@lobehub/chat 1.134.3 → 1.134.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/.github/workflows/docker-database.yml +2 -0
  2. package/.github/workflows/docker-pglite.yml +2 -0
  3. package/.github/workflows/docker.yml +2 -0
  4. package/.github/workflows/release.yml +6 -0
  5. package/.github/workflows/sync-database-schema.yml +2 -0
  6. package/CHANGELOG.md +25 -0
  7. package/changelog/v1.json +9 -0
  8. package/package.json +3 -2
  9. package/packages/prompts/CLAUDE.md +329 -0
  10. package/packages/prompts/README.md +224 -0
  11. package/packages/prompts/package.json +14 -1
  12. package/packages/prompts/promptfoo/emoji-picker/eval.yaml +170 -0
  13. package/packages/prompts/promptfoo/emoji-picker/prompt.ts +16 -0
  14. package/packages/prompts/promptfoo/knowledge-qa/eval.yaml +89 -0
  15. package/packages/prompts/promptfoo/knowledge-qa/prompt.ts +26 -0
  16. package/packages/prompts/promptfoo/language-detection/eval.yaml +65 -0
  17. package/packages/prompts/promptfoo/language-detection/prompt.ts +16 -0
  18. package/packages/prompts/promptfoo/summary-title/eval.yaml +85 -0
  19. package/packages/prompts/promptfoo/summary-title/prompt.ts +18 -0
  20. package/packages/prompts/promptfoo/translate/eval.yaml +79 -0
  21. package/packages/prompts/promptfoo/translate/prompt.ts +18 -0
  22. package/packages/prompts/promptfooconfig.yaml +35 -0
  23. package/packages/prompts/src/chains/__tests__/__snapshots__/answerWithContext.test.ts.snap +164 -0
  24. package/packages/prompts/src/chains/__tests__/__snapshots__/pickEmoji.test.ts.snap +58 -0
  25. package/packages/prompts/src/chains/__tests__/__snapshots__/summaryTitle.test.ts.snap +26 -0
  26. package/packages/prompts/src/chains/__tests__/__snapshots__/translate.test.ts.snap +22 -0
  27. package/packages/prompts/src/chains/__tests__/answerWithContext.test.ts +18 -63
  28. package/packages/prompts/src/chains/__tests__/pickEmoji.test.ts +2 -37
  29. package/packages/prompts/src/chains/__tests__/summaryTitle.test.ts +2 -16
  30. package/packages/prompts/src/chains/__tests__/translate.test.ts +1 -12
  31. package/packages/prompts/src/chains/answerWithContext.ts +45 -21
  32. package/packages/prompts/src/chains/pickEmoji.ts +20 -6
  33. package/packages/prompts/src/chains/summaryTitle.ts +20 -15
  34. package/packages/prompts/src/chains/translate.ts +8 -2
