@lobehub/chat 0.86.3 → 0.86.5

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.
@@ -19,6 +19,12 @@ jobs:
19
19
  steps:
20
20
  - uses: actions/checkout@v4
21
21
 
22
+ - name: Clean issue notice
23
+ uses: actions-cool/issues-helper@v3
24
+ with:
25
+ actions: 'close-issues'
26
+ labels: '🚨 Sync Fail'
27
+
22
28
  - name: Sync upstream changes
23
29
  id: sync
24
30
  uses: aormsby/Fork-Sync-With-Upstream-action@v3.4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.86.5](https://github.com/lobehub/lobe-chat/compare/v0.86.4...v0.86.5)
6
+
7
+ <sup>Released on **2023-10-11**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix clear session error.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix clear session error, closes [#303](https://github.com/lobehub/lobe-chat/issues/303) ([09512fc](https://github.com/lobehub/lobe-chat/commit/09512fc))
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 0.86.4](https://github.com/lobehub/lobe-chat/compare/v0.86.3...v0.86.4)
31
+
32
+ <sup>Released on **2023-10-11**</sup>
33
+
34
+ #### 💄 Styles
35
+
36
+ - **misc**: Improve api key form.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Styles
44
+
45
+ - **misc**: Improve api key form ([fa3170d](https://github.com/lobehub/lobe-chat/commit/fa3170d))
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 0.86.3](https://github.com/lobehub/lobe-chat/compare/v0.86.2...v0.86.3)
6
56
 
7
57
  <sup>Released on **2023-10-11**</sup>
package/README.md CHANGED
@@ -17,10 +17,10 @@ LobeChat is a open-source, extensible ([Function Calling][fc-link]), high-perfor
17
17
  [![][github-release-shield]][github-release-link]
18
18
  [![][docker-release-shield]][docker-release-link]
19
19
  [![][vercel-shield]][vercel-link]
20
- [![][discord-shield]][discord-link]
21
- [![][github-releasedate-shield]][github-releasedate-link]
20
+ [![][discord-shield]][discord-link]<br/>
22
21
  [![][github-action-test-shield]][github-action-test-link]
23
- [![][github-action-release-shield]][github-action-release-link]<br/>
22
+ [![][github-action-release-shield]][github-action-release-link]
23
+ [![][github-releasedate-shield]][github-releasedate-link]<br/>
24
24
  [![][github-contributors-shield]][github-contributors-link]
25
25
  [![][github-forks-shield]][github-forks-link]
26
26
  [![][github-stars-shield]][github-stars-link]
@@ -190,11 +190,11 @@ LobeChat provides a [self-hosted version][deploy-link] with Vercel. This allows
190
190
  > **Note**\
191
191
  > This project provides some additional configuration items, set with environment variables, The complete list of environment variables can be found in the [📘 Environment Variables](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable) :
192
192
 
193
- | Environment Variable | Required | Description | Example |
194
- | -------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
195
- | `OPENAI_API_KEY` | Yes | This is the API key you apply on the OpenAI account page | `sk-xxxxxx...xxxxxx` |
193
+ | Environment Variable | Required | Description | Example |
194
+ | -------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
195
+ | `OPENAI_API_KEY` | Yes | This is the API key you apply on the OpenAI account page | `sk-xxxxxx...xxxxxx` |
196
196
  | `OPENAI_PROXY_URL` | No | If you manually configure the OpenAI interface proxy, you can use this configuration item to override the default OpenAI API request base URL | `https://api.chatanywhere.cn/v1`<br/>The default value is<br/>`https://api.openai.com/v1` |
197
- | `ACCESS_CODE` | No | Add a password to access this service, the password should be a 6-digit number or letter | `awCT74` or `e3@09!` |
197
+ | `ACCESS_CODE` | No | Add a password to access this service, the password should be a 6-digit number or letter | `awCT74` or `e3@09!` |
198
198
 
199
199
  ### Keep Updated
200
200
 
package/README.zh-CN.md CHANGED
@@ -17,10 +17,10 @@ LobeChat 是一个开源的、可扩展的([Function Calling][fc-link])高
17
17
  [![][github-release-shield]][github-release-link]
18
18
  [![][docker-release-shield]][docker-release-link]
19
19
  [![][vercel-shield]][vercel-link]
20
- [![][discord-shield]][discord-link]
21
- [![][github-releasedate-shield]][github-releasedate-link]
20
+ [![][discord-shield]][discord-link]<br/>
22
21
  [![][github-action-test-shield]][github-action-test-link]
23
- [![][github-action-release-shield]][github-action-release-link]<br/>
22
+ [![][github-action-release-shield]][github-action-release-link]
23
+ [![][github-releasedate-shield]][github-releasedate-link]<br/>
24
24
  [![][github-contributors-shield]][github-contributors-link]
25
25
  [![][github-forks-shield]][github-forks-link]
26
26
  [![][github-stars-shield]][github-stars-link]
@@ -192,11 +192,11 @@ LobeChat 提供了 Vercel 的 [自托管版本][deploy-link]。这使你可以
192
192
  > **Note**\
193
193
  > 本项目提供了一些额外的配置项,使用环境变量进行设置,完整环境变量可见 [📘环境变量](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN):
194
194
 
195
- | 环境变量 | 类型 | 描述 | 示例 |
196
- | ------------------ | ---- | -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
197
- | `OPENAI_API_KEY` | 必选 | 这是你在 OpenAI 账户页面申请的 API 密钥 | `sk-xxxxxx...xxxxxx` |
195
+ | 环境变量 | 类型 | 描述 | 示例 |
196
+ | ------------------ | ---- | -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
197
+ | `OPENAI_API_KEY` | 必选 | 这是你在 OpenAI 账户页面申请的 API 密钥 | `sk-xxxxxx...xxxxxx` |
198
198
  | `OPENAI_PROXY_URL` | 可选 | 如果你手动配置了 OpenAI 接口代理,可以使用此配置项来覆盖默认的 OpenAI API 请求基础 URL | `https://api.chatanywhere.cn/v1`<br/>默认值:<br/>`https://api.openai.com/v1` |
199
- | `ACCESS_CODE` | 可选 | 添加访问此服务的密码,密码应为 6 位数字或字母 | `awCT74` 或 `e3@09!` |
199
+ | `ACCESS_CODE` | 可选 | 添加访问此服务的密码,密码应为 6 位数字或字母 | `awCT74` 或 `e3@09!` |
200
200
 
201
201
  ### 保持更新
202
202
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.86.3",
3
+ "version": "0.86.5",
4
4
  "description": "An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -1,5 +1,7 @@
1
+ import { Icon } from '@lobehub/ui';
1
2
  import { Button, Input } from 'antd';
2
- import { memo } from 'react';
3
+ import { Network } from 'lucide-react';
4
+ import { memo, useState } from 'react';
3
5
  import { useTranslation } from 'react-i18next';
4
6
  import { Center, Flexbox } from 'react-layout-kit';
5
7
 
@@ -10,11 +12,14 @@ import { FormAction } from './style';
10
12
 
11
13
  const APIKeyForm = memo<{ id: string }>(({ id }) => {
12
14
  const { t } = useTranslation('error');
15
+ const [showProxy, setShow] = useState(false);
13
16
 
14
- const [apiKey, setKeys] = useGlobalStore((s) => [
17
+ const [apiKey, proxyUrl, setConfig] = useGlobalStore((s) => [
15
18
  settingsSelectors.openAIAPI(s),
16
- s.setOpenAIAPIKey,
19
+ settingsSelectors.openAIProxyUrl(s),
20
+ s.setOpenAIConfig,
17
21
  ]);
22
+
18
23
  const [resend, deleteMessage] = useSessionStore((s) => [s.resendMessage, s.deleteMessage]);
19
24
 
20
25
  return (
@@ -26,12 +31,32 @@ const APIKeyForm = memo<{ id: string }>(({ id }) => {
26
31
  >
27
32
  <Input.Password
28
33
  onChange={(e) => {
29
- setKeys(e.target.value);
34
+ setConfig({ OPENAI_API_KEY: e.target.value });
30
35
  }}
31
36
  placeholder={'sk-*****************************************'}
32
37
  type={'block'}
33
38
  value={apiKey}
34
39
  />
40
+ {showProxy ? (
41
+ <Input
42
+ onChange={(e) => {
43
+ setConfig({ endpoint: e.target.value });
44
+ }}
45
+ placeholder={'https://api.openai.com/v1'}
46
+ type={'block'}
47
+ value={proxyUrl}
48
+ />
49
+ ) : (
50
+ <Button
51
+ icon={<Icon icon={Network} />}
52
+ onClick={() => {
53
+ setShow(true);
54
+ }}
55
+ type={'text'}
56
+ >
57
+ {t('unlock.apikey.addProxyUrl')}
58
+ </Button>
59
+ )}
35
60
  </FormAction>
36
61
  <Flexbox gap={12} width={'100%'}>
37
62
  <Button
@@ -29,12 +29,12 @@ const InvalidAccess = memo<{ id: string }>(({ id }) => {
29
29
  block
30
30
  onChange={(value) => setMode(value as Tab)}
31
31
  options={[
32
- { icon: <Icon icon={KeySquare} />, label: 'OpenAI API Key', value: Tab.Api },
33
32
  {
34
33
  icon: <Icon icon={SquareAsterisk} />,
35
34
  label: t('password', { ns: 'common' }),
36
35
  value: Tab.Password,
37
36
  },
37
+ { icon: <Icon icon={KeySquare} />, label: 'OpenAI API Key', value: Tab.Api },
38
38
  ]}
39
39
  style={{ width: '100%' }}
40
40
  value={mode}
@@ -37,6 +37,7 @@ export default {
37
37
  },
38
38
  unlock: {
39
39
  apikey: {
40
+ addProxyUrl: '添加 OpenAI 代理地址(可选)',
40
41
  description: '输入你的 OpenAI API Key 即可开始会话。应用不会记录你的 API Key',
41
42
  title: '使用自定义 API Key',
42
43
  },
@@ -17,6 +17,8 @@ const defaultAgentMeta = (s: GlobalStore) => merge(DEFAULT_AGENT_META, defaultAg
17
17
  const openAIAPIKeySelectors = (s: GlobalStore) =>
18
18
  s.settings.languageModel.openAI.OPENAI_API_KEY || s.settings.OPENAI_API_KEY;
19
19
 
20
+ const openAIProxyUrlSelectors = (s: GlobalStore) => s.settings.languageModel.openAI.endpoint;
21
+
20
22
  export const exportSettings = (s: GlobalStore) => {
21
23
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
24
  const { OPENAI_API_KEY: _, password: __, ...settings } = s.settings;
@@ -41,4 +43,5 @@ export const settingsSelectors = {
41
43
  defaultAgentMeta,
42
44
  exportSettings,
43
45
  openAIAPI: openAIAPIKeySelectors,
46
+ openAIProxyUrl: openAIProxyUrlSelectors,
44
47
  };
@@ -6,7 +6,7 @@ import type { StateCreator } from 'zustand/vanilla';
6
6
 
7
7
  import { DEFAULT_AGENT, DEFAULT_SETTINGS } from '@/const/settings';
8
8
  import { SettingsTabs } from '@/store/global/initialState';
9
- import type { GlobalSettings } from '@/types/settings';
9
+ import type { GlobalSettings, OpenAIConfig } from '@/types/settings';
10
10
  import { merge } from '@/utils/merge';
11
11
  import { setNamespace } from '@/utils/storeDebug';
12
12
 
@@ -23,7 +23,7 @@ export interface SettingsAction {
23
23
  * 重置设置
24
24
  */
25
25
  resetSettings: () => void;
26
- setOpenAIAPIKey: (apikey: string) => void;
26
+ setOpenAIConfig: (config: Partial<OpenAIConfig>) => void;
27
27
  /**
28
28
  * 设置部分配置设置
29
29
  * @param settings - 部分配置设置
@@ -63,17 +63,17 @@ export const createSettingsSlice: StateCreator<
63
63
  resetSettings: () => {
64
64
  set({ settings: DEFAULT_SETTINGS }, false, t('resetSettings'));
65
65
  },
66
- setOpenAIAPIKey: (apikey) => {
67
- get().setSettings({ languageModel: { openAI: { OPENAI_API_KEY: apikey } } });
66
+ setOpenAIConfig: (config) => {
67
+ get().setSettings({ languageModel: { openAI: config } });
68
68
  },
69
69
 
70
70
  setSettings: (settings) => {
71
- const oldSetting = get().settings;
72
- const nextSettings = merge(oldSetting, settings);
71
+ const prevSetting = get().settings;
72
+ const nextSettings = merge(prevSetting, settings);
73
73
 
74
- if (isEqual(oldSetting, nextSettings)) return;
74
+ if (isEqual(prevSetting, nextSettings)) return;
75
75
 
76
- set({ settings: merge(oldSetting, settings) }, false, t('setSettings', settings));
76
+ set({ settings: merge(prevSetting, settings) }, false, t('setSettings', settings));
77
77
  },
78
78
  switchSettingTabs: (tab) => {
79
79
  set({ settingsTab: tab });
@@ -11,7 +11,7 @@ import { LobeAgentSession, LobeAgentSettings, LobeSessions } from '@/types/sessi
11
11
  import { setNamespace } from '@/utils/storeDebug';
12
12
  import { uuid } from '@/utils/uuid';
13
13
 
14
- import { initLobeSession } from './initialState';
14
+ import { initInbox, initLobeSession } from './initialState';
15
15
  import { SessionDispatch, sessionsReducer } from './reducers/session';
16
16
 
17
17
  const t = setNamespace('session');
@@ -76,7 +76,7 @@ export const createSessionSlice: StateCreator<
76
76
  },
77
77
 
78
78
  clearSessions: () => {
79
- set({ sessions: {} }, false, t('clearSessions'));
79
+ set({ inbox: initInbox, sessions: {} }, false, t('clearSessions'));
80
80
  },
81
81
 
82
82
  createSession: async (agent) => {
@@ -45,7 +45,7 @@ export interface GlobalBaseSettings {
45
45
 
46
46
  export type GlobalDefaultAgent = Pick<LobeAgentSession, 'config' | 'meta'>;
47
47
 
48
- interface OpenAIConfig {
48
+ export interface OpenAIConfig {
49
49
  OPENAI_API_KEY: string;
50
50
  azureApiVersion?: string;
51
51
  endpoint?: string;