@lobehub/chat 1.62.11 → 1.63.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 +66 -0
- package/changelog/v1.json +24 -0
- package/locales/ar/chat.json +26 -0
- package/locales/ar/models.json +21 -0
- package/locales/bg-BG/chat.json +26 -0
- package/locales/bg-BG/models.json +21 -0
- package/locales/de-DE/chat.json +26 -0
- package/locales/de-DE/models.json +21 -0
- package/locales/en-US/chat.json +26 -0
- package/locales/en-US/models.json +21 -0
- package/locales/es-ES/chat.json +26 -0
- package/locales/es-ES/models.json +21 -0
- package/locales/fa-IR/chat.json +26 -0
- package/locales/fa-IR/models.json +21 -0
- package/locales/fr-FR/chat.json +26 -0
- package/locales/fr-FR/models.json +21 -0
- package/locales/it-IT/chat.json +26 -0
- package/locales/it-IT/models.json +21 -0
- package/locales/ja-JP/chat.json +26 -0
- package/locales/ja-JP/models.json +21 -0
- package/locales/ko-KR/chat.json +26 -0
- package/locales/ko-KR/models.json +21 -0
- package/locales/nl-NL/chat.json +26 -0
- package/locales/nl-NL/models.json +21 -0
- package/locales/pl-PL/chat.json +26 -0
- package/locales/pl-PL/models.json +21 -0
- package/locales/pt-BR/chat.json +26 -0
- package/locales/pt-BR/models.json +21 -0
- package/locales/ru-RU/chat.json +26 -0
- package/locales/ru-RU/models.json +21 -0
- package/locales/tr-TR/chat.json +26 -0
- package/locales/tr-TR/models.json +21 -0
- package/locales/vi-VN/chat.json +26 -0
- package/locales/vi-VN/models.json +21 -0
- package/locales/zh-CN/chat.json +27 -1
- package/locales/zh-CN/models.json +25 -4
- package/locales/zh-TW/chat.json +26 -0
- package/locales/zh-TW/models.json +21 -0
- package/package.json +2 -2
- package/src/app/(backend)/webapi/chat/groq/route.test.ts +29 -0
- package/src/app/(backend)/webapi/chat/groq/route.ts +21 -0
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/index.tsx +1 -0
- package/src/config/aiModels/google.ts +8 -0
- package/src/config/aiModels/groq.ts +111 -95
- package/src/config/aiModels/hunyuan.ts +36 -4
- package/src/config/aiModels/internlm.ts +4 -5
- package/src/config/aiModels/jina.ts +3 -0
- package/src/config/aiModels/mistral.ts +35 -21
- package/src/config/aiModels/novita.ts +293 -32
- package/src/config/aiModels/perplexity.ts +14 -2
- package/src/config/aiModels/qwen.ts +91 -37
- package/src/config/aiModels/sensenova.ts +70 -17
- package/src/config/aiModels/siliconcloud.ts +5 -3
- package/src/config/aiModels/stepfun.ts +19 -0
- package/src/config/aiModels/taichu.ts +4 -2
- package/src/config/aiModels/upstage.ts +24 -11
- package/src/config/modelProviders/openrouter.ts +1 -0
- package/src/config/modelProviders/qwen.ts +2 -1
- package/src/const/settings/agent.ts +1 -0
- package/src/database/repositories/aiInfra/index.test.ts +2 -5
- package/src/database/repositories/aiInfra/index.ts +6 -2
- package/src/database/schemas/message.ts +2 -1
- package/src/database/server/models/aiModel.ts +1 -1
- package/src/database/server/models/aiProvider.ts +6 -1
- package/src/features/ChatInput/ActionBar/Model/ControlsForm.tsx +38 -0
- package/src/features/ChatInput/ActionBar/Model/ExtendControls.tsx +40 -0
- package/src/features/ChatInput/ActionBar/Model/index.tsx +132 -0
- package/src/features/ChatInput/ActionBar/Params/index.tsx +2 -2
- package/src/features/ChatInput/ActionBar/Search/ExaIcon.tsx +15 -0
- package/src/features/ChatInput/ActionBar/Search/ModelBuiltinSearch.tsx +68 -0
- package/src/features/ChatInput/ActionBar/Search/SwitchPanel.tsx +167 -0
- package/src/features/ChatInput/ActionBar/Search/index.tsx +74 -0
- package/src/features/ChatInput/ActionBar/config.ts +4 -2
- package/src/features/Conversation/Error/index.tsx +1 -6
- package/src/features/Conversation/Messages/Assistant/SearchGrounding.tsx +153 -0
- package/src/features/Conversation/Messages/Assistant/Tool/Inspector/Debug.tsx +9 -6
- package/src/features/Conversation/Messages/Assistant/Tool/Inspector/PluginResultJSON.tsx +14 -9
- package/src/features/Conversation/Messages/Assistant/Tool/Inspector/Settings.tsx +1 -0
- package/src/features/Conversation/Messages/Assistant/Tool/Inspector/index.tsx +2 -1
- package/src/features/Conversation/Messages/Assistant/Tool/Render/CustomRender.tsx +4 -2
- package/src/features/Conversation/Messages/Assistant/Tool/Render/ErrorResponse.tsx +36 -0
- package/src/features/Conversation/{Error → Messages/Assistant/Tool/Render}/PluginSettings.tsx +1 -1
- package/src/features/Conversation/Messages/Assistant/Tool/Render/index.tsx +7 -1
- package/src/features/Conversation/Messages/Assistant/index.tsx +7 -1
- package/src/features/ModelSelect/index.tsx +1 -1
- package/src/features/ModelSwitchPanel/index.tsx +2 -3
- package/src/hooks/useEnabledChatModels.ts +1 -1
- package/src/libs/agent-runtime/google/index.test.ts +142 -36
- package/src/libs/agent-runtime/google/index.ts +26 -51
- package/src/libs/agent-runtime/novita/__snapshots__/index.test.ts.snap +3 -3
- package/src/libs/agent-runtime/openrouter/__snapshots__/index.test.ts.snap +3 -3
- package/src/libs/agent-runtime/openrouter/index.ts +20 -20
- package/src/libs/agent-runtime/perplexity/index.test.ts +2 -2
- package/src/libs/agent-runtime/qwen/index.ts +38 -55
- package/src/libs/agent-runtime/types/chat.ts +6 -2
- package/src/libs/agent-runtime/utils/streams/google-ai.ts +29 -4
- package/src/libs/agent-runtime/utils/streams/openai.ts +1 -1
- package/src/libs/agent-runtime/utils/streams/protocol.ts +1 -1
- package/src/locales/default/chat.ts +28 -0
- package/src/services/chat.ts +10 -0
- package/src/services/session/_deprecated.ts +2 -1
- package/src/store/agent/slices/chat/__snapshots__/selectors.test.ts.snap +1 -0
- package/src/store/agent/slices/chat/selectors.ts +6 -0
- package/src/store/aiInfra/slices/aiModel/selectors.ts +36 -0
- package/src/store/aiInfra/slices/aiProvider/initialState.ts +2 -2
- package/src/store/aiInfra/slices/aiProvider/selectors.ts +14 -0
- package/src/store/chat/slices/aiChat/actions/generateAIChat.ts +15 -5
- package/src/store/chat/slices/message/action.ts +1 -1
- package/src/store/user/slices/modelList/selectors/modelProvider.ts +1 -1
- package/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap +1 -0
- package/src/types/agent/index.ts +4 -0
- package/src/types/aiModel.ts +35 -8
- package/src/types/aiProvider.ts +7 -10
- package/src/types/message/base.ts +2 -5
- package/src/types/message/chat.ts +5 -3
- package/src/types/openai/chat.ts +5 -0
- package/src/types/search.ts +29 -0
- package/src/utils/fetch/fetchSSE.ts +11 -11
- package/src/features/ChatInput/ActionBar/ModelSwitch.tsx +0 -20
@@ -2,8 +2,9 @@ import STT from '../STT';
|
|
2
2
|
import Clear from './Clear';
|
3
3
|
import History from './History';
|
4
4
|
import Knowledge from './Knowledge';
|
5
|
-
import
|
5
|
+
import Model from './Model';
|
6
6
|
import Params from './Params';
|
7
|
+
import Search from './Search';
|
7
8
|
import { MainToken, PortalToken } from './Token';
|
8
9
|
import Tools from './Tools';
|
9
10
|
import Upload from './Upload';
|
@@ -14,9 +15,10 @@ export const actionMap = {
|
|
14
15
|
history: History,
|
15
16
|
knowledgeBase: Knowledge,
|
16
17
|
mainToken: MainToken,
|
17
|
-
model:
|
18
|
+
model: Model,
|
18
19
|
params: Params,
|
19
20
|
portalToken: PortalToken,
|
21
|
+
search: Search,
|
20
22
|
stt: STT,
|
21
23
|
temperature: Params,
|
22
24
|
tools: Tools,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { IPluginErrorType
|
1
|
+
import { IPluginErrorType } from '@lobehub/chat-plugin-sdk';
|
2
2
|
import type { AlertProps } from '@lobehub/ui';
|
3
3
|
import { Skeleton } from 'antd';
|
4
4
|
import dynamic from 'next/dynamic';
|
@@ -19,7 +19,6 @@ import { ErrorActionContainer } from './style';
|
|
19
19
|
const loading = () => <Skeleton active />;
|
20
20
|
|
21
21
|
const OllamaBizError = dynamic(() => import('./OllamaBizError'), { loading, ssr: false });
|
22
|
-
const PluginSettings = dynamic(() => import('./PluginSettings'), { loading, ssr: false });
|
23
22
|
|
24
23
|
// Config for the errorMessage display
|
25
24
|
const getErrorAlertConfig = (
|
@@ -86,10 +85,6 @@ const ErrorMessageExtra = memo<{ data: ChatMessage }>(({ data }) => {
|
|
86
85
|
if (!error?.type) return;
|
87
86
|
|
88
87
|
switch (error.type) {
|
89
|
-
case PluginErrorType.PluginSettingsInvalid: {
|
90
|
-
return <PluginSettings id={data.id} plugin={data.plugin} />;
|
91
|
-
}
|
92
|
-
|
93
88
|
case AgentRuntimeErrorType.OllamaBizError: {
|
94
89
|
return <OllamaBizError {...data} />;
|
95
90
|
}
|
@@ -0,0 +1,153 @@
|
|
1
|
+
import { Icon, SearchResultCards, Tag } from '@lobehub/ui';
|
2
|
+
import { createStyles } from 'antd-style';
|
3
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
4
|
+
import { ChevronDown, ChevronRight, Globe } from 'lucide-react';
|
5
|
+
import Image from 'next/image';
|
6
|
+
import { rgba } from 'polished';
|
7
|
+
import { memo, useState } from 'react';
|
8
|
+
import { useTranslation } from 'react-i18next';
|
9
|
+
import { Flexbox } from 'react-layout-kit';
|
10
|
+
|
11
|
+
import { GroundingSearch } from '@/types/search';
|
12
|
+
|
13
|
+
const useStyles = createStyles(({ css, token, isDarkMode }) => ({
|
14
|
+
container: css`
|
15
|
+
width: fit-content;
|
16
|
+
padding-block: 4px;
|
17
|
+
padding-inline: 8px;
|
18
|
+
border-radius: 6px;
|
19
|
+
|
20
|
+
color: ${token.colorTextTertiary};
|
21
|
+
|
22
|
+
&:hover {
|
23
|
+
background: ${isDarkMode ? token.colorFillQuaternary : token.colorFillTertiary};
|
24
|
+
}
|
25
|
+
`,
|
26
|
+
expand: css`
|
27
|
+
background: ${isDarkMode ? token.colorFillQuaternary : token.colorFillTertiary} !important;
|
28
|
+
`,
|
29
|
+
shinyText: css`
|
30
|
+
color: ${rgba(token.colorText, 0.45)};
|
31
|
+
|
32
|
+
background: linear-gradient(
|
33
|
+
120deg,
|
34
|
+
${rgba(token.colorTextBase, 0)} 40%,
|
35
|
+
${token.colorTextSecondary} 50%,
|
36
|
+
${rgba(token.colorTextBase, 0)} 60%
|
37
|
+
);
|
38
|
+
background-clip: text;
|
39
|
+
background-size: 200% 100%;
|
40
|
+
|
41
|
+
animation: shine 1.5s linear infinite;
|
42
|
+
|
43
|
+
@keyframes shine {
|
44
|
+
0% {
|
45
|
+
background-position: 100%;
|
46
|
+
}
|
47
|
+
|
48
|
+
100% {
|
49
|
+
background-position: -100%;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
`,
|
53
|
+
title: css`
|
54
|
+
overflow: hidden;
|
55
|
+
display: -webkit-box;
|
56
|
+
-webkit-box-orient: vertical;
|
57
|
+
-webkit-line-clamp: 1;
|
58
|
+
|
59
|
+
font-size: 12px;
|
60
|
+
text-overflow: ellipsis;
|
61
|
+
`,
|
62
|
+
}));
|
63
|
+
|
64
|
+
const SearchGrounding = memo<GroundingSearch>(({ searchQueries, citations }) => {
|
65
|
+
const { t } = useTranslation('chat');
|
66
|
+
const { styles, cx, theme } = useStyles();
|
67
|
+
|
68
|
+
const [showDetail, setShowDetail] = useState(false);
|
69
|
+
|
70
|
+
return (
|
71
|
+
<Flexbox
|
72
|
+
className={cx(styles.container, showDetail && styles.expand)}
|
73
|
+
gap={16}
|
74
|
+
style={{ width: showDetail ? '100%' : undefined }}
|
75
|
+
>
|
76
|
+
<Flexbox
|
77
|
+
distribution={'space-between'}
|
78
|
+
flex={1}
|
79
|
+
gap={8}
|
80
|
+
horizontal
|
81
|
+
onClick={() => {
|
82
|
+
setShowDetail(!showDetail);
|
83
|
+
}}
|
84
|
+
style={{ cursor: 'pointer' }}
|
85
|
+
>
|
86
|
+
<Flexbox align={'center'} gap={8} horizontal>
|
87
|
+
<Icon icon={Globe} />
|
88
|
+
<Flexbox horizontal>{t('search.grounding.title', { count: citations?.length })}</Flexbox>
|
89
|
+
{!showDetail && (
|
90
|
+
<Flexbox horizontal>
|
91
|
+
{citations?.slice(0, 8).map((item, index) => (
|
92
|
+
<Image
|
93
|
+
alt={item.title || item.url}
|
94
|
+
height={16}
|
95
|
+
key={`${item.url}-${index}`}
|
96
|
+
src={`https://icons.duckduckgo.com/ip3/${new URL(item.url).host}.ico`}
|
97
|
+
style={{
|
98
|
+
background: theme.colorBgContainer,
|
99
|
+
borderRadius: 8,
|
100
|
+
marginInline: -2,
|
101
|
+
padding: 2,
|
102
|
+
zIndex: 100 - index,
|
103
|
+
}}
|
104
|
+
unoptimized
|
105
|
+
width={16}
|
106
|
+
/>
|
107
|
+
))}
|
108
|
+
</Flexbox>
|
109
|
+
)}
|
110
|
+
</Flexbox>
|
111
|
+
|
112
|
+
<Flexbox gap={4} horizontal>
|
113
|
+
<Icon icon={showDetail ? ChevronDown : ChevronRight} />
|
114
|
+
</Flexbox>
|
115
|
+
</Flexbox>
|
116
|
+
|
117
|
+
<AnimatePresence initial={false}>
|
118
|
+
{showDetail && (
|
119
|
+
<motion.div
|
120
|
+
animate="open"
|
121
|
+
exit="collapsed"
|
122
|
+
initial="collapsed"
|
123
|
+
style={{ overflow: 'hidden', width: '100%' }}
|
124
|
+
transition={{
|
125
|
+
duration: 0.2,
|
126
|
+
ease: [0.4, 0, 0.2, 1], // 使用 ease-out 缓动函数
|
127
|
+
}}
|
128
|
+
variants={{
|
129
|
+
collapsed: { height: 0, opacity: 0, width: 'auto' },
|
130
|
+
open: { height: 'auto', opacity: 1, width: 'auto' },
|
131
|
+
}}
|
132
|
+
>
|
133
|
+
<Flexbox gap={12}>
|
134
|
+
{searchQueries && (
|
135
|
+
<Flexbox gap={4} horizontal>
|
136
|
+
{t('search.grounding.searchQueries')}
|
137
|
+
<Flexbox gap={8} horizontal>
|
138
|
+
{searchQueries.map((query, index) => (
|
139
|
+
<Tag key={index}>{query}</Tag>
|
140
|
+
))}
|
141
|
+
</Flexbox>
|
142
|
+
</Flexbox>
|
143
|
+
)}
|
144
|
+
{citations && <SearchResultCards dataSource={citations} />}
|
145
|
+
</Flexbox>
|
146
|
+
</motion.div>
|
147
|
+
)}
|
148
|
+
</AnimatePresence>
|
149
|
+
</Flexbox>
|
150
|
+
);
|
151
|
+
});
|
152
|
+
|
153
|
+
export default SearchGrounding;
|
@@ -3,12 +3,15 @@ import { Tabs } from 'antd';
|
|
3
3
|
import { memo } from 'react';
|
4
4
|
import { useTranslation } from 'react-i18next';
|
5
5
|
|
6
|
+
import PluginResult from './PluginResultJSON';
|
7
|
+
|
6
8
|
interface DebugProps {
|
7
9
|
payload: object;
|
8
10
|
requestArgs?: string;
|
11
|
+
toolCallId: string;
|
9
12
|
}
|
10
13
|
|
11
|
-
const Debug = memo<DebugProps>(({ payload, requestArgs }) => {
|
14
|
+
const Debug = memo<DebugProps>(({ payload, requestArgs, toolCallId }) => {
|
12
15
|
const { t } = useTranslation('plugin');
|
13
16
|
let params;
|
14
17
|
try {
|
@@ -30,11 +33,11 @@ const Debug = memo<DebugProps>(({ payload, requestArgs }) => {
|
|
30
33
|
key: 'function_call',
|
31
34
|
label: t('debug.function_call'),
|
32
35
|
},
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
{
|
37
|
+
children: <PluginResult toolCallId={toolCallId} />,
|
38
|
+
key: 'response',
|
39
|
+
label: t('debug.response'),
|
40
|
+
},
|
38
41
|
]}
|
39
42
|
style={{ display: 'grid', maxWidth: 800, minWidth: 400 }}
|
40
43
|
/>
|
@@ -1,18 +1,23 @@
|
|
1
1
|
import { Highlighter } from '@lobehub/ui';
|
2
|
-
import { memo } from 'react';
|
2
|
+
import { memo, useMemo } from 'react';
|
3
|
+
|
4
|
+
import { useChatStore } from '@/store/chat';
|
5
|
+
import { chatSelectors } from '@/store/chat/selectors';
|
3
6
|
|
4
7
|
export interface FunctionMessageProps {
|
5
|
-
|
8
|
+
toolCallId: string;
|
6
9
|
}
|
7
10
|
|
8
|
-
const PluginResult = memo<FunctionMessageProps>(({
|
9
|
-
|
11
|
+
const PluginResult = memo<FunctionMessageProps>(({ toolCallId }) => {
|
12
|
+
const toolMessage = useChatStore(chatSelectors.getMessageByToolCallId(toolCallId));
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
const data = useMemo(() => {
|
15
|
+
try {
|
16
|
+
return JSON.stringify(JSON.parse(toolMessage?.content || ''), null, 2);
|
17
|
+
} catch {
|
18
|
+
return toolMessage?.content || '';
|
19
|
+
}
|
20
|
+
}, [toolMessage?.content]);
|
16
21
|
|
17
22
|
return (
|
18
23
|
<Highlighter language={'json'} style={{ maxHeight: 200, maxWidth: 800, overflow: 'scroll' }}>
|
@@ -79,6 +79,7 @@ const Inspectors = memo<InspectorProps>(
|
|
79
79
|
index,
|
80
80
|
identifier,
|
81
81
|
apiName,
|
82
|
+
id,
|
82
83
|
arguments: requestArgs,
|
83
84
|
showRender,
|
84
85
|
payload,
|
@@ -142,7 +143,7 @@ const Inspectors = memo<InspectorProps>(
|
|
142
143
|
<Settings id={identifier} />
|
143
144
|
</Flexbox>
|
144
145
|
</Flexbox>
|
145
|
-
{showDebug && <Debug payload={payload} requestArgs={requestArgs} />}
|
146
|
+
{showDebug && <Debug payload={payload} requestArgs={requestArgs} toolCallId={id} />}
|
146
147
|
</Flexbox>
|
147
148
|
);
|
148
149
|
},
|
@@ -29,10 +29,10 @@ const CustomRender = memo<
|
|
29
29
|
|
30
30
|
const theme = useTheme();
|
31
31
|
useEffect(() => {
|
32
|
-
if (!plugin?.type) return;
|
32
|
+
if (!plugin?.type || loading) return;
|
33
33
|
|
34
34
|
setShowPluginRender(plugin?.type !== 'default');
|
35
|
-
}, [plugin?.type]);
|
35
|
+
}, [plugin?.type, loading]);
|
36
36
|
|
37
37
|
if (isMessageToolUIOpen)
|
38
38
|
return (
|
@@ -53,6 +53,8 @@ const CustomRender = memo<
|
|
53
53
|
</Center>
|
54
54
|
);
|
55
55
|
|
56
|
+
if (loading) return <Arguments arguments={requestArgs} shine />;
|
57
|
+
|
56
58
|
return (
|
57
59
|
<Flexbox gap={12} id={id} width={'100%'}>
|
58
60
|
{showPluginRender ? (
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { Alert, Highlighter } from '@lobehub/ui';
|
2
|
+
import { memo } from 'react';
|
3
|
+
import { useTranslation } from 'react-i18next';
|
4
|
+
import { Flexbox } from 'react-layout-kit';
|
5
|
+
|
6
|
+
import { ChatMessageError, ChatPluginPayload } from '@/types/message';
|
7
|
+
|
8
|
+
import PluginSettings from './PluginSettings';
|
9
|
+
|
10
|
+
interface ErrorResponseProps extends ChatMessageError {
|
11
|
+
id: string;
|
12
|
+
plugin?: ChatPluginPayload;
|
13
|
+
}
|
14
|
+
|
15
|
+
const ErrorResponse = memo<ErrorResponseProps>(({ id, type, body, message, plugin }) => {
|
16
|
+
const { t } = useTranslation('error');
|
17
|
+
if (type === 'PluginSettingsInvalid') {
|
18
|
+
return <PluginSettings id={id} plugin={plugin} />;
|
19
|
+
}
|
20
|
+
|
21
|
+
return (
|
22
|
+
<Alert
|
23
|
+
extra={
|
24
|
+
<Flexbox>
|
25
|
+
<Highlighter copyButtonSize={'small'} language={'json'} type={'pure'}>
|
26
|
+
{JSON.stringify(body || { message, type }, null, 2)}
|
27
|
+
</Highlighter>
|
28
|
+
</Flexbox>
|
29
|
+
}
|
30
|
+
message={t(`response.${type}` as any)}
|
31
|
+
showIcon
|
32
|
+
type={'error'}
|
33
|
+
/>
|
34
|
+
);
|
35
|
+
});
|
36
|
+
export default ErrorResponse;
|
package/src/features/Conversation/{Error → Messages/Assistant/Tool/Render}/PluginSettings.tsx
RENAMED
@@ -12,7 +12,7 @@ import { pluginHelpers, useToolStore } from '@/store/tool';
|
|
12
12
|
import { pluginSelectors } from '@/store/tool/selectors';
|
13
13
|
import { ChatPluginPayload } from '@/types/message';
|
14
14
|
|
15
|
-
import { ErrorActionContainer, useStyles } from '
|
15
|
+
import { ErrorActionContainer, useStyles } from '../../../../Error/style';
|
16
16
|
|
17
17
|
interface PluginSettingsProps {
|
18
18
|
id: string;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Suspense, memo } from 'react';
|
2
2
|
|
3
|
+
import ErrorResponse from '@/features/Conversation/Messages/Assistant/Tool/Render/ErrorResponse';
|
3
4
|
import { useChatStore } from '@/store/chat';
|
4
5
|
import { chatSelectors } from '@/store/chat/selectors';
|
5
6
|
|
@@ -22,7 +23,11 @@ const Render = memo<RenderProps>(
|
|
22
23
|
// 如果处于 loading 或者找不到 toolMessage 则展示 Arguments
|
23
24
|
if (loading || !toolMessage) return <Arguments arguments={requestArgs} />;
|
24
25
|
|
25
|
-
if (!!toolMessage)
|
26
|
+
if (!!toolMessage) {
|
27
|
+
if (toolMessage.error) {
|
28
|
+
return <ErrorResponse {...toolMessage.error} id={messageId} plugin={toolMessage.plugin} />;
|
29
|
+
}
|
30
|
+
|
26
31
|
return (
|
27
32
|
<Suspense fallback={<Arguments arguments={requestArgs} shine />}>
|
28
33
|
<CustomRender
|
@@ -33,6 +38,7 @@ const Render = memo<RenderProps>(
|
|
33
38
|
/>
|
34
39
|
</Suspense>
|
35
40
|
);
|
41
|
+
}
|
36
42
|
},
|
37
43
|
);
|
38
44
|
|
@@ -9,13 +9,14 @@ import { ChatMessage } from '@/types/message';
|
|
9
9
|
import { DefaultMessage } from '../Default';
|
10
10
|
import FileChunks from './FileChunks';
|
11
11
|
import Reasoning from './Reasoning';
|
12
|
+
import SearchGrounding from './SearchGrounding';
|
12
13
|
import Tool from './Tool';
|
13
14
|
|
14
15
|
export const AssistantMessage = memo<
|
15
16
|
ChatMessage & {
|
16
17
|
editableContent: ReactNode;
|
17
18
|
}
|
18
|
-
>(({ id, tools, content, chunksList, ...props }) => {
|
19
|
+
>(({ id, tools, content, chunksList, search, ...props }) => {
|
19
20
|
const editing = useChatStore(chatSelectors.isMessageEditing(id));
|
20
21
|
const generating = useChatStore(chatSelectors.isMessageGenerating(id));
|
21
22
|
|
@@ -23,6 +24,8 @@ export const AssistantMessage = memo<
|
|
23
24
|
|
24
25
|
const isReasoning = useChatStore(aiChatSelectors.isMessageInReasoning(id));
|
25
26
|
|
27
|
+
const showSearch = !!search && !!search.citations?.length;
|
28
|
+
|
26
29
|
// remove \n to avoid empty content
|
27
30
|
// refs: https://github.com/lobehub/lobe-chat/pull/6153
|
28
31
|
const showReasoning =
|
@@ -38,6 +41,9 @@ export const AssistantMessage = memo<
|
|
38
41
|
/>
|
39
42
|
) : (
|
40
43
|
<Flexbox gap={8} id={id}>
|
44
|
+
{showSearch && (
|
45
|
+
<SearchGrounding citations={search?.citations} searchQueries={search?.searchQueries} />
|
46
|
+
)}
|
41
47
|
{!!chunksList && chunksList.length > 0 && <FileChunks data={chunksList} />}
|
42
48
|
{showReasoning && <Reasoning {...props.reasoning} id={id} />}
|
43
49
|
{content && (
|
@@ -4,7 +4,7 @@ import { memo, useMemo } from 'react';
|
|
4
4
|
|
5
5
|
import { ModelItemRender, ProviderItemRender } from '@/components/ModelSelect';
|
6
6
|
import { useEnabledChatModels } from '@/hooks/useEnabledChatModels';
|
7
|
-
import { EnabledProviderWithModels } from '@/types/
|
7
|
+
import { EnabledProviderWithModels } from '@/types/aiProvider';
|
8
8
|
|
9
9
|
const useStyles = createStyles(({ css, prefixCls }) => ({
|
10
10
|
select: css`
|
@@ -14,7 +14,7 @@ import { useEnabledChatModels } from '@/hooks/useEnabledChatModels';
|
|
14
14
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
15
15
|
import { useAgentStore } from '@/store/agent';
|
16
16
|
import { agentSelectors } from '@/store/agent/slices/chat';
|
17
|
-
import { EnabledProviderWithModels } from '@/types/
|
17
|
+
import { EnabledProviderWithModels } from '@/types/aiProvider';
|
18
18
|
|
19
19
|
const useStyles = createStyles(({ css, prefixCls }) => ({
|
20
20
|
menu: css`
|
@@ -68,7 +68,7 @@ const ModelSwitchPanel = memo<PropsWithChildren>(({ children }) => {
|
|
68
68
|
if (items.length === 0)
|
69
69
|
return [
|
70
70
|
{
|
71
|
-
key:
|
71
|
+
key: `${provider.id}-empty`,
|
72
72
|
label: (
|
73
73
|
<Flexbox gap={8} horizontal style={{ color: theme.colorTextTertiary }}>
|
74
74
|
{t('ModelSwitchPanel.emptyModel')}
|
@@ -114,7 +114,6 @@ const ModelSwitchPanel = memo<PropsWithChildren>(({ children }) => {
|
|
114
114
|
},
|
115
115
|
}}
|
116
116
|
placement={isMobile ? 'top' : 'topLeft'}
|
117
|
-
trigger={['click']}
|
118
117
|
>
|
119
118
|
<div className={styles.tag}>{children}</div>
|
120
119
|
</Dropdown>
|
@@ -4,7 +4,7 @@ import { isDeprecatedEdition } from '@/const/version';
|
|
4
4
|
import { useAiInfraStore } from '@/store/aiInfra';
|
5
5
|
import { useUserStore } from '@/store/user';
|
6
6
|
import { modelProviderSelectors } from '@/store/user/selectors';
|
7
|
-
import { EnabledProviderWithModels } from '@/types/
|
7
|
+
import { EnabledProviderWithModels } from '@/types/aiProvider';
|
8
8
|
|
9
9
|
export const useEnabledChatModels = (): EnabledProviderWithModels[] => {
|
10
10
|
const enabledList = useUserStore(modelProviderSelectors.modelProviderListForModelSelect, isEqual);
|