@lobehub/chat 0.91.0 → 0.92.0
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/locales/en_US/chat.json +55 -0
- package/locales/en_US/common.json +17 -51
- package/locales/ja_JP/chat.json +55 -0
- package/locales/ja_JP/common.json +14 -48
- package/locales/ko_KR/chat.json +55 -0
- package/locales/ko_KR/common.json +25 -59
- package/locales/ru_RU/chat.json +55 -0
- package/locales/ru_RU/common.json +11 -45
- package/locales/zh_CN/chat.json +55 -0
- package/locales/zh_CN/common.json +11 -45
- package/locales/zh_TW/chat.json +55 -0
- package/locales/zh_TW/common.json +30 -64
- package/package.json +2 -1
- package/src/app/chat/(desktop)/features/ChatHeader.tsx +1 -1
- package/src/app/chat/(desktop)/features/SessionHeader.tsx +1 -1
- package/src/app/chat/(mobile)/features/ChatHeader.tsx +1 -1
- package/src/app/chat/(mobile)/features/TopicList.tsx +1 -1
- package/src/app/chat/features/ChatHeader/ShareButton/Inner.tsx +1 -1
- package/src/app/chat/features/ChatHeader/ShareButton/Preview.tsx +1 -1
- package/src/app/chat/features/ChatInputContent/ActionBar/ActionRight.tsx +3 -3
- package/src/app/chat/features/ChatInputContent/ActionBar/Token.tsx +1 -1
- package/src/app/chat/features/ChatInputContent/Footer/SaveTopic.tsx +1 -1
- package/src/app/chat/features/ChatInputContent/Footer/index.tsx +1 -1
- package/src/app/chat/features/ChatInputContent/index.tsx +1 -1
- package/src/app/chat/features/Conversation/ChatList/Actions/Assistant.tsx +22 -0
- package/src/app/chat/features/Conversation/ChatList/Actions/Error.tsx +15 -0
- package/src/app/chat/features/Conversation/ChatList/{Messages/System.tsx → Actions/Fallback.tsx} +1 -1
- package/src/app/chat/features/Conversation/ChatList/Actions/Function.tsx +14 -0
- package/src/app/chat/features/Conversation/ChatList/{Messages → Actions}/User.tsx +6 -1
- package/src/app/chat/features/Conversation/ChatList/Actions/customAction.ts +21 -0
- package/src/app/chat/features/Conversation/ChatList/Actions/index.ts +13 -0
- package/src/app/chat/features/Conversation/ChatList/Extras/Assistant.tsx +39 -0
- package/src/app/chat/features/Conversation/ChatList/Extras/Translate.tsx +75 -0
- package/src/app/chat/features/Conversation/ChatList/Extras/User.tsx +24 -0
- package/src/app/chat/features/Conversation/ChatList/Extras/index.ts +9 -0
- package/src/app/chat/features/Conversation/ChatList/Loading.tsx +53 -0
- package/src/app/chat/features/Conversation/ChatList/Messages/Assistant.tsx +5 -58
- package/src/app/chat/features/Conversation/ChatList/Messages/Default.tsx +7 -1
- package/src/app/chat/features/Conversation/ChatList/Messages/Function.tsx +4 -23
- package/src/app/chat/features/Conversation/ChatList/Messages/index.ts +4 -17
- package/src/app/chat/features/Conversation/ChatList/Plugins/FunctionCall.tsx +0 -2
- package/src/app/chat/features/Conversation/ChatList/Plugins/PluginMessage.tsx +3 -4
- package/src/app/chat/features/Conversation/ChatList/index.tsx +17 -2
- package/src/app/chat/features/Conversation/index.tsx +1 -1
- package/src/app/chat/features/SessionListContent/Inbox/index.tsx +1 -1
- package/src/app/chat/features/SessionListContent/List/AddButton.tsx +1 -1
- package/src/app/chat/features/SessionSearchBar/index.tsx +1 -1
- package/src/app/chat/features/TopicListContent/Topic/DefaultContent.tsx +1 -1
- package/src/app/chat/features/TopicListContent/Topic/TopicContent.tsx +1 -1
- package/src/app/chat/features/TopicListContent/Topic/index.tsx +1 -1
- package/src/app/chat/features/TopicListContent/TopicSearchBar/index.tsx +1 -1
- package/src/app/home/index.tsx +2 -2
- package/src/chains/chat.ts +77 -0
- package/src/features/AgentSetting/AgentPrompt/index.tsx +3 -3
- package/src/features/AgentSetting/store/action.ts +1 -1
- package/src/layout/ResponsiveLayout.client.tsx +4 -2
- package/src/locales/create.ts +2 -1
- package/src/locales/default/chat.ts +60 -0
- package/src/locales/default/common.ts +10 -45
- package/src/locales/options.ts +10 -0
- package/src/locales/resources/en_US.ts +2 -0
- package/src/locales/resources/index.ts +1 -1
- package/src/locales/resources/ja_JP.ts +2 -0
- package/src/locales/resources/ko_KR.ts +2 -0
- package/src/locales/resources/ru_RU.ts +2 -0
- package/src/locales/resources/zh_CN.ts +2 -0
- package/src/locales/resources/zh_TW.ts +2 -0
- package/src/store/global/selectors/settings.ts +4 -0
- package/src/store/session/slices/chat/actions/index.ts +7 -1
- package/src/store/session/slices/chat/actions/message.ts +2 -2
- package/src/store/session/slices/chat/actions/topic.ts +2 -2
- package/src/store/session/slices/chat/actions/translate.ts +87 -0
- package/src/store/session/slices/chat/selectors/chat.ts +23 -17
- package/src/store/session/slices/chat/selectors/index.ts +2 -2
- package/src/types/chatMessage.ts +5 -4
- package/src/types/translate.ts +4 -0
- package/src/prompts/chat.ts +0 -32
- /package/src/{prompts → chains}/agent.ts +0 -0
package/src/types/chatMessage.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PluginRequestPayload } from '@lobehub/chat-plugin-sdk';
|
|
2
2
|
|
|
3
3
|
import { ErrorType } from '@/types/fetch';
|
|
4
|
+
import { Translate } from '@/types/translate';
|
|
4
5
|
|
|
5
6
|
import { LLMRoleType } from './llm';
|
|
6
7
|
import { BaseDataModel } from './meta';
|
|
@@ -18,6 +19,9 @@ export interface OpenAIFunctionCall {
|
|
|
18
19
|
name: string;
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
export interface ChatTranslate extends Translate {
|
|
23
|
+
content?: string;
|
|
24
|
+
}
|
|
21
25
|
export interface ChatMessage extends BaseDataModel {
|
|
22
26
|
/**
|
|
23
27
|
* @title 内容
|
|
@@ -29,10 +33,7 @@ export interface ChatMessage extends BaseDataModel {
|
|
|
29
33
|
extra?: {
|
|
30
34
|
fromModel?: string;
|
|
31
35
|
// 翻译
|
|
32
|
-
translate?:
|
|
33
|
-
target: string;
|
|
34
|
-
to: string;
|
|
35
|
-
};
|
|
36
|
+
translate?: ChatTranslate;
|
|
36
37
|
} & Record<string, any>;
|
|
37
38
|
|
|
38
39
|
/**
|
package/src/prompts/chat.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { chatHelpers } from '@/store/session/helpers';
|
|
2
|
-
import { LanguageModel } from '@/types/llm';
|
|
3
|
-
import { OpenAIChatMessage, OpenAIChatStreamPayload } from '@/types/openai/chat';
|
|
4
|
-
|
|
5
|
-
export const promptSummaryTitle = async (
|
|
6
|
-
messages: OpenAIChatMessage[],
|
|
7
|
-
): Promise<Partial<OpenAIChatStreamPayload>> => {
|
|
8
|
-
const finalMessages: OpenAIChatMessage[] = [
|
|
9
|
-
{
|
|
10
|
-
content:
|
|
11
|
-
'你是一名擅长会话的助理,你需要将用户的会话总结为 10 个字以内的标题,不需要包含标点符号',
|
|
12
|
-
role: 'system',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
content: `${messages.map((message) => `${message.role}: ${message.content}`).join('\n')}
|
|
16
|
-
|
|
17
|
-
请总结上述对话为10个字以内的标题,不需要包含标点符号`,
|
|
18
|
-
role: 'user',
|
|
19
|
-
},
|
|
20
|
-
];
|
|
21
|
-
// 如果超过 4k,则使用 GPT3.5 16K 模型
|
|
22
|
-
const tokens = await chatHelpers.getMessagesTokenCount(finalMessages);
|
|
23
|
-
let model: LanguageModel | undefined = undefined;
|
|
24
|
-
if (tokens > 4000) {
|
|
25
|
-
model = LanguageModel.GPT3_5_16K;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
messages: finalMessages,
|
|
30
|
-
model,
|
|
31
|
-
};
|
|
32
|
-
};
|
|
File without changes
|