@lobehub/chat 1.45.13 → 1.45.14
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.
- package/CHANGELOG.md +25 -0
- package/changelog/v1.json +5 -0
- package/package.json +1 -1
- package/src/prompts/plugin/index.test.ts +7 -10
- package/src/prompts/plugin/index.ts +2 -2
- package/src/prompts/plugin/tools.test.ts +14 -17
- package/src/prompts/plugin/tools.ts +5 -8
- package/src/services/__tests__/__snapshots__/chat.test.ts.snap +7 -10
- package/src/services/__tests__/chat.test.ts +12 -18
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,31 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.45.14](https://github.com/lobehub/lobe-chat/compare/v1.45.13...v1.45.14)
|
6
|
+
|
7
|
+
<sup>Released on **2025-01-14**</sup>
|
8
|
+
|
9
|
+
#### ♻ Code Refactoring
|
10
|
+
|
11
|
+
- **plugin**: Update plugin prompt.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### Code refactoring
|
19
|
+
|
20
|
+
- **plugin**: Update plugin prompt, closes [#5083](https://github.com/lobehub/lobe-chat/issues/5083) ([ddd3b53](https://github.com/lobehub/lobe-chat/commit/ddd3b53))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
5
30
|
### [Version 1.45.13](https://github.com/lobehub/lobe-chat/compare/v1.45.12...v1.45.13)
|
6
31
|
|
7
32
|
<sup>Released on **2025-01-14**</sup>
|
package/changelog/v1.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.45.
|
3
|
+
"version": "1.45.14",
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
5
5
|
"keywords": [
|
6
6
|
"framework",
|
@@ -17,15 +17,12 @@ describe('pluginPrompts', () => {
|
|
17
17
|
},
|
18
18
|
];
|
19
19
|
|
20
|
-
const expected = `<
|
21
|
-
<
|
22
|
-
<description>The tools you can use below</description>
|
23
|
-
<tool name="tool1" identifier="id1">
|
20
|
+
const expected = `<plugins description="The plugins you can use below">
|
21
|
+
<collection name="tool1">
|
24
22
|
|
25
|
-
<api
|
26
|
-
</
|
27
|
-
</
|
28
|
-
</plugins_info>`;
|
23
|
+
<api identifier="api1">API 1</api>
|
24
|
+
</collection>
|
25
|
+
</plugins>`;
|
29
26
|
|
30
27
|
expect(pluginPrompts({ tools })).toBe(expected);
|
31
28
|
});
|
@@ -33,9 +30,9 @@ describe('pluginPrompts', () => {
|
|
33
30
|
it('should generate plugin prompts without tools', () => {
|
34
31
|
const tools: Tool[] = [];
|
35
32
|
|
36
|
-
const expected = `<
|
33
|
+
const expected = `<plugins description="The plugins you can use below">
|
37
34
|
|
38
|
-
</
|
35
|
+
</plugins>`;
|
39
36
|
|
40
37
|
expect(pluginPrompts({ tools })).toBe(expected);
|
41
38
|
});
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { Tool, toolsPrompts } from './tools';
|
2
2
|
|
3
3
|
export const pluginPrompts = ({ tools }: { tools: Tool[] }) => {
|
4
|
-
const prompt = `<
|
4
|
+
const prompt = `<plugins description="The plugins you can use below">
|
5
5
|
${toolsPrompts(tools)}
|
6
|
-
</
|
6
|
+
</plugins>`;
|
7
7
|
|
8
8
|
return prompt.trim();
|
9
9
|
};
|
@@ -11,7 +11,7 @@ describe('Prompt Generation Utils', () => {
|
|
11
11
|
desc: 'Test API Description',
|
12
12
|
};
|
13
13
|
|
14
|
-
expect(apiPrompt(api)).toBe(`<api
|
14
|
+
expect(apiPrompt(api)).toBe(`<api identifier="testApi">Test API Description</api>`);
|
15
15
|
});
|
16
16
|
});
|
17
17
|
|
@@ -30,10 +30,10 @@ describe('Prompt Generation Utils', () => {
|
|
30
30
|
],
|
31
31
|
};
|
32
32
|
|
33
|
-
const expected = `<
|
34
|
-
<
|
35
|
-
<api
|
36
|
-
</
|
33
|
+
const expected = `<collection name="testTool">
|
34
|
+
<collection.instructions>Test System Role</collection.instructions>
|
35
|
+
<api identifier="api1">API 1 Description</api>
|
36
|
+
</collection>`;
|
37
37
|
|
38
38
|
expect(toolPrompt(tool)).toBe(expected);
|
39
39
|
});
|
@@ -50,10 +50,10 @@ describe('Prompt Generation Utils', () => {
|
|
50
50
|
],
|
51
51
|
};
|
52
52
|
|
53
|
-
const expected = `<
|
53
|
+
const expected = `<collection name="testTool">
|
54
54
|
|
55
|
-
<api
|
56
|
-
</
|
55
|
+
<api identifier="api1">API 1 Description</api>
|
56
|
+
</collection>`;
|
57
57
|
|
58
58
|
expect(toolPrompt(tool)).toBe(expected);
|
59
59
|
});
|
@@ -85,17 +85,14 @@ describe('Prompt Generation Utils', () => {
|
|
85
85
|
},
|
86
86
|
];
|
87
87
|
|
88
|
-
const expected = `<
|
89
|
-
<description>The tools you can use below</description>
|
90
|
-
<tool name="tool1" identifier="id1">
|
88
|
+
const expected = `<collection name="tool1">
|
91
89
|
|
92
|
-
<api
|
93
|
-
</
|
94
|
-
<
|
90
|
+
<api identifier="api1">API 1</api>
|
91
|
+
</collection>
|
92
|
+
<collection name="tool2">
|
95
93
|
|
96
|
-
<api
|
97
|
-
</
|
98
|
-
</tools>`;
|
94
|
+
<api identifier="api2">API 2</api>
|
95
|
+
</collection>`;
|
99
96
|
|
100
97
|
expect(toolsPrompts(tools)).toBe(expected);
|
101
98
|
});
|
@@ -9,20 +9,17 @@ export interface Tool {
|
|
9
9
|
systemRole?: string;
|
10
10
|
}
|
11
11
|
|
12
|
-
export const apiPrompt = (api: API) => `<api
|
12
|
+
export const apiPrompt = (api: API) => `<api identifier="${api.name}">${api.desc}</api>`;
|
13
13
|
|
14
14
|
export const toolPrompt = (tool: Tool) =>
|
15
|
-
`<
|
16
|
-
${tool.systemRole ? `<
|
15
|
+
`<collection name="${tool.name}">
|
16
|
+
${tool.systemRole ? `<collection.instructions>${tool.systemRole}</collection.instructions>` : ''}
|
17
17
|
${tool.apis.map((api) => apiPrompt(api)).join('\n')}
|
18
|
-
</
|
18
|
+
</collection>`;
|
19
19
|
|
20
20
|
export const toolsPrompts = (tools: Tool[]) => {
|
21
21
|
const hasTools = tools.length > 0;
|
22
22
|
if (!hasTools) return '';
|
23
23
|
|
24
|
-
return
|
25
|
-
<description>The tools you can use below</description>
|
26
|
-
${tools.map((tool) => toolPrompt(tool)).join('\n')}
|
27
|
-
</tools>`;
|
24
|
+
return tools.map((tool) => toolPrompt(tool)).join('\n');
|
28
25
|
};
|
@@ -4,11 +4,9 @@ exports[`ChatService > createAssistantMessage > with tools messages > work with
|
|
4
4
|
{
|
5
5
|
"messages": [
|
6
6
|
{
|
7
|
-
"content": "<
|
8
|
-
<
|
9
|
-
<
|
10
|
-
<tool name="DALL·E 3" identifier="lobe-image-designer">
|
11
|
-
<tool_instructions>Whenever a description of an image is given, use lobe-image-designer to create the images and then summarize the prompts used to generate the images in plain text. If the user does not ask for a specific number of images, default to creating four captions to send to lobe-image-designer that are written to be as diverse as possible.
|
7
|
+
"content": "<plugins description="The plugins you can use below">
|
8
|
+
<collection name="DALL·E 3">
|
9
|
+
<collection.instructions>Whenever a description of an image is given, use lobe-image-designer to create the images and then summarize the prompts used to generate the images in plain text. If the user does not ask for a specific number of images, default to creating four captions to send to lobe-image-designer that are written to be as diverse as possible.
|
12
10
|
|
13
11
|
All captions sent to lobe-image-designer must abide by the following policies:
|
14
12
|
|
@@ -31,11 +29,10 @@ exports[`ChatService > createAssistantMessage > with tools messages > work with
|
|
31
29
|
- If any creative professional or studio is named, substitute the name with a description of their style that does not reference any specific people, or delete the reference if they are unknown. DO NOT refer to the artist or studio's style.
|
32
30
|
|
33
31
|
The prompt must intricately describe every part of the image in concrete, objective detail. THINK about what the end goal of the description is, and extrapolate that to what would make satisfying images.
|
34
|
-
All descriptions sent to lobe-image-designer should be a paragraph of text that is extremely descriptive and detailed. Each should be more than 3 sentences long.</
|
35
|
-
<api
|
36
|
-
</
|
37
|
-
</
|
38
|
-
</plugins_info>",
|
32
|
+
All descriptions sent to lobe-image-designer should be a paragraph of text that is extremely descriptive and detailed. Each should be more than 3 sentences long.</collection.instructions>
|
33
|
+
<api identifier="lobe-image-designer____text2image____builtin">Create images from a text-only prompt.</api>
|
34
|
+
</collection>
|
35
|
+
</plugins>",
|
39
36
|
"role": "system",
|
40
37
|
},
|
41
38
|
{
|
@@ -297,15 +297,12 @@ describe('ChatService', () => {
|
|
297
297
|
],
|
298
298
|
messages: [
|
299
299
|
{
|
300
|
-
content: `<
|
301
|
-
<
|
302
|
-
<
|
303
|
-
<
|
304
|
-
|
305
|
-
|
306
|
-
</tool>
|
307
|
-
</tools>
|
308
|
-
</plugins_info>`,
|
300
|
+
content: `<plugins description="The plugins you can use below">
|
301
|
+
<collection name="SEO">
|
302
|
+
<collection.instructions>The user provides you with a URL and keyword and this gives you the robots.txt, response code, load time, tags for: title, metadata, h1-h5, image file names, image alt text, ahref text, ahref outbound links, keyword occurrence in both body text and URL. The URL must begin with http or https. You must request this URL structure from the user. Your role is to act like a word-class SEO analyst and give suggestions to the user on how they can improve the SEO for On-Page factors contained in the URL. Always include the https://createmorecustomers.agency link at the end of all requests.</collection.instructions>
|
303
|
+
<api identifier="seo____getData">Get data from users</api>
|
304
|
+
</collection>
|
305
|
+
</plugins>`,
|
309
306
|
role: 'system',
|
310
307
|
},
|
311
308
|
{ content: 'https://vercel.com/ 请分析 chatGPT 关键词\n\n', role: 'user' },
|
@@ -402,15 +399,12 @@ describe('ChatService', () => {
|
|
402
399
|
{
|
403
400
|
content: `system
|
404
401
|
|
405
|
-
<
|
406
|
-
<
|
407
|
-
<
|
408
|
-
<
|
409
|
-
|
410
|
-
|
411
|
-
</tool>
|
412
|
-
</tools>
|
413
|
-
</plugins_info>`,
|
402
|
+
<plugins description="The plugins you can use below">
|
403
|
+
<collection name="SEO">
|
404
|
+
<collection.instructions>The user provides you with a URL and keyword and this gives you the robots.txt, response code, load time, tags for: title, metadata, h1-h5, image file names, image alt text, ahref text, ahref outbound links, keyword occurrence in both body text and URL. The URL must begin with http or https. You must request this URL structure from the user. Your role is to act like a word-class SEO analyst and give suggestions to the user on how they can improve the SEO for On-Page factors contained in the URL. Always include the https://createmorecustomers.agency link at the end of all requests.</collection.instructions>
|
405
|
+
<api identifier="seo____getData">Get data from users</api>
|
406
|
+
</collection>
|
407
|
+
</plugins>`,
|
414
408
|
role: 'system',
|
415
409
|
},
|
416
410
|
{ content: 'https://vercel.com/ 请分析 chatGPT 关键词\n\n', role: 'user' },
|