From 3ac0dbc25299b4dad38fbc404e8f8c4648cb8112 Mon Sep 17 00:00:00 2001 From: isidorn Date: Thu, 2 May 2024 14:14:53 +0200 Subject: [PATCH] do not use system prompt --- chat-sample/src/extension.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/chat-sample/src/extension.ts b/chat-sample/src/extension.ts index 80fe4788..22713450 100644 --- a/chat-sample/src/extension.ts +++ b/chat-sample/src/extension.ts @@ -22,8 +22,8 @@ export function activate(context: vscode.ExtensionContext) { stream.progress('Picking the right topic to teach...'); const topic = getTopic(context.history); const messages = [ - new vscode.LanguageModelChatSystemMessage('You are a cat! Your job is to explain computer science concepts in the funny manner of a cat. Always start your response by stating what concept you are explaining. Always include code samples.'), - new vscode.LanguageModelChatUserMessage(topic) + new vscode.LanguageModelChatUserMessage(`You are a cat! Your job is to explain computer science concepts in the funny manner of a cat. + Always start your response by stating what concept you are explaining. Always include code samples. Explain the following \n` + topic) ]; const chatResponse = await vscode.lm.sendChatRequest(LANGUAGE_MODEL_ID, messages, {}, token); for await (const fragment of chatResponse.stream) { @@ -39,8 +39,8 @@ export function activate(context: vscode.ExtensionContext) { } else if (request.command == 'play') { stream.progress('Throwing away the computer science books and preparing to play with some Python code...'); const messages = [ - new vscode.LanguageModelChatSystemMessage('You are a cat! Reply in the voice of a cat, using cat analogies when appropriate. Be concise to prepare for cat play time.'), - new vscode.LanguageModelChatUserMessage('Give a small random python code samples (that have cat names for variables). ' + request.prompt) + new vscode.LanguageModelChatUserMessage(`You are a cat! Reply in the voice of a cat, using cat analogies when appropriate. + Be concise to prepare for cat play time. Give a small random python code samples (that have cat names for variables). \n` + request.prompt) ]; const chatResponse = await vscode.lm.sendChatRequest(LANGUAGE_MODEL_ID, messages, {}, token); for await (const fragment of chatResponse.stream) { @@ -49,9 +49,8 @@ export function activate(context: vscode.ExtensionContext) { return { metadata: { command: 'play' } }; } else { const messages = [ - new vscode.LanguageModelChatSystemMessage(`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.LanguageModelChatUserMessage(request.prompt) + new vscode.LanguageModelChatUserMessage(`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. \n` + request.prompt) ]; const chatResponse = await vscode.lm.sendChatRequest(LANGUAGE_MODEL_ID, messages, {}, token); for await (const fragment of chatResponse.stream) { @@ -109,9 +108,8 @@ export function activate(context: vscode.ExtensionContext) { // Replace all variables in active editor with cat names and words const text = textEditor.document.getText(); const messages = [ - new vscode.LanguageModelChatSystemMessage(`You are a cat! Think carefully and step by step like a cat would. - Your job is to replace all variable names in the following code with funny cat variable names. Be creative. IMPORTANT respond just with code. Do not use markdown!`), - new vscode.LanguageModelChatUserMessage(text) + new vscode.LanguageModelChatUserMessage(`You are a cat! Think carefully and step by step like a cat would. + Your job is to replace all variable names in the following code with funny cat variable names. Be creative. IMPORTANT respond just with code. Do not use markdown! Code: \n` + text) ]; let chatResponse: vscode.LanguageModelChatResponse | undefined;