@lobehub/chat 1.68.11 → 1.69.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/changelog/v1.json +9 -0
  3. package/locales/ar/chat.json +8 -0
  4. package/locales/bg-BG/chat.json +8 -0
  5. package/locales/de-DE/chat.json +8 -0
  6. package/locales/en-US/chat.json +8 -0
  7. package/locales/es-ES/chat.json +8 -0
  8. package/locales/fa-IR/chat.json +8 -0
  9. package/locales/fr-FR/chat.json +8 -0
  10. package/locales/it-IT/chat.json +8 -0
  11. package/locales/ja-JP/chat.json +8 -0
  12. package/locales/ko-KR/chat.json +8 -0
  13. package/locales/nl-NL/chat.json +8 -0
  14. package/locales/pl-PL/chat.json +8 -0
  15. package/locales/pt-BR/chat.json +8 -0
  16. package/locales/ru-RU/chat.json +8 -0
  17. package/locales/tr-TR/chat.json +8 -0
  18. package/locales/vi-VN/chat.json +8 -0
  19. package/locales/zh-CN/chat.json +8 -0
  20. package/locales/zh-TW/chat.json +8 -0
  21. package/next.config.ts +6 -0
  22. package/package.json +1 -1
  23. package/packages/web-crawler/src/crawImpl/naive.ts +19 -12
  24. package/packages/web-crawler/src/urlRules.ts +9 -1
  25. package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/ChatItem/index.tsx +9 -18
  26. package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/WelcomeMessage.tsx +2 -5
  27. package/src/app/[variants]/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/HeaderAction.tsx +3 -2
  28. package/src/app/[variants]/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/Main.tsx +56 -30
  29. package/src/app/[variants]/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/Tags/HistoryLimitTags.tsx +26 -0
  30. package/src/app/[variants]/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/{SearchTags.tsx → Tags/SearchTags.tsx} +7 -4
  31. package/src/app/[variants]/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/{Tags.tsx → Tags/index.tsx} +4 -1
  32. package/src/app/[variants]/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/index.tsx +1 -1
  33. package/src/config/aiModels/anthropic.ts +16 -1
  34. package/src/config/modelProviders/anthropic.ts +0 -2
  35. package/src/const/layoutTokens.test.ts +1 -1
  36. package/src/const/layoutTokens.ts +1 -1
  37. package/src/const/models.ts +27 -0
  38. package/src/features/ChatInput/ActionBar/History.tsx +6 -3
  39. package/src/features/ChatInput/ActionBar/Model/ContextCachingSwitch.tsx +20 -0
  40. package/src/features/ChatInput/ActionBar/Model/ControlsForm.tsx +49 -7
  41. package/src/features/ChatInput/ActionBar/Model/ReasoningTokenSlider.tsx +6 -14
  42. package/src/features/ChatInput/ActionBar/Search/ModelBuiltinSearch.tsx +2 -2
  43. package/src/features/ChatInput/ActionBar/Search/SwitchPanel.tsx +2 -2
  44. package/src/features/ChatInput/ActionBar/Token/TokenTag.tsx +3 -5
  45. package/src/features/Conversation/Messages/Assistant/Tool/Render/CustomRender.tsx +2 -0
  46. package/src/features/Conversation/Messages/Assistant/Tool/Render/index.tsx +5 -1
  47. package/src/features/Conversation/Messages/Assistant/Tool/index.tsx +2 -0
  48. package/src/features/Conversation/components/ChatItem/index.tsx +3 -6
  49. package/src/features/Portal/Thread/Chat/ChatItem.tsx +4 -9
  50. package/src/hooks/useAgentEnableSearch.ts +2 -2
  51. package/src/libs/agent-runtime/anthropic/index.test.ts +36 -7
  52. package/src/libs/agent-runtime/anthropic/index.ts +30 -8
  53. package/src/libs/agent-runtime/azureOpenai/index.ts +4 -9
  54. package/src/libs/agent-runtime/azureai/index.ts +4 -9
  55. package/src/libs/agent-runtime/openai/index.ts +21 -38
  56. package/src/libs/agent-runtime/types/chat.ts +4 -0
  57. package/src/libs/agent-runtime/utils/anthropicHelpers.test.ts +55 -0
  58. package/src/libs/agent-runtime/utils/anthropicHelpers.ts +37 -3
  59. package/src/libs/langchain/loaders/code/__tests__/long.json +2 -2
  60. package/src/libs/langchain/loaders/code/__tests__/long.txt +1 -1
  61. package/src/locales/default/chat.ts +8 -0
  62. package/src/store/agent/initialState.ts +2 -2
  63. package/src/store/agent/selectors.ts +1 -1
  64. package/src/store/agent/slices/chat/{selectors.test.ts → selectors/agent.test.ts} +2 -2
  65. package/src/store/agent/slices/chat/{selectors.ts → selectors/agent.ts} +24 -33
  66. package/src/store/agent/slices/chat/selectors/chatConfig.test.ts +184 -0
  67. package/src/store/agent/slices/chat/selectors/chatConfig.ts +65 -0
  68. package/src/store/agent/slices/chat/selectors/index.ts +2 -0
  69. package/src/store/agent/store.ts +2 -2
  70. package/src/store/chat/helpers.test.ts +7 -7
  71. package/src/store/chat/helpers.ts +11 -7
  72. package/src/store/chat/slices/aiChat/actions/__tests__/generateAIChat.test.ts +3 -3
  73. package/src/store/chat/slices/aiChat/actions/generateAIChat.ts +11 -2
  74. package/src/store/chat/slices/aiChat/actions/helpers.ts +6 -2
  75. package/src/store/chat/slices/builtinTool/actions/searXNG.ts +28 -20
  76. package/src/store/chat/slices/message/selectors.ts +7 -3
  77. package/src/store/chat/slices/thread/selectors/index.ts +7 -3
  78. package/src/tools/web-browsing/Render/PageContent/Result.tsx +4 -2
  79. package/src/tools/web-browsing/Render/index.tsx +2 -0
  80. package/src/types/agent/index.ts +4 -0
  81. package/src/types/aiModel.ts +1 -1
  82. package/src/types/aiProvider.ts +60 -31
  83. /package/packages/web-crawler/src/{__test__ → __tests__}/crawler.test.ts +0 -0
  84. /package/packages/web-crawler/src/crawImpl/{__test__ → __tests__}/jina.test.ts +0 -0
  85. /package/src/app/[variants]/(main)/chat/(workspace)/_layout/Desktop/ChatHeader/{KnowledgeTag.tsx → Tags/KnowledgeTag.tsx} +0 -0
  86. /package/src/store/agent/slices/chat/{__snapshots__/selectors.test.ts.snap → selectors/__snapshots__/agent.test.ts.snap} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { DEFAULT_USER_AVATAR } from '@/const/meta';
