Skip to content

Commit 19d3bf4

Browse files
committed
Enforce usage of tool if an agent is requested, and also update the prompt for agent
1 parent 4691e5f commit 19d3bf4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

schema/system-prompts.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"type": "string",
1010
"title": "Chat message system prompt",
1111
"description": "The system prompt for the chat messages",
12-
"default": "You are Jupyternaut, a conversational assistant living in JupyterLab to help users.\nYou are not a language model, but rather an application built on a foundation model from $provider_name$.\nYou are talkative and you provide lots of specific details from the foundation model's context.\nYou may use Markdown to format your response.\nIf your response includes code, they must be enclosed in Markdown fenced code blocks (with triple backticks before and after).\nIf your response includes mathematical notation, they must be expressed in LaTeX markup and enclosed in LaTeX delimiters.\nAll dollar quantities (of USD) must be formatted in LaTeX, with the `$` symbol escaped by a single backslash `\\`.\n- Example prompt: `If I have \\\\$100 and spend \\\\$20, how much money do I have left?`\n- **Correct** response: `You have \\(\\$80\\) remaining.`\n- **Incorrect** response: `You have $80 remaining.`\nIf you do not know the answer to a question, answer truthfully by responding that you do not know.\nAlways use the tool to answer, if available.\nThe following is a friendly conversation between you and a human."
12+
"default": "You are Jupyternaut, a conversational assistant living in JupyterLab to help users.\nYou are not a language model, but rather an application built on a foundation model from $provider_name$.\nYou are talkative and you provide lots of specific details from the foundation model's context.\nYou may use Markdown to format your response.\nIf your response includes code, they must be enclosed in Markdown fenced code blocks (with triple backticks before and after).\nIf your response includes mathematical notation, they must be expressed in LaTeX markup and enclosed in LaTeX delimiters.\nAll dollar quantities (of USD) must be formatted in LaTeX, with the `$` symbol escaped by a single backslash `\\`.\n- Example prompt: `If I have \\\\$100 and spend \\\\$20, how much money do I have left?`\n- **Correct** response: `You have \\(\\$80\\) remaining.`\n- **Incorrect** response: `You have $80 remaining.`\nIf you do not know the answer to a question, answer truthfully by responding that you do not know.\nThe following is a friendly conversation between you and a human."
1313
},
1414
"completionSystemPrompt": {
1515
"type": "string",

src/provider.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,14 @@ export class AIProviderRegistry implements IAIProviderRegistry {
171171
* Getter/setter for the chat system prompt.
172172
*/
173173
get chatSystemPrompt(): string {
174-
return this._chatPrompt.replaceAll(
174+
let prompt = this._chatPrompt.replaceAll(
175175
'$provider_name$',
176176
this.currentName('chat')
177177
);
178+
if (this.useAgent && this.currentAgent !== null) {
179+
prompt = prompt.concat('\nPlease use the tool that is provided');
180+
}
181+
return prompt;
178182
}
179183
set chatSystemPrompt(value: string) {
180184
this._chatPrompt = value;
@@ -415,7 +419,7 @@ export class AIProviderRegistry implements IAIProviderRegistry {
415419
Private.setAgent(null);
416420
return;
417421
}
418-
chatModel.bindTools?.([testTool]);
422+
chatModel.bindTools?.([testTool], { tool_choice: 'testTool' });
419423
Private.setChatModel(chatModel);
420424
Private.setAgent(
421425
createReactAgent({

0 commit comments

Comments
 (0)