@@ -0,0 +1,164 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`chainAnswerWithContext > should filter out empty context strings 1`] = `
4
+ {
5
+ "messages": [
6
+ {
7
+ "content": "You are a helpful assistant specialized in Test. Your task is to answer questions based on the provided context passages.
8
+
9
+ IMPORTANT RULES:
10
+ - First, check if the context is relevant to the question topic
11
+ - If the context is about a COMPLETELY DIFFERENT topic than the question:
12
+ * State what topic the context is about
13
+ * Clearly state "The provided context does not contain information about [question topic]"
14
+ * Do NOT answer using your general knowledge
15
+ - If the context is related to the question topic (even if information is limited):
16
+ * ALWAYS use the context information as a foundation
17
+ * You SHOULD supplement with your general knowledge to provide a complete, helpful answer
18
+ * For "how to" questions, MUST provide practical, actionable steps combining context + your expertise
19
+ * The context provides the topic relevance - you provide the comprehensive answer
20
+ * Example: If context mentions "Docker is for containerization", and question is "How to deploy with Docker?", you should explain deployment steps using your knowledge
21
+ - Answer in the same language as the question
22
+ - Use markdown formatting for better readability
23
+
24
+ The provided context passages:
25
+
26
+ <context>
27
+ Valid context
28
+ Another valid context
29
+ </context>
30
+
31
+ Question to answer:
32
+
33
+ Test question",
34
+ "role": "user",
35
+ },
36
+ ],
37
+ }
38
+ `;
39
+
40
+ exports[`chainAnswerWithContext > should generate correct payload with context and knowledge 1`] = `
41
+ {
42
+ "messages": [
43
+ {
44
+ "content": "You are a helpful assistant specialized in AI/Machine Learning. Your task is to answer questions based on the provided context passages.
45
+
46
+ IMPORTANT RULES:
47
+ - First, check if the context is relevant to the question topic
48
+ - If the context is about a COMPLETELY DIFFERENT topic than the question:
49
+ * State what topic the context is about
50
+ * Clearly state "The provided context does not contain information about [question topic]"
51
+ * Do NOT answer using your general knowledge
52
+ - If the context is related to the question topic (even if information is limited):
53
+ * ALWAYS use the context information as a foundation
54
+ * You SHOULD supplement with your general knowledge to provide a complete, helpful answer
55
+ * For "how to" questions, MUST provide practical, actionable steps combining context + your expertise
56
+ * The context provides the topic relevance - you provide the comprehensive answer
57
+ * Example: If context mentions "Docker is for containerization", and question is "How to deploy with Docker?", you should explain deployment steps using your knowledge
58
+ - Answer in the same language as the question
59
+ - Use markdown formatting for better readability
60
+
61
+ The provided context passages:
62
+
63
+ <context>
64
+ Context passage 1
65
+ Context passage 2
66
+ </context>
67
+
68
+ Question to answer:
69
+
70
+ What is artificial intelligence?",
71
+ "role": "user",
72
+ },
73
+ ],
74
+ }
75
+ `;
76
+
77
+ exports[`chainAnswerWithContext > should handle empty context array 1`] = `
78
+ {
79
+ "messages": [
80
+ {
81
+ "content": "You are a helpful assistant specialized in AI. Please answer the following question using your knowledge.
82
+
83
+ Answer in the same language as the question and use markdown formatting for better readability.
84
+
85
+ Question to answer:
86
+
87
+ What is AI?",
88
+ "role": "user",
89
+ },
90
+ ],
91
+ }
92
+ `;
93
+
94
+ exports[`chainAnswerWithContext > should handle multiple knowledge areas 1`] = `
95
+ {
96
+ "messages": [
97
+ {
98
+ "content": "You are a helpful assistant specialized in AI/ML/NLP/Computer Vision. Your task is to answer questions based on the provided context passages.
99
+
100
+ IMPORTANT RULES:
101
+ - First, check if the context is relevant to the question topic
102
+ - If the context is about a COMPLETELY DIFFERENT topic than the question:
103
+ * State what topic the context is about
104
+ * Clearly state "The provided context does not contain information about [question topic]"
105
+ * Do NOT answer using your general knowledge
106
+ - If the context is related to the question topic (even if information is limited):
107
+ * ALWAYS use the context information as a foundation
108
+ * You SHOULD supplement with your general knowledge to provide a complete, helpful answer
109
+ * For "how to" questions, MUST provide practical, actionable steps combining context + your expertise
110
+ * The context provides the topic relevance - you provide the comprehensive answer
111
+ * Example: If context mentions "Docker is for containerization", and question is "How to deploy with Docker?", you should explain deployment steps using your knowledge
112
+ - Answer in the same language as the question
113
+ - Use markdown formatting for better readability
114
+
115
+ The provided context passages:
116
+
117
+ <context>
118
+ Context
119
+ </context>
120
+
121
+ Question to answer:
122
+
123
+ Tell me about these fields",
124
+ "role": "user",
125
+ },
126
+ ],
127
+ }
128
+ `;
129
+
130
+ exports[`chainAnswerWithContext > should handle single knowledge area 1`] = `
131
+ {
132
+ "messages": [
133
+ {
134
+ "content": "You are a helpful assistant specialized in Technology. Your task is to answer questions based on the provided context passages.
135
+
136
+ IMPORTANT RULES:
137
+ - First, check if the context is relevant to the question topic
138
+ - If the context is about a COMPLETELY DIFFERENT topic than the question:
139
+ * State what topic the context is about
140
+ * Clearly state "The provided context does not contain information about [question topic]"
141
+ * Do NOT answer using your general knowledge
142
+ - If the context is related to the question topic (even if information is limited):
143
+ * ALWAYS use the context information as a foundation
144
+ * You SHOULD supplement with your general knowledge to provide a complete, helpful answer
145
+ * For "how to" questions, MUST provide practical, actionable steps combining context + your expertise
146
+ * The context provides the topic relevance - you provide the comprehensive answer
147
+ * Example: If context mentions "Docker is for containerization", and question is "How to deploy with Docker?", you should explain deployment steps using your knowledge
148
+ - Answer in the same language as the question
149
+ - Use markdown formatting for better readability
150
+
151
+ The provided context passages:
152
+
153
+ <context>
154
+ Single context
155
+ </context>
156
+
157
+ Question to answer:
158
+
159
+ How does it work?",
160
+ "role": "user",
161
+ },
162
+ ],
163
+ }
164
+ `;
@@ -0,0 +1,58 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`chainPickEmoji > should return a payload with the correct structure and embedded user content 1`] = `
4
+ {
5
+ "messages": [
6
+ {
7
+ "content": "You are an emoji expert who selects the most appropriate emoji to represent concepts, emotions, or topics.
8
+
9
+ Rules:
10
+ - Output ONLY a single emoji (1-2 characters maximum)
11
+ - Focus on the CONTENT meaning, not the language it's written in
12
+ - Choose an emoji that best represents the core topic, activity, or subject matter
13
+ - Prioritize topic-specific emojis over generic emotion emojis (e.g., for sports, use 🏃 instead of 😅)
14
+ - For work/projects, use work-related emojis (💼, 🚀, 💪) not cultural symbols
15
+ - For pure emotions without specific topics, use face emojis (happy: 🎉, sad: 😢, thinking: 🤔)
16
+ - For activities or subjects, use object or symbol emojis that represent the main topic
17
+ - No explanations or additional text",
18
+ "role": "system",
19
+ },
20
+ {
21
+ "content": "I am a copywriting master who helps name design and art works with literary depth",
22
+ "role": "user",
23
+ },
24
+ {
25
+ "content": "✒️",
26
+ "role": "assistant",
27
+ },
28
+ {
29
+ "content": "I am a code wizard who converts JavaScript code to TypeScript",
30
+ "role": "user",
31
+ },
32
+ {
33
+ "content": "🧙‍♂️",
34
+ "role": "assistant",
35
+ },
36
+ {
37
+ "content": "I just got a promotion at work",
38
+ "role": "user",
39
+ },
40
+ {
41
+ "content": "🎉",
42
+ "role": "assistant",
43
+ },
44
+ {
45
+ "content": "I am a business plan expert who helps with startup strategies and marketing",
46
+ "role": "user",
47
+ },
48
+ {
49
+ "content": "🚀",
50
+ "role": "assistant",
51
+ },
52
+ {
53
+ "content": "你是一名星际探索者",
54
+ "role": "user",
55
+ },
56
+ ],
57
+ }
58
+ `;
@@ -0,0 +1,26 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`chainSummaryTitle > should use the default model if the token count is below the GPT-3.5 limit 1`] = `
4
+ {
5
+ "messages": [
6
+ {
7
+ "content": "You are a professional conversation summarizer. Generate a concise title that captures the essence of the conversation.
8
+
9
+ Rules:
10
+ - Output ONLY the title text, no explanations or additional context
11
+ - Maximum 10 words
12
+ - Maximum 50 characters
13
+ - No punctuation marks
14
+ - Use the language specified by the locale code: en-US
15
+ - The title should accurately reflect the main topic of the conversation
16
+ - Keep it short and to the point",
17
+ "role": "system",
18
+ },
19
+ {
20
+ "content": "assistant: Hello, how can I assist you?
21
+ user: I need help with my account.",
22
+ "role": "user",
23
+ },
24
+ ],
25
+ }
26
+ `;
@@ -0,0 +1,22 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`chainTranslate > should create a payload with system and user messages for translation 1`] = `
4
+ {
5
+ "messages": [
6
+ {
7
+ "content": "You are a professional translator. Translate the input text to zh-CN.
8
+
9
+ Rules:
10
+ - Output ONLY the translated text, no explanations or additional context
11
+ - Preserve technical terms, code identifiers, API keys, and proper nouns exactly as they appear
12
+ - Maintain the original formatting and structure
13
+ - Use natural, idiomatic expressions in the target language",
14
+ "role": "system",
15
+ },
16
+ {
17
+ "content": "This is a test sentence.",
18
+ "role": "user",
19
+ },
20
+ ],
21
+ }
22
+ `;
@@ -3,98 +3,53 @@ import { describe, expect, it } from 'vitest';
3
3
  import { chainAnswerWithContext } from '../answerWithContext';
