@lobehub/chat 0.26.0 → 0.26.1
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/package.json +1 -1
- package/src/const/message.ts +2 -0
- package/src/locales/default/common.ts +3 -0
- package/src/locales/default/plugin.ts +19 -1
- package/src/pages/api/openai.ts +7 -4
- package/src/pages/api/plugins.api.ts +16 -38
- package/src/pages/chat/[id]/Conversation/ChatList/MessageExtra.tsx +28 -26
- package/src/pages/chat/[id]/Conversation/ChatList/Plugins/FunctionCall.tsx +60 -0
- package/src/pages/chat/[id]/Conversation/ChatList/Plugins/PluginMessage.tsx +45 -0
- package/src/pages/chat/[id]/Conversation/ChatList/Plugins/PluginResultRender.tsx +51 -0
- package/src/pages/chat/[id]/Conversation/ChatList/Plugins/style.ts +25 -0
- package/src/pages/chat/[id]/Conversation/ChatList/index.tsx +34 -9
- package/src/pages/chat/[id]/edit/AgentPlugin/index.tsx +2 -2
- package/src/pages/setting/index.page.tsx +11 -28
- package/src/pages/setting/layout.tsx +35 -0
- package/src/plugins/Render.ts +8 -0
- package/src/plugins/index.ts +7 -3
- package/src/plugins/searchEngine/index.ts +4 -1
- package/src/plugins/searchEngine/runner.ts +5 -73
- package/src/plugins/searchEngine/type.ts +80 -0
- package/src/plugins/type.ts +17 -0
- package/src/plugins/weather/Render.tsx +53 -0
- package/src/plugins/weather/index.ts +9 -1
- package/src/plugins/weather/runner.ts +12 -7
- package/src/plugins/weather/type.ts +36 -0
- package/src/plugins/webCrawler/index.ts +4 -1
- package/src/plugins/webCrawler/runner.ts +3 -27
- package/src/plugins/webCrawler/type.ts +32 -0
- package/src/services/chatModel.ts +1 -2
- package/src/services/plugin.ts +30 -0
- package/src/store/session/slices/chat/actions/message.ts +59 -40
- package/src/store/session/slices/chat/selectors/utils.test.ts +3 -2
- package/src/store/session/slices/chat/selectors/utils.ts +4 -3
- package/src/types/chatMessage.ts +5 -1
- package/src/types/openai.ts +3 -0
- package/src/types/plugin.ts +4 -0
- package/src/utils/message.ts +16 -0
- package/src/pages/chat/[id]/Conversation/ChatList/FunctionMessage.tsx +0 -31
package/src/types/chatMessage.ts
CHANGED
|
@@ -11,6 +11,10 @@ export interface ChatMessageError {
|
|
|
11
11
|
message: string;
|
|
12
12
|
type: ErrorType;
|
|
13
13
|
}
|
|
14
|
+
export interface OpenAIFunctionCall {
|
|
15
|
+
arguments?: string;
|
|
16
|
+
name: string;
|
|
17
|
+
}
|
|
14
18
|
|
|
15
19
|
export interface ChatMessage extends BaseDataModel {
|
|
16
20
|
/**
|
|
@@ -29,7 +33,7 @@ export interface ChatMessage extends BaseDataModel {
|
|
|
29
33
|
};
|
|
30
34
|
} & Record<string, any>;
|
|
31
35
|
|
|
32
|
-
function_call?:
|
|
36
|
+
function_call?: OpenAIFunctionCall;
|
|
33
37
|
name?: string;
|
|
34
38
|
|
|
35
39
|
parentId?: string;
|
package/src/types/openai.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OpenAIFunctionCall } from '@/types/chatMessage';
|
|
1
2
|
import { LLMRoleType } from '@/types/llm';
|
|
2
3
|
|
|
3
4
|
export interface OpenAIChatMessage {
|
|
@@ -7,6 +8,8 @@ export interface OpenAIChatMessage {
|
|
|
7
8
|
*/
|
|
8
9
|
content: string;
|
|
9
10
|
|
|
11
|
+
function_call?: OpenAIFunctionCall;
|
|
12
|
+
name?: string;
|
|
10
13
|
/**
|
|
11
14
|
* 角色
|
|
12
15
|
* @description 消息发送者的角色
|
package/src/utils/message.ts
CHANGED
|
@@ -3,3 +3,19 @@ import { FUNCTION_MESSAGE_FLAG } from '@/const/message';
|
|
|
3
3
|
export const isFunctionMessage = (content: string) => {
|
|
4
4
|
return content.startsWith(FUNCTION_MESSAGE_FLAG);
|
|
5
5
|
};
|
|
6
|
+
|
|
7
|
+
// export const createFunctionCallMessage = () => {
|
|
8
|
+
// return [
|
|
9
|
+
// {
|
|
10
|
+
// content: '',
|
|
11
|
+
// function_call: { arguments: '{\n "city": "杭州"\n}', name: 'realtimeWeather' },
|
|
12
|
+
// role: 'assistant',
|
|
13
|
+
// },
|
|
14
|
+
// {
|
|
15
|
+
// content:
|
|
16
|
+
// '{"status":"1","count":"1","info":"OK","infocode":"10000","forecasts":[{"city":"杭州市","adcode":"300","province":"浙江","reporttime":"2023-07-28 20:32:48","casts":[{"date":"2023-07-28","week":"5","dayweather"小雨","nightweather":"小雨-中雨","daytemp":"32","nighttemp":"26","daywind":"东","nightwind":"东","daypower":"6power":"6","daytemp_float":"32.0","nighttemp_float":"26.0"},{"date":"2023-07-29","week":"6","dayweather":"小雨雨","nightweather":"小雨","daytemp":"30","nighttemp":"25","daywind":"东南","nightwind":"东南","daypower":"4","wer":"4","daytemp_float":"30.0","nighttemp_float":"25.0"},{"date":"2023-07-30","week":"7","dayweather":"小雨",ightweather":"雷阵雨","daytemp":"31","nighttemp":"25","daywind":"东南","nightwind":"东南","daypower":"4","nigh:"4","daytemp_float":"31.0","nighttemp_float":"25.0"},{"date":"2023-07-31","week":"1","dayweather":"雷阵雨","ntweather":"雷阵雨","daytemp":"33","nighttemp":"25","daywind":"东","nightwind":"东","daypower":"4","nightpower""daytemp_float":"33.0","nighttemp_float":"25.0"}]}]}',
|
|
17
|
+
// name: 'realtimeWeather',
|
|
18
|
+
// role: 'function',
|
|
19
|
+
// },
|
|
20
|
+
// ];
|
|
21
|
+
// };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { LoadingOutlined } from '@ant-design/icons';
|
|
2
|
-
import { createStyles } from 'antd-style';
|
|
3
|
-
import { memo } from 'react';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { Flexbox } from 'react-layout-kit';
|
|
6
|
-
|
|
7
|
-
const useStyles = createStyles(({ css, token }) => ({
|
|
8
|
-
container: css`
|
|
9
|
-
padding: 4px 8px;
|
|
10
|
-
|
|
11
|
-
color: ${token.colorTextSecondary};
|
|
12
|
-
|
|
13
|
-
background: ${token.colorFillTertiary};
|
|
14
|
-
border: 1px solid ${token.colorBorder};
|
|
15
|
-
border-radius: 6px;
|
|
16
|
-
`,
|
|
17
|
-
}));
|
|
18
|
-
const FunctionMessage = memo(() => {
|
|
19
|
-
const { t } = useTranslation('plugin');
|
|
20
|
-
const { styles } = useStyles();
|
|
21
|
-
return (
|
|
22
|
-
<Flexbox className={styles.container} gap={8} horizontal>
|
|
23
|
-
<div>
|
|
24
|
-
<LoadingOutlined />
|
|
25
|
-
</div>
|
|
26
|
-
{t('pluginLoading')}
|
|
27
|
-
</Flexbox>
|
|
28
|
-
);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export default FunctionMessage;
|