@lobehub/chat 1.29.1 → 1.29.3

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 CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.29.3](https://github.com/lobehub/lobe-chat/compare/v1.29.2...v1.29.3)
6
+
7
+ <sup>Released on **2024-11-09**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix the display model of history summary.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix the display model of history summary, closes [#4656](https://github.com/lobehub/lobe-chat/issues/4656) ([66cf2c1](https://github.com/lobehub/lobe-chat/commit/66cf2c1))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ### [Version 1.29.2](https://github.com/lobehub/lobe-chat/compare/v1.29.1...v1.29.2)
31
+
32
+ <sup>Released on **2024-11-09**</sup>
33
+
34
+ #### 💄 Styles
35
+
36
+ - **misc**: Allow users to disable SSRF or set a whitelist.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Styles
44
+
45
+ - **misc**: Allow users to disable SSRF or set a whitelist, closes [#4633](https://github.com/lobehub/lobe-chat/issues/4633) ([7175145](https://github.com/lobehub/lobe-chat/commit/7175145))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ### [Version 1.29.1](https://github.com/lobehub/lobe-chat/compare/v1.29.0...v1.29.1)
6
56
 
7
57
  <sup>Released on **2024-11-09**</sup>
@@ -93,6 +93,20 @@ For specific content, please refer to the [Feature Flags](/docs/self-hosting/adv
93
93
  try using `host.docker.internal` instead of `localhost`.
94
94
  </Callout>
95
95
 
96
+ ### `SSRF_ALLOW_PRIVATE_IP_ADDRESS`
97
+
98
+ - Type: Optional
99
+ - Description: Allow to connect private IP address. In a trusted environment, it can be set to true to turn off SSRF protection.
100
+ - Default: `0`
101
+ - Example: `1` or `0`
102
+
103
+ ### `SSRF_ALLOW_IP_ADDRESS_LIST`
104
+
105
+ - Type: Optional
106
+ - Description: Allow private IP address list, multiple IP addresses are separated by commas. Only when `SSRF_ALLOW_PRIVATE_IP_ADDRESS` is `0`, it takes effect.
107
+ - Default: -
108
+ - Example: `198.18.1.62,224.0.0.3`
109
+
96
110
  ## Plugin Service
97
111
 
98
112
  ### `PLUGINS_INDEX_URL`
@@ -88,6 +88,20 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
88
88
  是走到自身容器的 `localhost`,此时请尝试用 `host.docker.internal` 替代 `localhost`
89
89
  </Callout>
90
90
 
91
+ ### `SSRF_ALLOW_PRIVATE_IP_ADDRESS`
92
+
93
+ - 类型:可选
94
+ - 描述:是否允许连接私有IP地址。在可信环境中可以设置为true来关闭SSRF防护。
95
+ - 默认值:`0`
96
+ - 示例:`1` or `0`
97
+
98
+ ### `SSRF_ALLOW_IP_ADDRESS_LIST`
99
+
100
+ - 类型:可选
101
+ - 描述:允许连接的私有IP地址列表,多个IP地址时使用逗号分隔。当 `SSRF_ALLOW_PRIVATE_IP_ADDRESS` 为 `0` 时才会生效。
102
+ - 默认值:-
103
+ - 示例:`198.18.1.62,224.0.0.3`
104
+
91
105
  ## 插件服务
92
106
 
93
107
  ### `PLUGINS_INDEX_URL`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.29.1",
3
+ "version": "1.29.3",
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",
@@ -1,6 +1,8 @@
1
1
  import { NextResponse } from 'next/server';
2
2
  import fetch from 'node-fetch';
3
- import { useAgent as ssrfAgent } from 'request-filtering-agent';
3
+ import { RequestFilteringAgentOptions, useAgent as ssrfAgent } from 'request-filtering-agent';
4
+
5
+ import { appEnv } from '@/config/app';
4
6
 
5
7
  /**
6
8
  * just for a proxy
@@ -9,7 +11,14 @@ export const POST = async (req: Request) => {
9
11
  const url = await req.text();
10
12
 
11
13
  try {
12
- const res = await fetch(url, { agent: ssrfAgent(url) });
14
+ // https://www.npmjs.com/package/request-filtering-agent
15
+ const options: RequestFilteringAgentOptions = {
16
+ allowIPAddressList: appEnv.SSRF_ALLOW_IP_ADDRESS_LIST?.split(',') || [],
17
+ allowMetaIPAddress: appEnv.SSRF_ALLOW_PRIVATE_IP_ADDRESS,
18
+ allowPrivateIPAddress: appEnv.SSRF_ALLOW_PRIVATE_IP_ADDRESS,
19
+ denyIPAddressList: [],
20
+ };
21
+ const res = await fetch(url, { agent: ssrfAgent(url, options) });
13
22
 
14
23
  return new Response(await res.arrayBuffer(), { headers: { ...res.headers } });
15
24
  } catch (err) {
package/src/config/app.ts CHANGED
@@ -46,6 +46,9 @@ export const getAppConfig = () => {
46
46
  CDN_USE_GLOBAL: z.boolean().optional(),
47
47
  CUSTOM_FONT_FAMILY: z.string().optional(),
48
48
  CUSTOM_FONT_URL: z.string().optional(),
49
+
50
+ SSRF_ALLOW_PRIVATE_IP_ADDRESS: z.boolean().optional(),
51
+ SSRF_ALLOW_IP_ADDRESS_LIST: z.string().optional(),
49
52
  },
50
53
  runtimeEnv: {
51
54
  NEXT_PUBLIC_BASE_PATH: process.env.NEXT_PUBLIC_BASE_PATH || '',
@@ -72,6 +75,9 @@ export const getAppConfig = () => {
72
75
  CUSTOM_FONT_FAMILY: process.env.CUSTOM_FONT_FAMILY,
73
76
  CUSTOM_FONT_URL: process.env.CUSTOM_FONT_URL,
74
77
  CDN_USE_GLOBAL: process.env.CDN_USE_GLOBAL === '1',
78
+
79
+ SSRF_ALLOW_PRIVATE_IP_ADDRESS: process.env.SSRF_ALLOW_PRIVATE_IP_ADDRESS === '1',
80
+ SSRF_ALLOW_IP_ADDRESS_LIST: process.env.SSRF_ALLOW_IP_ADDRESS_LIST,
75
81
  },
76
82
  });
77
83
  };
@@ -8,8 +8,6 @@ import { useUserStore } from '@/store/user';
8
8
  import { systemAgentSelectors } from '@/store/user/selectors';
9
9
  import { ChatMessage } from '@/types/message';
10
10
 
11
- import { getAgentConfig } from './helpers';
12
-
13
11
  export interface ChatMemoryAction {
14
12
  internal_summaryHistory: (messages: ChatMessage[]) => Promise<void>;
15
13
  }
@@ -24,9 +22,7 @@ export const chatMemory: StateCreator<
24
22
  const topicId = get().activeTopicId;
25
23
  if (messages.length <= 1 || !topicId) return;
26
24
 
27
- const { model, provider } = getAgentConfig();
28
-
29
- const historyCompressConfig = systemAgentSelectors.historyCompress(useUserStore.getState());
25
+ const { model, provider } = systemAgentSelectors.historyCompress(useUserStore.getState());
30
26
 
31
27
  let historySummary = '';
32
28
  await chatService.fetchPresetTaskResult({
@@ -34,12 +30,7 @@ export const chatMemory: StateCreator<
34
30
  historySummary = text;
35
31
  },
36
32
 
37
- params: {
38
- ...chainSummaryHistory(messages),
39
- model: historyCompressConfig.model,
40
- provider: historyCompressConfig.provider,
41
- stream: false,
42
- },
33
+ params: { ...chainSummaryHistory(messages), model, provider, stream: false },
43
34
  });
44
35
 
45
36
  await topicService.updateTopic(topicId, {