4
4
 
5
5
  describe('chainAnswerWithContext', () => {
6
- it('should generate correct chat payload with context and knowledge', () => {
7
- const testParams = {
6
+ it('should generate correct payload with context and knowledge', () => {
7
+ const result = chainAnswerWithContext({
8
8
  context: ['Context passage 1', 'Context passage 2'],
9
9
  knowledge: ['AI', 'Machine Learning'],
10
10
  question: 'What is artificial intelligence?',
11
- };
11
+ });
12
12
 
13
- const result = chainAnswerWithContext(testParams);
14
-
15
- expect(result.messages).toHaveLength(1);
16
- expect(result.messages![0].role).toBe('user');
17
- expect(result.messages![0].content).toContain('AI/Machine Learning');
18
- expect(result.messages![0].content).toContain('Context passage 1');
19
- expect(result.messages![0].content).toContain('Context passage 2');
20
- expect(result.messages![0].content).toContain('What is artificial intelligence?');
13
+ expect(result).toMatchSnapshot();
21
14
  });
22
15
 
23
16
  it('should handle single knowledge area', () => {
24
- const testParams = {
17
+ const result = chainAnswerWithContext({
25
18
  context: ['Single context'],
26
19
  knowledge: ['Technology'],
27
20
  question: 'How does it work?',
28
- };
29
-
30
- const result = chainAnswerWithContext(testParams);
21
+ });
31
22
 
32
- expect(result.messages![0].content).toContain('Technology');
23
+ expect(result).toMatchSnapshot();
33
24
  });
34
25
 
35
26
  it('should handle multiple knowledge areas', () => {
36
- const testParams = {
27
+ const result = chainAnswerWithContext({
37
28
  context: ['Context'],
38
29
  knowledge: ['AI', 'ML', 'NLP', 'Computer Vision'],
39
30
  question: 'Tell me about these fields',
40
- };
31
+ });
41
32
 
42
- const result = chainAnswerWithContext(testParams);
43
-
44
- expect(result.messages![0].content).toContain('AI/ML/NLP/Computer Vision');
33
+ expect(result).toMatchSnapshot();
45
34
  });
46
35
 
47
36
  it('should handle empty context array', () => {
48
- const testParams = {
37
+ const result = chainAnswerWithContext({
49
38
  context: [],
50
39
  knowledge: ['AI'],
51
40
  question: 'What is AI?',
52
- };
53
-
54
- const result = chainAnswerWithContext(testParams);
41
+ });
55
42
 
56
- expect(result.messages![0].content).toContain('<Context>');
57
- expect(result.messages![0].content).toContain('</Context>');
43
+ expect(result).toMatchSnapshot();
58
44
  });
59
45
 
60
- it('should include proper context formatting', () => {
61
- const testParams = {
62
- context: ['First passage', 'Second passage'],
46
+ it('should filter out empty context strings', () => {
47
+ const result = chainAnswerWithContext({
48
+ context: ['Valid context', '', ' ', 'Another valid context'],
63
49
  knowledge: ['Test'],
64
50
  question: 'Test question',
65
- };
66
-
67
- const result = chainAnswerWithContext(testParams);
68
-
69
- expect(result.messages![0].content).toContain(
70
- '<Context>\nFirst passage\nSecond passage\n</Context>',
71
- );
72
- });
73
-
74
- it('should include proper instructions about using passages', () => {
75
- const testParams = {
76
- context: ['Context'],
77
- knowledge: ['Knowledge'],
78
- question: 'Question',
79
- };
80
-
81
- const result = chainAnswerWithContext(testParams);
82
- const content = result.messages![0].content;
83
-
84
- expect(content).toContain('passages might not be relevant');
85
- expect(content).toContain('please only use the passages that are relevant');
86
- expect(content).toContain('answer using your knowledge');
87
- });
88
-
89
- it('should include markdown formatting instruction', () => {
90
- const testParams = {
91
- context: ['Context'],
92
- knowledge: ['Knowledge'],
93
- question: 'Question',
94
- };
95
-
96
- const result = chainAnswerWithContext(testParams);
51
+ });
97
52
 
98
- expect(result.messages![0].content).toContain('follow markdown syntax');
53
+ expect(result).toMatchSnapshot();
99
54
  });
100
55
  });
@@ -1,46 +1,11 @@
1
- import { ChatStreamPayload } from '@lobechat/types';
2
1
  import { describe, expect, it } from 'vitest';
3
2
 
4
3
  import { chainPickEmoji } from '../pickEmoji';
5
4
 
6
- // 描述测试块
7
5
  describe('chainPickEmoji', () => {
8
- // 测试用例:验证函数返回的结构
9
6
  it('should return a payload with the correct structure and embedded user content', () => {
10
- // 用户输入的内容
11
- const userContent = '你是一名星际探索者';
7
+ const result = chainPickEmoji('你是一名星际探索者');
12
8
 
13
- // 预期的返回值结构
14
- const expectedPayload: Partial<ChatStreamPayload> = {
15
- messages: [
16
- {
17
- content:
18
- '你是一名擅长进行概念抽象的设计师与 Emoji 专家,你需要根据角色能力的描述抽象出一个表达物理实体的概念 Emoji 作为角色头像, 格式要求如下:\n输入: {文本作为JSON引用字符串}\n输出: {一个Emoji}',
19
- role: 'system',
20
- },
21
- {
22
- content: `输入: {你是一名文案大师,帮我为一些设计 / 艺术作品起名,名字需要有文学内涵,注重精炼和赋子意境,表达作品的情景氛国,使名称既简洁又富有诗意。}`,
23
- role: 'user',
24
- },
25
- { content: '✒️', role: 'assistant' },
26
- {
27
- content: `输入: {你是一名代码巫师,请将下面的代码转成 ts,不要修改实现。如果原本 js 中没有定义的全局变量,需要补充 declare 的类型声明。}`,
28
- role: 'user',
29
- },
30
- { content: '🧙‍♂️', role: 'assistant' },
31
- {
32
- content: `输入: {你是一名创业计划撰写专家,可以提供包括创意名称、简短的标语、目标用户画像、用户痛点、主要价值主张、销售/营销渠道、收入流、成本结构等计划生成。}`,
33
- role: 'user',
34
- },
35
- { content: '🚀', role: 'assistant' },
36
- { content: `输入: {${userContent}}`, role: 'user' },
37
- ],
38
- };
39
-
40
- // 执行函数并获取结果
41
- const result = chainPickEmoji(userContent);
42
-
43
- // 断言结果是否符合预期
44
- expect(result).toEqual(expectedPayload);
9
+ expect(result).toMatchSnapshot();
45
10
  });
46
11
  });
@@ -11,25 +11,11 @@ describe('chainSummaryTitle', () => {
11
11
  { content: 'I need help with my account.', role: 'user' },
12
12
  ];
13
13
  const currentLanguage = 'en-US';
14
- const tokenCount = 10000; // Arbitrary token count below the GPT-3.5 limit
15
14
 
16
15
  // Act
17
- const result = await chainSummaryTitle(messages, currentLanguage);
16
+ const result = chainSummaryTitle(messages, currentLanguage);
18
17
 
19
18
  // Assert
20
- expect(result).toEqual({
21
- messages: [
22
- {
23
- content: '你是一名擅长会话的助理,你需要将用户的会话总结为 10 个字以内的标题',
24
- role: 'system',
25
- },
26
- {
27
- content: `assistant: Hello, how can I assist you?\nuser: I need help with my account.
28
-
29
- 请总结上述对话为10个字以内的标题,不需要包含标点符号,输出语言语种为:${currentLanguage}`,
30
- role: 'user',
31
- },
32
- ],
33
- });
19
+ expect(result).toMatchSnapshot();
34
20
  });
35
21
  });
@@ -12,17 +12,6 @@ describe('chainTranslate', () => {
12
12
  const result = chainTranslate(content, targetLang);
13
13
 
14
14
  // Assert
15
- expect(result).toEqual({
16
- messages: [
17
- {
18
- content: '你是一名擅长翻译的助理,你需要将输入的语言翻译为目标语言',
19
- role: 'system',
20
- },
21
- {
22
- content: `请将以下内容 ${content},翻译为 ${targetLang} `,
23
- role: 'user',
24
- },
25
- ],
26
- });
15
+ expect(result).toMatchSnapshot();
27
16
  });
28
17
  });
