Skip to content

Commit

Permalink
fix: specify language for builtin agents
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-jianliang committed May 26, 2024
1 parent 4219e0c commit 076833a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/agent/chat-with-the-bot.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"selection": {
"type": "ChatGPT",
"model": "gpt-3.5-turbo",
"systemPrompt": "Your are an assistant powered by OpenAI",
"systemPrompt": "# Character\nYou are an AI assistant powered by advanced, state-of-the-art models.\n# Language: ${language}",
"prompt": "${selection}"
},
"all": {
Expand Down
2 changes: 1 addition & 1 deletion src/agent/whats-this.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"engine": "ChatGPT",
"models": ["gpt-3.5-turbo"],
"tags": ["common"],
"systemPrompt": "Please provide a clear and concise explanation for the details that the user is seeking. This could be a word with a certain connotation, a unique phrase, a complete sentence, or a specific term.",
"systemPrompt": "Please provide a clear and concise explanation for the details that the user is seeking in ${language}. This could be a word with a certain connotation, a unique phrase, a complete sentence, or a specific term.",
"prompts": {
"selection": "What is '${selection}'.",
"image": "What is in this image?"
Expand Down
13 changes: 9 additions & 4 deletions src/pages/content/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,30 @@ export default function App() {

let prompt: string = '';
let chatTitle = agent.name;
let systemPrompt: string = '';
if (info.selectionText) {
prompt = getPrompt(agent, 'selection').replace('${selection}', info.selectionText);
const textSystemPrompt = getSystemPrompt(agent, 'selection');
chatTitle = `${chatTitle} - ${info.selectionText}`;
setInputType('selection');
setSystemPrompt(textSystemPrompt);
systemPrompt = textSystemPrompt;
} else if (info.mediaType == 'image') {
prompt = getPrompt(agent, 'image');
const imageSystemPrompt = getSystemPrompt(agent, 'image');
setInputType('image');
setSystemPrompt(imageSystemPrompt);
systemPrompt = imageSystemPrompt;
} else {
setInputType('default');
setSystemPrompt(getSystemPrompt(agent, 'default'));
systemPrompt = getSystemPrompt(agent, 'default');
}

const language = getLanguageName();
systemPrompt = systemPrompt.replace('${language}', language);
setSystemPrompt(systemPrompt);

if (prompt.length > 0) {
// replace "${language}" with the current language
prompt = prompt.replace('${language}', getLanguageName());
prompt = prompt.replace('${language}', language);
console.log('prompt', prompt);
if (agent.autoSend) {
setMessages(() => {
Expand Down

0 comments on commit 076833a

Please sign in to comment.