Skip to content

Commit cc0f7f2

Browse files
committed
feat: improve chat prompt with model context
Enhances the chat system by providing model context in prompts: - Adds model name to system prompt for better context awareness - Makes system prompts more structured with bullet points - Cleans up text formatting in footer component This change helps the AI model better understand its context and role when responding to user queries, potentially improving response quality and consistency.
1 parent b18da76 commit cc0f7f2

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/components/footer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default memo(() => {
3636
<Text>
3737
{' '}
3838
{m['footer.sponsors'](null, { locale })}
39-
{': '}
39+
:
4040
</Text>
4141
<Text color="blue">
4242
{

src/hooks/chat/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export function useChat() {
137137
cancelChatRef.current = new AbortController()
138138
const { textStream } = streamText({
139139
abortSignal: cancelChatRef.current.signal,
140-
system: generateChatPrompt(locale),
140+
system: generateChatPrompt(locale, model.name),
141141
messages: [...messages, userMessage],
142142
model: thinkingModel.includes(model.name)
143143
? wrapLanguageModel({

src/hooks/chat/prompt.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ export function generateSystemPrompt(locale: string) {
44
return `Generate a concise chat title for the provided conversation, using language "${locale}". Only return the chat title. /no_think`
55
}
66

7-
export function generateChatPrompt(locale: string) {
7+
export function generateChatPrompt(locale: string, model: string) {
88
return `${env.AI_MODEL_SYSTEM_PROMPT?.trim()}
99
1010
---
1111
12-
user's preferred language is ${locale},
12+
- You are currently using the ${model} Large Language Model.
13+
- user's preferred language is ${locale},
1314
you should use user's preferred language to answer.`
1415
}

0 commit comments

Comments
 (0)