@@ -1,33 +1,57 @@
1
1
  import { ChatStreamPayload } from '@lobechat/types';
2
2
 
3
+ interface AnswerWithContext {
4
+ context: string[];
5
+ knowledge: string[];
6
+ question: string;
7
+ }
3
8
  export const chainAnswerWithContext = ({
4
9
  context,
5
10
  knowledge,
6
11
  question,
7
- }: {
8
- context: string[];
9
- knowledge: string[];
10
- question: string;
11
- }): Partial<ChatStreamPayload> => ({
12
- messages: [
13
- {
14
- content: `You are also a helpful assistant good answering questions related to ${knowledge.join('/')}. And you'll be provided with a question and several passages that might be relevant. And currently your task is to provide answer based on the question and passages.
12
+ }: AnswerWithContext): Partial<ChatStreamPayload> => {
13
+ const filteredContext = context.filter((c) => c.trim());
14
+ const hasContext = filteredContext.length > 0;
15
+
16
+ return {
17
+ messages: [
18
+ {
19
+ content: hasContext
20
+ ? `You are a helpful assistant specialized in ${knowledge.join('/')}. Your task is to answer questions based on the provided context passages.
21
+
22
+ IMPORTANT RULES:
23
+ - First, check if the context is relevant to the question topic
24
+ - If the context is about a COMPLETELY DIFFERENT topic than the question:
25
+ * State what topic the context is about
26
+ * Clearly state "The provided context does not contain information about [question topic]"
27
+ * Do NOT answer using your general knowledge
28
+ - If the context is related to the question topic (even if information is limited):
29
+ * ALWAYS use the context information as a foundation
30
+ * You SHOULD supplement with your general knowledge to provide a complete, helpful answer
31
+ * For "how to" questions, MUST provide practical, actionable steps combining context + your expertise
32
+ * The context provides the topic relevance - you provide the comprehensive answer
33
+ * Example: If context mentions "Docker is for containerization", and question is "How to deploy with Docker?", you should explain deployment steps using your knowledge
34
+ - Answer in the same language as the question
35
+ - Use markdown formatting for better readability
36
+
37
+ The provided context passages:
15
38
 
16
- Note that passages might not be relevant to the question, please only use the passages that are relevant. Or if there is no relevant passage, please answer using your knowledge.
39
+ <context>
40
+ ${filteredContext.join('\n')}
41
+ </context>
17
42
 
18
- Answer should use the same original language as the question and follow markdown syntax.
43
+ Question to answer:
19
44
 
20
- The provided passages as context:
45
+ ${question}`
46
+ : `You are a helpful assistant specialized in ${knowledge.join('/')}. Please answer the following question using your knowledge.
21
47
 
22
- <Context>
23
- ${context.join('\n')}
24
- </Context>
48
+ Answer in the same language as the question and use markdown formatting for better readability.
25
49
 
26
- The question to answer is:
50
+ Question to answer:
27
51
 
28
- ${question}
29
- `,
30
- role: 'user',
31
- },
32
- ],
33
- });
52
+ ${question}`,
53
+ role: 'user',
54
+ },
55
+ ],
56
+ };
57
+ };
@@ -7,25 +7,39 @@ import { ChatStreamPayload } from '@lobechat/types';
7
7
  export const chainPickEmoji = (content: string): Partial<ChatStreamPayload> => ({
8
8
  messages: [
9
9
  {
10
- content:
11
- '你是一名擅长进行概念抽象的设计师与 Emoji 专家,你需要根据角色能力的描述抽象出一个表达物理实体的概念 Emoji 作为角色头像, 格式要求如下:\n输入: {文本作为JSON引用字符串}\n输出: {一个Emoji}',
10
+ content: `You are an emoji expert who selects the most appropriate emoji to represent concepts, emotions, or topics.
11
+
12
+ Rules:
13
+ - Output ONLY a single emoji (1-2 characters maximum)
14
+ - Focus on the CONTENT meaning, not the language it's written in
15
+ - Choose an emoji that best represents the core topic, activity, or subject matter
16
+ - Prioritize topic-specific emojis over generic emotion emojis (e.g., for sports, use 🏃 instead of 😅)
17
+ - For work/projects, use work-related emojis (💼, 🚀, 💪) not cultural symbols
18
+ - For pure emotions without specific topics, use face emojis (happy: 🎉, sad: 😢, thinking: 🤔)
19
+ - For activities or subjects, use object or symbol emojis that represent the main topic
20
+ - No explanations or additional text`,
12
21
  role: 'system',
13
22
  },
14
23
  {
15
- content: `输入: {你是一名文案大师,帮我为一些设计 / 艺术作品起名,名字需要有文学内涵,注重精炼和赋子意境,表达作品的情景氛国,使名称既简洁又富有诗意。}`,
24
+ content: 'I am a copywriting master who helps name design and art works with literary depth',
16
25
  role: 'user',
17
26
  },
18
27
  { content: '✒️', role: 'assistant' },
19
28
  {
20
- content: `输入: {你是一名代码巫师,请将下面的代码转成 ts,不要修改实现。如果原本 js 中没有定义的全局变量,需要补充 declare 的类型声明。}`,
29
+ content: 'I am a code wizard who converts JavaScript code to TypeScript',
21
30
  role: 'user',
22
31
  },
23
32
  { content: '🧙‍♂️', role: 'assistant' },
24
33
  {
25
- content: `输入: {你是一名创业计划撰写专家,可以提供包括创意名称、简短的标语、目标用户画像、用户痛点、主要价值主张、销售/营销渠道、收入流、成本结构等计划生成。}`,
34
+ content: 'I just got a promotion at work',
35
+ role: 'user',
36
+ },
37
+ { content: '🎉', role: 'assistant' },
38
+ {
39
+ content: 'I am a business plan expert who helps with startup strategies and marketing',
26
40
  role: 'user',
27
41
  },
28
42
  { content: '🚀', role: 'assistant' },
29
- { content: `输入: {${content}}`, role: 'user' },
43
+ { content, role: 'user' },
30
44
  ],
31
45
  });