2
2
  import { INBOX_SESSION_ID } from '@/const/session';
3
3
  import { useAgentStore } from '@/store/agent';
4
- import { agentSelectors } from '@/store/agent/selectors';
4
+ import { agentChatConfigSelectors } from '@/store/agent/selectors';
5
5
  import { messageMapKey } from '@/store/chat/utils/messageMapKey';
6
6
  import { useSessionStore } from '@/store/session';
7
7
  import { sessionMetaSelectors } from '@/store/session/selectors';
@@ -84,9 +84,13 @@ const mainAIChats = (s: ChatStoreState): ChatMessage[] => {
84
84
 
85
85
  const mainAIChatsWithHistoryConfig = (s: ChatStoreState): ChatMessage[] => {
86
86
  const chats = mainAIChats(s);
87
- const config = agentSelectors.currentAgentChatConfig(useAgentStore.getState());
87
+ const enableHistoryCount = agentChatConfigSelectors.enableHistoryCount(useAgentStore.getState());
88
+ const historyCount = agentChatConfigSelectors.historyCount(useAgentStore.getState());
88
89
 
89
- return chatHelpers.getSlicedMessagesWithConfig(chats, config);
90
+ return chatHelpers.getSlicedMessages(chats, {
91
+ enableHistoryCount,
92
+ historyCount,
93
+ });
90
94
  };
91
95
 
92
96
  const mainAIChatsMessageString = (s: ChatStoreState): string => {
@@ -1,6 +1,6 @@
1
1
  import { THREAD_DRAFT_ID } from '@/const/message';
2
2
  import { useAgentStore } from '@/store/agent';
3
- import { agentSelectors } from '@/store/agent/selectors';
3
+ import { agentChatConfigSelectors } from '@/store/agent/selectors';
4
4
  import type { ChatStoreState } from '@/store/chat';
5
5
  import { chatHelpers } from '@/store/chat/helpers';
6
6
  import { ChatMessage } from '@/types/message';
@@ -123,9 +123,13 @@ const portalAIChatsWithHistoryConfig = (s: ChatStoreState) => {
123
123
 
124
124
  const messages = [...parentMessages, ...afterMessages].filter(Boolean) as ChatMessage[];
125
125
 
126
- const config = agentSelectors.currentAgentChatConfig(useAgentStore.getState());
126
+ const enableHistoryCount = agentChatConfigSelectors.enableHistoryCount(useAgentStore.getState());
127
+ const historyCount = agentChatConfigSelectors.historyCount(useAgentStore.getState());
127
128
 
128
- return chatHelpers.getSlicedMessagesWithConfig(messages, config);
129
+ return chatHelpers.getSlicedMessages(messages, {
130
+ enableHistoryCount,
131
+ historyCount,
132
+ });
129
133
  };
130
134
 
131
135
  const threadSourceMessageIndex = (s: ChatStoreState) => {
@@ -51,12 +51,13 @@ const useStyles = createStyles(({ token, css }) => {
51
51
  }
52
52
  `,
53
53
  footer: css`
54
- padding: ${token.paddingXS}px;
54
+ padding-block: 8px;
55
+ padding-inline: 16px;
55
56
  text-align: center;
56
57
  background-color: ${token.colorFillQuaternary};
57
58
  `,
58
59
  footerText: css`
59
- font-size: ${token.fontSizeSM}px;
60
+ font-size: 12px !important;
60
61
  color: ${token.colorTextTertiary} !important;
61
62
  `,
62
63
  metaInfo: css`
@@ -153,6 +154,7 @@ const CrawlerResultCard = memo<CrawlerData>(({ result, messageId, crawler, origi
153
154
  <Descriptions
154
155
  classNames={{
155
156
  content: styles.footerText,
157
+ label: styles.footerText,
156
158
  }}
157
159
  column={2}
158
160
  items={[
@@ -45,4 +45,6 @@ const WebBrowsing = memo<BuiltinRenderProps<SearchContent[]>>(
45
45
  },
46
46
  );
47
47
 
48
+ WebBrowsing.displayName = 'WebBrowsing';
49
+
48
50
  export default WebBrowsing;
@@ -75,6 +75,10 @@ export interface LobeAgentChatConfig {
75
75
  enableReasoningEffort?: boolean;
76
76
  reasoningBudgetToken?: number;
77
77
 
78
+ /**
79
+ * 禁用上下文缓存
80
+ */
81
+ disableContextCaching?: boolean;
78
82
  /**
79
83
  * 历史消息条数
80
84
  */
@@ -140,7 +140,7 @@ export interface AiModelConfig {
140
140
 
141
141
  export type ModelSearchImplementType = 'tool' | 'params' | 'internal';
142
142
 
143
- export type ExtendParamsType = 'reasoningBudgetToken' | 'enableReasoning';
143
+ export type ExtendParamsType = 'reasoningBudgetToken' | 'enableReasoning' | 'disableContextCaching';
144
144
 
145
145
  export interface AiModelSettings {
146
146
  extendParams?: ExtendParamsType[];
@@ -32,37 +32,6 @@ export const AiProviderSDKEnum = {
32
32
 
33
33
  export type AiProviderSDKType = (typeof AiProviderSDKEnum)[keyof typeof AiProviderSDKEnum];
34
34
 
35
- // create
36
- export const CreateAiProviderSchema = z.object({
37
- config: z.object({}).passthrough().optional(),
38
- description: z.string().optional(),
39
- id: z.string(),
40
- keyVaults: z.any().optional(),
41
- logo: z.string().optional(),
42
- name: z.string(),
43
- sdkType: z.enum(['openai', 'anthropic']).optional(),
44
- source: z.enum(['builtin', 'custom']),
45
- // checkModel: z.string().optional(),
46
- // homeUrl: z.string().optional(),
47
- // modelsUrl: z.string().optional(),
48
- });
49
-
50
- export type CreateAiProviderParams = z.infer<typeof CreateAiProviderSchema>;
51
-
52
- // List Query
53
-
54
- export interface AiProviderListItem {
55
- description?: string;
56
- enabled: boolean;
57
- id: string;
58
- logo?: string;
59
- name?: string;
60
- sort?: number;
61
- source: AiProviderSourceType;
62
- }
63
-
64
- // Detail Query
65
-
66
35
  export interface AiProviderSettings {
67
36
  /**
68
37
  * whether provider show browser request option by default
@@ -115,6 +84,65 @@ export interface AiProviderSettings {
115
84
  smoothing?: SmoothingParams;
116
85
  }
117
86
 
87
+ const AiProviderSettingsSchema = z.object({
88
+ defaultShowBrowserRequest: z.boolean().optional(),
89
+ disableBrowserRequest: z.boolean().optional(),
90
+ modelEditable: z.boolean().optional(),
91
+ proxyUrl: z
92
+ .object({
93
+ desc: z.string().optional(),
94
+ placeholder: z.string(),
95
+ title: z.string().optional(),
96
+ })
97
+ .or(z.literal(false))
98
+ .optional(),
99
+ sdkType: z.enum(['anthropic', 'openai', 'ollama']).optional(),
100
+ searchMode: z.enum(['params', 'internal']).optional(),
101
+ showAddNewModel: z.boolean().optional(),
102
+ showApiKey: z.boolean().optional(),
103
+ showChecker: z.boolean().optional(),
104
+ showDeployName: z.boolean().optional(),
105
+ showModelFetcher: z.boolean().optional(),
106
+ smoothing: z
107
+ .object({
108
+ text: z.boolean().optional(),
109
+ toolsCalling: z.boolean().optional(),
110
+ })
111
+ .optional(),
112
+ });
113
+
114
+ // create
115
+ export const CreateAiProviderSchema = z.object({
116
+ config: z.object({}).passthrough().optional(),
117
+ description: z.string().optional(),
118
+ id: z.string(),
119
+ keyVaults: z.any().optional(),
120
+ logo: z.string().optional(),
121
+ name: z.string(),
122
+ sdkType: z.enum(['openai', 'anthropic']).optional(),
123
+ settings: AiProviderSettingsSchema.optional(),
124
+ source: z.enum(['builtin', 'custom']),
125
+ // checkModel: z.string().optional(),
126
+ // homeUrl: z.string().optional(),
127
+ // modelsUrl: z.string().optional(),
128
+ });
129
+
130
+ export type CreateAiProviderParams = z.infer<typeof CreateAiProviderSchema>;
131
+
132
+ // List Query
133
+
134
+ export interface AiProviderListItem {
135
+ description?: string;
136
+ enabled: boolean;
137
+ id: string;
138
+ logo?: string;
139
+ name?: string;
140
+ sort?: number;
141
+ source: AiProviderSourceType;
142
+ }
143
+
144
+ // Detail Query
145
+
118
146
  export interface AiProviderCard {
119
147
  /**
120
148
  * the default model that used for connection check
@@ -174,6 +202,7 @@ export const UpdateAiProviderSchema = z.object({
174
202
  logo: z.string().nullable().optional(),
175
203
  name: z.string(),
176
204
  sdkType: z.enum(['openai', 'anthropic']).optional(),
205
+ settings: AiProviderSettingsSchema.optional(),
177
206
  });
178
207
 
179
208
  export type UpdateAiProviderParams = z.infer<typeof UpdateAiProviderSchema>;