@lobehub/chat 1.118.0 → 1.118.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.
Files changed (83) hide show
  1. package/.env.example +8 -0
  2. package/CHANGELOG.md +33 -0
  3. package/changelog/v1.json +12 -0
  4. package/locales/ar/chat.json +6 -1
  5. package/locales/ar/error.json +8 -8
  6. package/locales/ar/models.json +21 -0
  7. package/locales/ar/providers.json +3 -0
  8. package/locales/bg-BG/chat.json +6 -1
  9. package/locales/bg-BG/error.json +8 -8
  10. package/locales/bg-BG/models.json +21 -0
  11. package/locales/bg-BG/providers.json +3 -0
  12. package/locales/de-DE/chat.json +6 -1
  13. package/locales/de-DE/error.json +7 -7
  14. package/locales/de-DE/models.json +21 -0
  15. package/locales/de-DE/providers.json +3 -0
  16. package/locales/en-US/chat.json +6 -1
  17. package/locales/en-US/error.json +4 -4
  18. package/locales/en-US/models.json +21 -0
  19. package/locales/en-US/providers.json +3 -0
  20. package/locales/es-ES/chat.json +6 -1
  21. package/locales/es-ES/error.json +9 -9
  22. package/locales/es-ES/models.json +21 -0
  23. package/locales/es-ES/providers.json +3 -0
  24. package/locales/fa-IR/chat.json +6 -1
  25. package/locales/fa-IR/error.json +9 -9
  26. package/locales/fa-IR/models.json +21 -0
  27. package/locales/fa-IR/providers.json +3 -0
  28. package/locales/fr-FR/chat.json +6 -1
  29. package/locales/fr-FR/error.json +9 -9
  30. package/locales/fr-FR/models.json +21 -0
  31. package/locales/fr-FR/providers.json +3 -0
  32. package/locales/it-IT/chat.json +6 -1
  33. package/locales/it-IT/error.json +7 -7
  34. package/locales/it-IT/models.json +21 -0
  35. package/locales/it-IT/providers.json +3 -0
  36. package/locales/ja-JP/chat.json +6 -1
  37. package/locales/ja-JP/error.json +8 -8
  38. package/locales/ja-JP/models.json +21 -0
  39. package/locales/ja-JP/providers.json +3 -0
  40. package/locales/ko-KR/chat.json +6 -1
  41. package/locales/ko-KR/error.json +8 -8
  42. package/locales/ko-KR/models.json +21 -0
  43. package/locales/ko-KR/providers.json +3 -0
  44. package/locales/nl-NL/chat.json +6 -1
  45. package/locales/nl-NL/error.json +8 -8
  46. package/locales/nl-NL/models.json +21 -0
  47. package/locales/nl-NL/providers.json +3 -0
  48. package/locales/pl-PL/chat.json +6 -1
  49. package/locales/pl-PL/error.json +9 -9
  50. package/locales/pl-PL/models.json +21 -0
  51. package/locales/pl-PL/providers.json +3 -0
  52. package/locales/pt-BR/chat.json +6 -1
  53. package/locales/pt-BR/error.json +8 -8
  54. package/locales/pt-BR/models.json +21 -0
  55. package/locales/pt-BR/providers.json +3 -0
  56. package/locales/ru-RU/chat.json +6 -1
  57. package/locales/ru-RU/error.json +7 -7
  58. package/locales/ru-RU/models.json +21 -0
  59. package/locales/ru-RU/providers.json +3 -0
  60. package/locales/tr-TR/chat.json +6 -1
  61. package/locales/tr-TR/error.json +9 -9
  62. package/locales/tr-TR/models.json +21 -0
  63. package/locales/tr-TR/providers.json +3 -0
  64. package/locales/vi-VN/chat.json +6 -1
  65. package/locales/vi-VN/models.json +21 -0
  66. package/locales/vi-VN/providers.json +3 -0
  67. package/locales/zh-CN/chat.json +6 -1
  68. package/locales/zh-CN/models.json +21 -0
  69. package/locales/zh-CN/providers.json +3 -0
  70. package/locales/zh-TW/chat.json +6 -1
  71. package/locales/zh-TW/error.json +4 -4
  72. package/locales/zh-TW/models.json +21 -0
  73. package/locales/zh-TW/providers.json +3 -0
  74. package/next.config.ts +22 -6
  75. package/package.json +1 -1
  76. package/packages/model-runtime/src/google/index.ts +17 -3
  77. package/packages/model-runtime/src/types/chat.ts +4 -0
  78. package/packages/types/src/agent/chatConfig.ts +1 -0
  79. package/packages/types/src/aiModel.ts +2 -1
  80. package/src/config/aiModels/google.ts +8 -6
  81. package/src/features/ChatInput/ActionBar/Model/ControlsForm.tsx +13 -1
  82. package/src/locales/default/chat.ts +4 -0
  83. package/src/services/chat.ts +4 -0
