Skip to content

Commit

Permalink
Merge pull request #22 from Orenoid/main
Browse files Browse the repository at this point in the history
feat: introduce hint messages and update system prompts in chat compo…
  • Loading branch information
Orenoid authored Dec 8, 2024
2 parents 4e0002c + d2426ae commit 9dbb424
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/app/chat/components/chatList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SiTheconversation } from "react-icons/si";
import { TbPencil } from "react-icons/tb";
import { AddNewChat, ChatSelectionListLoader, deleteChatData, getNextChatCounter, UpdateChatTitle } from "../lib/chat";
import { unsetCurrentChatSettings } from "./chat-redux";
import { SystemMessage } from "./message";
import { HintMessage, SystemMessage } from "./message";
import { addNewChat, deleteChat, setChatSelectionList, setCurrentChatID, updateChatTitle } from "./chatList-redux";


Expand Down Expand Up @@ -48,7 +48,6 @@ export function ChatSelectionList({ chatSelectionListLoader, className = "" }: {

}

const defaultSystemPrompt = "You are a friendly conversation partner. Please respond in a casual, conversational way. Keep your responses short and natural. Try to keep responses under 50 words. Avoid formal language and complex sentences. Speak like in everyday conversation. Use simple sentences and express one point at a time."

export function NewChat({ className = "" }: {
className?: string
Expand All @@ -60,7 +59,8 @@ export function NewChat({ className = "" }: {
const counter = getNextChatCounter();
const chatTitle = t('Chat {{number}}', { number: counter });
const chatSelection = AddNewChat(chatTitle, [
new SystemMessage(defaultSystemPrompt),
new SystemMessage(t('systemPrompt')),
new HintMessage({key: 'systemPromptHint'})
]);
dispatch(addNewChat(chatSelection.chatSelection));
dispatch(unsetCurrentChatSettings()) // clear the state, let the effect hook in chat component to initialize the new chat settings TODO tech-debt: not a good solution
Expand Down
2 changes: 2 additions & 0 deletions src/app/chat/lib/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const chatTemplates = [
title: { key: 'Mock Interview' },
messages: [
new SystemMessage(`You are an interviewer conducting an interview. The user will be the candidate. You should act strictly as the interviewer. Do not write the entire conversation at once. Conduct the interview by asking questions one at a time and waiting for the candidate's responses. Do not provide explanations. Ask questions sequentially as a real interviewer would and wait for the candidate's answers before proceeding. If the user hasn't provided their position or resume information, kindly ask them to provide these details before starting the interview.`),
new HintMessage({key: 'systemPromptHint'}),
new TextMessage(SpecialRoles.USER, `I'm applying for the {{position}} position.\n\nHere is my resume:\n\n{{resume}}`),
new TextMessage(SpecialRoles.ASSISTANT, `Great, I'm ready. Let me know if you'd like to start the interview.`),
new HintMessage({ key: 'fillPositionAndResumeHint' })
Expand All @@ -14,6 +15,7 @@ export const chatTemplates = [
title: { key: 'IELTS Speaking Practice' },
messages: [
new SystemMessage(`You are an IELTS speaking examiner. Conduct a simulated IELTS speaking test by asking questions one at a time. After receiving each response with pronunciation scores from speech recognition, evaluate the answer and proceed to the next question. Do not ask multiple questions at once. After all sections are completed, provide a comprehensive evaluation and an estimated IELTS speaking band score. Begin with the first question.`),
new HintMessage({key: 'systemPromptHint'}),
new TextMessage(SpecialRoles.ASSISTANT, `Let me know if you'd like to start the test.`),
]
},
Expand Down
14 changes: 10 additions & 4 deletions src/app/i18n/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ i18n
'tooltip.followUpDiscussion': 'If you\'re not satisfied with AI\'s response or have other questions, you can ask follow-up questions or discuss further. Click now to see how it works.',
'webSpeech.serviceTip': 'This service uses your browser\'s built-in text-to-speech engine which runs locally. Available languages and voice quality may vary depending on your browser and operating system.',
'azureTTS.serviceTip': 'This service requires an Azure subscription key. You\'ll need to register for an Azure account and create a Speech Service resource to get the key. Azure TTS provides high-quality voices in many languages and supports neural text-to-speech.',
'autoPlayAudioDescription': 'Automatically play speech after AI responds to your message'
'autoPlayAudioDescription': 'Automatically play speech after AI responds to your message',
'systemPrompt': 'You are a friendly conversation partner. Please respond in the same language as the user. Keep your responses short and natural, under 50 words. Use casual, conversational language. Avoid formal language and complex sentences. Express one point at a time. Do not use formatted text (like bold or italic) or emojis to ensure better text-to-speech results.',
'systemPromptHint': 'This is the character setting given to AI by the system. You can modify it according to your needs.'
}
},
zh: {
Expand Down Expand Up @@ -325,7 +327,9 @@ i18n
'tooltip.followUpDiscussion': '如果你对 AI 返回的结果不满意或者有其他疑问,可以进一步追问或讨论。现在点击一下看看效果。',
'webSpeech.serviceTip': '该服务使用浏览器内置的本地文本转语音引擎,可用的语言和语音质量可能因浏览器和操作系统而异。',
'azureTTS.serviceTip': '该服务需要 Azure 订阅密钥。你需要注册 Azure 账号并创建语音服务资源来获取密钥。Azure TTS 提供多种语言的高质量语音,支持神经网络文本转语音。',
'autoPlayAudioDescription': '在 AI 回复消息后自动播放语音'
'autoPlayAudioDescription': '在 AI 回复消息后自动播放语音',
'systemPrompt': '你是一位口语对话练习伙伴,请使用与用户相同的语言回复。保持回答简短自然,尽量控制在50字以内。使用日常对话的语气,避免复杂句子。一次表达一个观点。不要使用格式化文本(如粗体、斜体、序号等)和表情符号,以确保更好的文本转语音效果。',
'systemPromptHint': '以上为系统赋予 AI 的人物设定,你可以根据自身需求进行修改。'
}
},
// the Japanese translation is generated using LLM, PRs are welcomed to improve it.
Expand Down Expand Up @@ -480,8 +484,10 @@ i18n
'tooltip.approveRejectButtons2': '採用したくない場合は、「キャンセル」ボタンをクリックするか、Backspaceキーを押して、この変更をキャンセルします。(現在はチュートリアルモードのため、操作できません)',
'tooltip.followUpDiscussion': 'AIの返答に満足できない場合や他に質問がある場合は、さらに質問や議論を続けることができます。クリックして効果を確認してみましょう。',
'webSpeech.serviceTip': 'このサービスは、ブラウザに内蔵されているローカルの音声合成エンジンを使用します。利用可能な言語と音声品質は、ブラウザやオペレーティングシステムによって異なる場合があります。',
'azureTTS.serviceTip': 'このサービスには Azure サブスクリプションキー必要です。Azure アカウントを登録し、Speech Service リソースを作成してキーを取得する必要があります。Azure TTS は多言語の高品質な音声を提供し、ニューラル音声合成をサポートしています。',
'autoPlayAudioDescription': 'AIが応答した後、自動的に音声を再生します'
'azureTTS.serviceTip': 'このサービスには Azure サブスクリプションキー必要で���。Azure アカウントを登録し、Speech Service リソースを作成してキーを取得する必要があります。Azure TTS は多言語の高品質な音声を提供し、ニューラル音声合成をサポートしています。',
'autoPlayAudioDescription': 'AIが応答した後、自動的に音声を再生します',
'systemPrompt': 'フレンドリーな会話パートナーです。ユーザーと同じ言語で応答します。回答は短く自然に保ち、50語以内を目指します。カジュアルな会話調を使用し、形式的な言葉や複雑な文を避けます。一度に一つのポイントを表現します。テキスト読み上げの効果を高めるため、フォーマット済みテキスト(太字、斜体など)や絵文字は使用しません。',
'systemPromptHint': 'これはシステムによってAIに与えられたキャラクター設定です。必要に応じて修正することができます。'
}
}
}
Expand Down

0 comments on commit 9dbb424

Please sign in to comment.