Merge pull request #1056 from mjbvz/compatible-shrimp

Fix linting for chat sample
This commit is contained in:
Matt Bierner
2024-06-27 14:24:54 -07:00
committed by GitHub
5 changed files with 1655 additions and 1705 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,65 @@
{
"name": "chat-sample",
"publisher": "vscode-samples",
"displayName": "Copilot Chat Sample",
"description": "Sample chat extension, a trusty cat tutor that will can teach you computer science topics.",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-extension-samples"
},
"version": "0.1.0",
"engines": {
"vscode": "^1.90.0"
},
"categories": [
"AI",
"Chat"
],
"activationEvents": [],
"enabledApiProposals": [
"chatVariableResolver"
],
"contributes": {
"chatParticipants": [
{
"id": "chat-sample.cat",
"fullName": "Cat",
"name": "cat",
"description": "Meow! What can I teach you?",
"isSticky": true,
"commands": [
{
"name": "teach",
"description": "Pick at random a computer science concept then explain it in purfect way of a cat"
},
{
"name": "play",
"description": "Do whatever you want, you are a cat after all"
}
]
}
],
"commands": [
{
"command": "cat.namesInEditor",
"title": "Use Cat Names in Editor"
}
]
},
"main": "./out/extension.js",
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./"
},
"devDependencies": {
"@types/node": "^20.5.9",
"@vscode/prompt-tsx": "^0.2.3-alpha",
"@types/vscode": "1.90.0",
"eslint": "^7.22.0",
"run-script-os": "^1.1.6",
"tslint": "^6.1.3",
"typescript": "^5.5.2"
}
}
"name": "chat-sample",
"publisher": "vscode-samples",
"displayName": "Copilot Chat Sample",
"description": "Sample chat extension, a trusty cat tutor that will can teach you computer science topics.",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-extension-samples"
},
"version": "0.1.0",
"engines": {
"vscode": "^1.90.0"
},
"categories": [
"AI",
"Chat"
],
"activationEvents": [],
"enabledApiProposals": [
"chatVariableResolver"
],
"contributes": {
"chatParticipants": [
{
"id": "chat-sample.cat",
"fullName": "Cat",
"name": "cat",
"description": "Meow! What can I teach you?",
"isSticky": true,
"commands": [
{
"name": "teach",
"description": "Pick at random a computer science concept then explain it in purfect way of a cat"
},
{
"name": "play",
"description": "Do whatever you want, you are a cat after all"
}
]
}
],
"commands": [
{
"command": "cat.namesInEditor",
"title": "Use Cat Names in Editor"
}
]
},
"main": "./out/extension.js",
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"lint": "eslint \"src/**/*.ts\"",
"watch": "tsc -watch -p ./"
},
"devDependencies": {
"@types/node": "^20.5.9",
"@vscode/prompt-tsx": "^0.2.3-alpha",
"@types/vscode": "1.90.0",
"@typescript-eslint/eslint-plugin": "^7.14.0",
"@typescript-eslint/parser": "^7.14.0",
"eslint": "^8.26.0",
"typescript": "^5.5.2"
}
}

View File

@ -20,7 +20,7 @@ export function activate(context: vscode.ExtensionContext) {
// To talk to an LLM in your subcommand handler implementation, your
// extension can use VS Code's `requestChatAccess` API to access the Copilot API.
// The GitHub Copilot Chat extension implements this provider.
if (request.command == 'teach') {
if (request.command === 'teach') {
stream.progress('Picking the right topic to teach...');
const topic = getTopic(context.history);
try {
@ -46,7 +46,7 @@ export function activate(context: vscode.ExtensionContext) {
});
return { metadata: { command: 'teach' } };
} else if (request.command == 'play') {
} else if (request.command === 'play') {
stream.progress('Throwing away the computer science books and preparing to play with some Python code...');
try {
const [model] = await vscode.lm.selectChatModels(MODEL_SELECTOR);
@ -120,7 +120,7 @@ export function activate(context: vscode.ExtensionContext) {
try {
const [model] = await vscode.lm.selectChatModels({ vendor: 'copilot', family: 'gpt-3.5-turbo' });
if (!model) {
console.log('Model not found. Please make sure the GitHub Copilot Chat extension is installed and enabled.')
console.log('Model not found. Please make sure the GitHub Copilot Chat extension is installed and enabled.');
return;
}
@ -133,7 +133,7 @@ export function activate(context: vscode.ExtensionContext) {
} catch (err) {
if (err instanceof vscode.LanguageModelError) {
console.log(err.message, err.code, err.cause)
console.log(err.message, err.code, err.cause);
} else {
throw err;
}
@ -189,13 +189,13 @@ function getTopic(history: ReadonlyArray<vscode.ChatRequestTurn | vscode.ChatRes
const topics = ['linked list', 'recursion', 'stack', 'queue', 'pointers'];
// Filter the chat history to get only the responses from the cat
const previousCatResponses = history.filter(h => {
return h instanceof vscode.ChatResponseTurn && h.participant == CAT_PARTICIPANT_ID
return h instanceof vscode.ChatResponseTurn && h.participant === CAT_PARTICIPANT_ID;
}) as vscode.ChatResponseTurn[];
// Filter the topics to get only the topics that have not been taught by the cat yet
const topicsNoRepetition = topics.filter(topic => {
return !previousCatResponses.some(catResponse => {
return catResponse.response.some(r => {
return r instanceof vscode.ChatResponseMarkdownPart && r.value.value.includes(topic)
return r instanceof vscode.ChatResponseMarkdownPart && r.value.value.includes(topic);
});
});
});

View File

@ -34,8 +34,8 @@
"@types/vscode": "^1.88.0",
"@types/node": "18.x",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"@typescript-eslint/parser": "^7.14.0",
"eslint": "^8.57.0",
"typescript": "^5.3.3"
"typescript": "^5.5.2"
}
}

View File

@ -45,7 +45,7 @@
"@types/vscode-webview": "^1.57.0",
"@typescript-eslint/eslint-plugin": "^7.14.0",
"@typescript-eslint/parser": "^7.14.0",
"eslint": "^8.26.0",
"eslint": "^8.57.0",
"typescript": "^5.5.2"
}
}