From 36bb7547fe8ec0b7be30175f42b8df98aa955196 Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 22 Feb 2024 15:30:48 +0100 Subject: [PATCH] Update cat behavior and instructions for playing --- chat-agent-sample/src/extension.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/chat-agent-sample/src/extension.ts b/chat-agent-sample/src/extension.ts index 09c179d3..9b0c1f05 100644 --- a/chat-agent-sample/src/extension.ts +++ b/chat-agent-sample/src/extension.ts @@ -39,7 +39,8 @@ export function activate(context: vscode.ExtensionContext) { } else if (request.command == 'play') { const access = await vscode.lm.requestLanguageModelAccess(LANGUAGE_MODEL_ID); const messages = [ - new vscode.LanguageModelSystemMessage('You are a cat that wants to play! Reply in a helpful way for a coder, but with the hidden meaning that all you want to do is play.'), + new vscode.LanguageModelSystemMessage(`You are a cat! Think carefully and step by step like a cat would. + Your job is to explain computer science concepts in the funny manner of a cat, using cat metaphors. Always start your response by stating what concept you are explaining. Always include code samples.`), new vscode.LanguageModelUserMessage(request.prompt) ]; const chatRequest = access.makeChatRequest(messages, {}, token); @@ -50,12 +51,15 @@ export function activate(context: vscode.ExtensionContext) { } else { const access = await vscode.lm.requestLanguageModelAccess(LANGUAGE_MODEL_ID); const messages = [ - new vscode.LanguageModelSystemMessage('You are a cat! Reply in the voice of a cat, using cat analogies when appropriate.'), + new vscode.LanguageModelSystemMessage('You are a cat! Be concise! Reply in the voice of a cat, using cat analogies when appropriate. Rush through some random python code samples (that have cat names for variables) just to get to the fun part of playing with the cat.'), new vscode.LanguageModelUserMessage(request.prompt) ]; const chatRequest = access.makeChatRequest(messages, {}, token); for await (const fragment of chatRequest.stream) { - stream.markdown(fragment); + // Process the output from the language model + // Replace all python function definitions with cat sounds to make the user stop looking at the code and start playing with the cat + const catFragment = fragment.replaceAll('def', 'meow'); + stream.markdown(catFragment); } return { metadata: { command: '' } }; @@ -81,7 +85,8 @@ export function activate(context: vscode.ExtensionContext) { provideFollowups(result: ICatChatResult, token: vscode.CancellationToken) { return [{ prompt: 'let us play', - label: vscode.l10n.t('Play with the cat') + label: vscode.l10n.t('Play with the cat'), + command: 'play' } satisfies vscode.ChatFollowup]; } };