package/next.config.ts CHANGED
@@ -9,6 +9,7 @@ const buildWithDocker = process.env.DOCKER === 'true';
9
9
  const isDesktop = process.env.NEXT_PUBLIC_IS_DESKTOP_APP === '1';
10
10
  const enableReactScan = !!process.env.REACT_SCAN_MONITOR_API_KEY;
11
11
  const isUsePglite = process.env.NEXT_PUBLIC_CLIENT_DB === 'pglite';
12
+ const shouldUseCSP = process.env.ENABLED_CSP === '1';
12
13
 
13
14
  // if you need to proxy the api endpoint to remote server
14
15
 
@@ -41,14 +42,29 @@ const nextConfig: NextConfig = {
41
42
  webVitalsAttribution: ['CLS', 'LCP'],
42
43
  },
43
44
  async headers() {
45
+ const securityHeaders = [
46
+ {
47
+ key: 'x-robots-tag',
48
+ value: 'all',
49
+ },
50
+ ];
51
+
52
+ if (shouldUseCSP) {
53
+ securityHeaders.push(
54
+ {
55
+ key: 'X-Frame-Options',
56
+ value: 'DENY',
57
+ },
58
+ {
59
+ key: 'Content-Security-Policy',
60
+ value: "frame-ancestors 'none';",
61
+ },
62
+ );
63
+ }
64
+
44
65
  return [
45
66
  {
46
- headers: [
47
- {
48
- key: 'x-robots-tag',
49
- value: 'all',
50
- },
51
- ],
67
+ headers: securityHeaders,
52
68
  source: '/:path*',
53
69
  },
54
70
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.118.0",
3
+ "version": "1.118.1",
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",
@@ -484,14 +484,28 @@ export class LobeGoogleAI implements LobeRuntimeAI {
484
484
  tools: ChatCompletionTool[] | undefined,
485
485
  payload?: ChatStreamPayload,
486
486
  ): GoogleFunctionCallTool[] | undefined {
487
- // 目前 Tools (例如 googleSearch) 无法与其他 FunctionCall 同时使用
488
- if (payload?.messages?.some((m) => m.tool_calls?.length)) {
487
+ const hasToolCalls = payload?.messages?.some((m) => m.tool_calls?.length);
488
+ const hasSearch = payload?.enabledSearch;
489
+ const hasUrlContext = payload?.urlContext;
490
+ const hasFunctionTools = tools && tools.length > 0;
491
+
492
+ // 如果已经有 tool_calls,优先处理 function declarations
493
+ if (hasToolCalls && hasFunctionTools) {
489
494
  return this.buildFunctionDeclarations(tools);
490
495
  }
491
- if (payload?.enabledSearch) {
496
+
497
+ // 构建并返回搜索相关工具(搜索工具不能与 FunctionCall 同时使用)
498
+ if (hasUrlContext && hasSearch) {
499
+ return [{ urlContext: {} }, { googleSearch: {} }];
500
+ }
501
+ if (hasUrlContext) {
502
+ return [{ urlContext: {} }];
503
+ }
504
+ if (hasSearch) {
492
505
  return [{ googleSearch: {} }];
493
506
  }
494
507
 
508
+ // 最后考虑 function declarations
495
509
  return this.buildFunctionDeclarations(tools);
496
510
  }
497
511
 
@@ -138,6 +138,10 @@ export interface ChatStreamPayload {
138
138
  */
139
139
  top_p?: number;
140
140
  truncation?: 'auto' | 'disabled';
141
+ /**
142
+ * @title Gemini URL 上下文获取工具开关
143
+ */
144
+ urlContext?: boolean;
141
145
  verbosity?: 'low' | 'medium' | 'high';
142
146
  }
143
147
 
@@ -54,6 +54,7 @@ export interface LobeAgentChatConfig {
54
54
 
55
55
  searchMode?: SearchMode;
56
56
  searchFCModel?: WorkingModel;
57
+ urlContext?: boolean;
57
58
  useModelBuiltinSearch?: boolean;
58
59
  }
59
60
  /* eslint-enable */
@@ -214,7 +214,8 @@ export type ExtendParamsType =
214
214
  | 'gpt5ReasoningEffort'
215
215
  | 'textVerbosity'
216
216
  | 'thinking'
217
- | 'thinkingBudget';
217
+ | 'thinkingBudget'
218
+ | 'urlContext';
218
219
 
219
220
  export interface AiModelSettings {
220
221
  extendParams?: ExtendParamsType[];
@@ -42,7 +42,7 @@ const googleChatModels: AIChatModelCard[] = [
42
42
  },
43
43
  releasedAt: '2025-06-17',
44
44
  settings: {
45
- extendParams: ['thinkingBudget'],
45
+ extendParams: ['thinkingBudget', 'urlContext'],
46
46
  searchImpl: 'params',
47
47
  searchProvider: 'google',
48
48
  },
@@ -86,7 +86,7 @@ const googleChatModels: AIChatModelCard[] = [
86
86
  },
87
87
  releasedAt: '2025-06-05',
88
88
  settings: {
89
- extendParams: ['thinkingBudget'],
89
+ extendParams: ['thinkingBudget', 'urlContext'],
90
90
  searchImpl: 'params',
91
91
  searchProvider: 'google',
92
92
  },
@@ -157,7 +157,7 @@ const googleChatModels: AIChatModelCard[] = [
157
157
  },
158
158
  releasedAt: '2025-06-17',
159
159
  settings: {
160
- extendParams: ['thinkingBudget'],
160
+ extendParams: ['thinkingBudget', 'urlContext'],
161
161
  searchImpl: 'params',
162
162
  searchProvider: 'google',
163
163
  },
@@ -184,7 +184,7 @@ const googleChatModels: AIChatModelCard[] = [
184
184
  },
185
185
  releasedAt: '2025-05-20',
186
186
  settings: {
187
- extendParams: ['thinkingBudget'],
187
+ extendParams: ['thinkingBudget', 'urlContext'],
188
188
  searchImpl: 'params',
189
189
  searchProvider: 'google',
190
190
  },
@@ -233,7 +233,7 @@ const googleChatModels: AIChatModelCard[] = [
233
233
  },
234
234
  releasedAt: '2025-07-22',
235
235
  settings: {
236
- extendParams: ['thinkingBudget'],
236
+ extendParams: ['thinkingBudget', 'urlContext'],
237
237
  searchImpl: 'params',
238
238
  searchProvider: 'google',
239
239
  },
@@ -261,7 +261,7 @@ const googleChatModels: AIChatModelCard[] = [
261
261
  },
262
262
  releasedAt: '2025-06-11',
263
263
  settings: {
264
- extendParams: ['thinkingBudget'],
264
+ extendParams: ['thinkingBudget', 'urlContext'],
265
265
  searchImpl: 'params',
266
266
  searchProvider: 'google',
267
267
  },
@@ -288,6 +288,7 @@ const googleChatModels: AIChatModelCard[] = [
288
288
  },
289
289
  releasedAt: '2025-02-05',
290
290
  settings: {
291
+ extendParams: ['urlContext'],
291
292
  searchImpl: 'params',
292
293
  searchProvider: 'google',
293
294
  },
@@ -314,6 +315,7 @@ const googleChatModels: AIChatModelCard[] = [
314
315
  },
315
316
  releasedAt: '2025-02-05',
316
317
  settings: {
318
+ extendParams: ['urlContext'],
317
319
  searchImpl: 'params',
318
320
  searchProvider: 'google',
319
321
  },
@@ -123,13 +123,25 @@ const ControlsForm = memo(() => {
123
123
  children: <ThinkingBudgetSlider />,
124
124
  label: t('extendParams.reasoningBudgetToken.title'),
125
125
  layout: 'vertical',
126
- minWidth: 500,
126
+ minWidth: 470,
127
127
  name: 'thinkingBudget',
128
128
  style: {
129
129
  paddingBottom: 0,
130
130
  },
131
131
  tag: 'thinkingBudget',
132
132
  },
133
+ {
134
+ children: <Switch />,
135
+ desc: t('extendParams.urlContext.desc'),
136
+ label: t('extendParams.urlContext.title'),
137
+ layout: 'horizontal',
138
+ minWidth: undefined,
139
+ name: 'urlContext',
140
+ style: {
141
+ width: 445,
142
+ },
143
+ tag: 'urlContext',
144
+ },
133
145
  {
134
146
  children: <ThinkingSlider />,
135
147
  label: t('extendParams.thinking.title'),
@@ -54,6 +54,10 @@ export default {
54
54
  title: '深度思考开关',
55
55
  },
56
56
  title: '模型扩展功能',
57
+ urlContext: {
58
+ desc: '开启后将自动解析网页链接,以获取实际网页上下文内容',
59
+ title: '提取网页链接内容',
60
+ },
57
61
  },
58
62
  history: {
59
63
  title: '助手将只记住最后{{count}}条消息',
@@ -297,6 +297,10 @@ class ChatService {
297
297
  ) {
298
298
  extendParams.thinkingBudget = chatConfig.thinkingBudget;
299
299
  }
300
+
301
+ if (modelExtendParams!.includes('urlContext') && chatConfig.urlContext) {
302
+ extendParams.urlContext = chatConfig.urlContext;
303
+ }
300
304
  }
301
305
 
302
306
  return this.getChatCompletion(