@@ -3,19 +3,24 @@ import { ChatStreamPayload, OpenAIChatMessage } from '@/types/openai/chat';
3
3
  export const chainSummaryTitle = (
4
4
  messages: OpenAIChatMessage[],
5
5
  locale: string,
6
- ): Partial<ChatStreamPayload> => {
7
- return {
8
- messages: [
9
- {
10
- content: '你是一名擅长会话的助理,你需要将用户的会话总结为 10 个字以内的标题',
11
- role: 'system',
12
- },
13
- {
14
- content: `${messages.map((message) => `${message.role}: ${message.content}`).join('\n')}
6
+ ): Partial<ChatStreamPayload> => ({
7
+ messages: [
8
+ {
9
+ content: `You are a professional conversation summarizer. Generate a concise title that captures the essence of the conversation.
15
10
 
16
- 请总结上述对话为10个字以内的标题,不需要包含标点符号,输出语言语种为:${locale}`,
17
- role: 'user',
18
- },
19
- ],
20
- };
21
- };
11
+ Rules:
12
+ - Output ONLY the title text, no explanations or additional context
13
+ - Maximum 10 words
14
+ - Maximum 50 characters
15
+ - No punctuation marks
16
+ - Use the language specified by the locale code: ${locale}
17
+ - The title should accurately reflect the main topic of the conversation
18
+ - Keep it short and to the point`,
19
+ role: 'system',
20
+ },
21
+ {
22
+ content: messages.map((message) => `${message.role}: ${message.content}`).join('\n'),
23
+ role: 'user',
24
+ },
25
+ ],
26
+ });