@lobehub/chat 0.115.7 → 0.115.9

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,57 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.115.9](https://github.com/lobehub/lobe-chat/compare/v0.115.8...v0.115.9)
6
+
7
+ <sup>Released on **2023-12-24**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix `PLUGINS_INDEX_URL` not working, fix a translation error in Traditional Chinese.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix `PLUGINS_INDEX_URL` not working, closes [#793](https://github.com/lobehub/lobe-chat/issues/793) ([152913e](https://github.com/lobehub/lobe-chat/commit/152913e))
21
+ - **misc**: Fix a translation error in Traditional Chinese, closes [#789](https://github.com/lobehub/lobe-chat/issues/789) ([80c02ee](https://github.com/lobehub/lobe-chat/commit/80c02ee))
22
+
23
+ </details>
24
+
25
+ <div align="right">
26
+
27
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
28
+
29
+ </div>
30
+
31
+ ### [Version 0.115.8](https://github.com/lobehub/lobe-chat/compare/v0.115.7...v0.115.8)
32
+
33
+ <sup>Released on **2023-12-24**</sup>
34
+
35
+ #### 🐛 Bug Fixes
36
+
37
+ - **misc**: Fix CUSTOM_MODEL `-` operator not working.
38
+
39
+ <br/>
40
+
41
+ <details>
42
+ <summary><kbd>Improvements and Fixes</kbd></summary>
43
+
44
+ #### What's fixed
45
+
46
+ - **misc**: Fix CUSTOM_MODEL `-` operator not working, closes [#791](https://github.com/lobehub/lobe-chat/issues/791) ([26b968f](https://github.com/lobehub/lobe-chat/commit/26b968f))
47
+
48
+ </details>
49
+
50
+ <div align="right">
51
+
52
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
53
+
54
+ </div>
55
+
5
56
  ### [Version 0.115.7](https://github.com/lobehub/lobe-chat/compare/v0.115.6...v0.115.7)
6
57
 
7
58
  <sup>Released on **2023-12-23**</sup>
package/README.md CHANGED
@@ -206,14 +206,14 @@ Our marketplace is not just a showcase platform but also a collaborative space.
206
206
 
207
207
  <!-- AGENT LIST -->
208
208
 
209
- | Recent Submits | Description |
210
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
211
- | [Facebook Ads Expert](https://chat-preview.lobehub.com/market?agent=facebook-ads-expert)<br/><sup>By **[alissonryan](https://github.com/alissonryan)** on **2023-12-20**</sup> | Create a Facebook Ads with a expert<br/>`copywriting` `facebook-ads` `lead-generation` |
212
- | [Dream Painter](https://chat-preview.lobehub.com/market?agent=dream-painter)<br/><sup>By **[ccdanpian](https://github.com/ccdanpian)** on **2023-12-19**</sup> | A dream artist who can bring your dreams into reality.<br/>`txt-2-img` `painter` |
213
- | [NewsHub](https://chat-preview.lobehub.com/market?agent=news-hub)<br/><sup>By **[ccdanpian](https://github.com/ccdanpian)** on **2023-12-19**</sup> | A news search assistant proficient at finding and presenting relevant news<br/>`news` `search` `helper` |
214
- | [NewsNest](https://chat-preview.lobehub.com/market?agent=news-nest)<br/><sup>By **[ccdanpian](https://github.com/ccdanpian)** on **2023-12-19**</sup> | A news search assistant, can help you find and display relevant news based on your needs.<br/>`news` `search` |
215
-
216
- > 📊 Total agents: [<kbd>**79**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
209
+ | Recent Submits | Description |
210
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
211
+ | [Facebook Ads Expert](https://chat-preview.lobehub.com/market?agent=facebook-ads-expert)<br/><sup>By **[alissonryan](https://github.com/alissonryan)** on **2023-12-20**</sup> | Create a Facebook Ads with a expert<br/>`copywriting` `facebook-ads` `lead-generation` |
212
+ | [Dream Painter](https://chat-preview.lobehub.com/market?agent=dream-painter)<br/><sup>By **[ccdanpian](https://github.com/ccdanpian)** on **2023-12-19**</sup> | A dream artist who can bring your dreams into reality.<br/>`txt-2-img` `painter` |
213
+ | [News Hub](https://chat-preview.lobehub.com/market?agent=news-hub)<br/><sup>By **[ccdanpian](https://github.com/ccdanpian)** on **2023-12-19**</sup> | News Search Assistant, proficient in locating and presenting relevant news based on user requests. Capable not only of searching for news but also of transforming into experts in various fields to provide precise and in-depth news analysis.<br/>`news` `search` `helper` |
214
+ | [Research Assistant](https://chat-preview.lobehub.com/market?agent=research-assistant)<br/><sup>By **[ccsen](https://github.com/ccsen)** on **2023-12-19**</sup> | Capable of answering questions, conducting research, drafting content, and more, utilizing scientific research papers.<br/>`research-assistant` `literature-retrieval` `writing` `scientific-research` `citation` |
215
+
216
+ > 📊 Total agents: [<kbd>**77**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
217
217
 
218
218
  <!-- AGENT LIST -->
219
219
 
package/README.zh-CN.md CHANGED
@@ -183,14 +183,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
183
183
 
184
184
  <!-- AGENT LIST -->
185
185
 
186
- | 最近新增 | 助手说明 |
187
- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
188
- | [Facebook 广告专家](https://chat-preview.lobehub.com/market?agent=facebook-ads-expert)<br/><sup>By **[alissonryan](https://github.com/alissonryan)** on **2023-12-20**</sup> | 与专家一起创建 Facebook 广告<br/>`文案撰写` `facebook广告` `潜在客户生成` |
189
- | [梦境画家](https://chat-preview.lobehub.com/market?agent=dream-painter)<br/><sup>By **[ccdanpian](https://github.com/ccdanpian)** on **2023-12-19**</sup> | 一位能将你的梦想变成现实的梦境艺术家。<br/>`txt-2-img` `painter` |
190
- | [NewsHub](https://chat-preview.lobehub.com/market?agent=news-hub)<br/><sup>By **[ccdanpian](https://github.com/ccdanpian)** on **2023-12-19**</sup> | 一个新闻搜索助手,擅长查找和呈现相关新闻<br/>`新闻` `搜索` `助手` |
191
- | [NewsNest](https://chat-preview.lobehub.com/market?agent=news-nest)<br/><sup>By **[ccdanpian](https://github.com/ccdanpian)** on **2023-12-19**</sup> | 一个新闻搜索助手,可以根据您的需求帮助您查找和显示相关新闻。<br/>`新闻` `搜索` |
192
-
193
- > 📊 Total agents: [<kbd>**79**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
186
+ | 最近新增 | 助手说明 |
187
+ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
188
+ | [Facebook 广告专家](https://chat-preview.lobehub.com/market?agent=facebook-ads-expert)<br/><sup>By **[alissonryan](https://github.com/alissonryan)** on **2023-12-20**</sup> | 与专家一起创建 Facebook 广告<br/>`文案撰写` `facebook广告` `潜在客户生成` |
189
+ | [梦境画家](https://chat-preview.lobehub.com/market?agent=dream-painter)<br/><sup>By **[ccdanpian](https://github.com/ccdanpian)** on **2023-12-19**</sup> | 一位能将你的梦想变成现实的梦境艺术家。<br/>`txt-2-img` `painter` |
190
+ | [新闻搜索助手](https://chat-preview.lobehub.com/market?agent=news-hub)<br/><sup>By **[ccdanpian](https://github.com/ccdanpian)** on **2023-12-19**</sup> | 新闻搜索助手,精通根据用户需求查找和呈现相关新闻。不仅能够搜索新闻,还可以根据用户的要求转变为不同领域的专家,提供精确深入的新闻解读<br/>`新闻` `搜索` `助手` |
191
+ | [研究助理](https://chat-preview.lobehub.com/market?agent=research-assistant)<br/><sup>By **[ccsen](https://github.com/ccsen)** on **2023-12-19**</sup> | 能够回答问题,进行研究,起草内容等,利用科学研究论文。<br/>`research-assistant` `literature-retrieval` `writing` `scientific-research` `citation` |
192
+
193
+ > 📊 Total agents: [<kbd>**77**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
194
194
 
195
195
  <!-- AGENT LIST -->
196
196
 
@@ -77,7 +77,7 @@
77
77
  "sr-RS": "塞爾維亞語",
78
78
  "sv-SE": "瑞典語",
79
79
  "th-TH": "泰語",
80
- "tr-TR": "土耳其",
80
+ "tr-TR": "土耳其語",
81
81
  "uk-UA": "烏克蘭語",
82
82
  "vi-VN": "越南語",
83
83
  "zh": "簡體中文",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.115.7",
3
+ "version": "0.115.9",
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,5 +1,7 @@
1
1
  import { createGatewayOnEdgeRuntime } from '@lobehub/chat-plugins-gateway';
2
2
 
3
- import { PLUGINS_INDEX_URL } from '@/const/url';
3
+ import { getServerConfig } from '@/config/server';
4
4
 
5
- export const POST = createGatewayOnEdgeRuntime({ pluginsIndexUrl: PLUGINS_INDEX_URL });
5
+ const pluginsIndexUrl = getServerConfig().PLUGINS_INDEX_URL;
6
+
7
+ export const POST = createGatewayOnEdgeRuntime({ pluginsIndexUrl });
@@ -0,0 +1,19 @@
1
+ import urlJoin from 'url-join';
2
+
3
+ import { getServerConfig } from '@/config/server';
4
+ import { DEFAULT_LANG, checkLang } from '@/const/locale';
5
+ import { Locales } from '@/locales/resources';
6
+
7
+ export class PluginStore {
8
+ private readonly baseUrl: string;
9
+
10
+ constructor(baseUrl?: string) {
11
+ this.baseUrl = baseUrl || getServerConfig().PLUGINS_INDEX_URL;
12
+ }
13
+
14
+ getPluginIndexUrl = (lang: Locales = DEFAULT_LANG) => {
15
+ if (checkLang(lang)) return this.baseUrl;
16
+
17
+ return urlJoin(this.baseUrl, `index.${lang}.json`);
18
+ };
19
+ }
@@ -0,0 +1,21 @@
1
+ import { DEFAULT_LANG } from '@/const/locale';
2
+
3
+ import { PluginStore } from './Store';
4
+
5
+ export const runtime = 'edge';
6
+
7
+ export const GET = async (req: Request) => {
8
+ const locale = new URL(req.url).searchParams.get('locale');
9
+
10
+ const pluginStore = new PluginStore();
11
+
12
+ let res: Response;
13
+
14
+ res = await fetch(pluginStore.getPluginIndexUrl(locale as any));
15
+
16
+ if (res.status === 404) {
17
+ res = await fetch(pluginStore.getPluginIndexUrl(DEFAULT_LANG));
18
+ }
19
+
20
+ return res;
21
+ };
package/src/const/url.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  import urlJoin from 'url-join';
2
2
 
3
- import { Locales } from '@/locales/resources';
4
-
5
3
  import pkg from '../../package.json';
6
- import { DEFAULT_LANG, checkLang } from './locale';
7
4
  import { INBOX_SESSION_ID } from './session';
8
5
 
9
6
  export const GITHUB = pkg.homepage;
@@ -16,12 +13,6 @@ export const DISCORD = 'https://discord.gg/AYFPHvv2jT';
16
13
 
17
14
  export const PLUGINS_INDEX_URL = 'https://chat-plugins.lobehub.com';
18
15
 
19
- export const getPluginIndexJSON = (lang: Locales = DEFAULT_LANG, baseUrl = PLUGINS_INDEX_URL) => {
20
- if (checkLang(lang)) return baseUrl;
21
-
22
- return urlJoin(baseUrl, `index.${lang}.json`);
23
- };
24
-
25
16
  export const AGENTS_INDEX_GITHUB = 'https://github.com/lobehub/lobe-chat-agents';
26
17
  export const AGENTS_INDEX_GITHUB_ISSUE = urlJoin(AGENTS_INDEX_GITHUB, 'issues/new');
27
18
 
@@ -1,7 +1,6 @@
1
1
  import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';
2
2
  import { Mock, beforeEach, describe, expect, it, vi } from 'vitest';
3
3
 
4
- import { getPluginIndexJSON } from '@/const/url';
5
4
  import { PluginModel } from '@/database/models/plugin';
6
5
  import { DB_Plugin } from '@/database/schemas/plugin';
7
6
  import { globalHelpers } from '@/store/global/helpers';
@@ -13,9 +12,7 @@ import openAPIV3 from './openai/OpenAPI_V3.json';
13
12
  import OpenAIPlugin from './openai/plugin.json';
14
13
 
15
14
  // Mocking modules and functions
16
- vi.mock('@/const/url', () => ({
17
- getPluginIndexJSON: vi.fn(),
18
- }));
15
+
19
16
  vi.mock('@/store/global/helpers', () => ({
20
17
  globalHelpers: {
21
18
  getCurrentLanguage: vi.fn(),
@@ -40,9 +37,7 @@ describe('PluginService', () => {
40
37
  it('should fetch and return the plugin list', async () => {
41
38
  // Arrange
42
39
  const fakeResponse = { plugins: [{ name: 'TestPlugin' }] };
43
- const fakeUrl = 'http://fake-url.com/plugins.json';
44
- (globalHelpers.getCurrentLanguage as Mock).mockReturnValue('en');
45
- (getPluginIndexJSON as Mock).mockReturnValue(fakeUrl);
40
+ (globalHelpers.getCurrentLanguage as Mock).mockReturnValue('tt');
46
41
  global.fetch = vi.fn(() =>
47
42
  Promise.resolve({
48
43
  json: () => Promise.resolve(fakeResponse),
@@ -54,8 +49,7 @@ describe('PluginService', () => {
54
49
 
55
50
  // Assert
56
51
  expect(globalHelpers.getCurrentLanguage).toHaveBeenCalled();
57
- expect(getPluginIndexJSON).toHaveBeenCalledWith('en');
58
- expect(fetch).toHaveBeenCalledWith(fakeUrl);
52
+ expect(fetch).toHaveBeenCalledWith('/api/plugin/store?locale=tt');
59
53
  expect(pluginList).toEqual(fakeResponse);
60
54
  });
61
55
 
@@ -63,7 +57,6 @@ describe('PluginService', () => {
63
57
  // Arrange
64
58
  const fakeUrl = 'http://fake-url.com/plugins.json';
65
59
  (globalHelpers.getCurrentLanguage as Mock).mockReturnValue('en');
66
- (getPluginIndexJSON as Mock).mockReturnValue(fakeUrl);
67
60
  global.fetch = vi.fn(() => Promise.reject(new Error('Network error')));
68
61
 
69
62
  // Act & Assert
@@ -1,7 +1,12 @@
1
1
  export const URLS = {
2
2
  config: '/api/config',
3
3
  market: '/api/market',
4
- plugins: '/api/plugins',
4
+ proxy: '/api/proxy',
5
+ };
6
+
7
+ export const PLUGINS_URLS = {
8
+ gateway: '/api/plugin/gateway',
9
+ store: '/api/plugin/store',
5
10
  };
6
11
 
7
12
  export const OPENAI_URLS = {
@@ -16,5 +21,3 @@ export const TTS_URL = {
16
21
  edge: '/api/tts/edge-speech',
17
22
  microsoft: '/api/tts/microsoft-speech',
18
23
  };
19
-
20
- export const PROXY_URL = '/api/proxy';
@@ -13,7 +13,7 @@ import { UserMessageContentPart } from '@/types/openai/chat';
13
13
  import { fetchAIFactory, getMessageError } from '@/utils/fetch';
14
14
 
15
15
  import { createHeaderWithOpenAI } from './_header';
16
- import { OPENAI_URLS, URLS } from './_url';
16
+ import { OPENAI_URLS, PLUGINS_URLS } from './_url';
17
17
 
18
18
  const isVisionModel = (model?: string) => model && VISION_MODEL_WHITE_LIST.includes(model);
19
19
 
@@ -92,7 +92,7 @@ class ChatService {
92
92
 
93
93
  const gatewayURL = manifest?.gateway;
94
94
 
95
- const res = await fetch(gatewayURL ?? URLS.plugins, {
95
+ const res = await fetch(gatewayURL ?? PLUGINS_URLS.gateway, {
96
96
  body: JSON.stringify({ ...params, manifest }),
97
97
  headers: createHeadersWithPluginSettings(settings),
98
98
  method: 'POST',
@@ -1,6 +1,6 @@
1
1
  import { FileModel } from '@/database/models/file';
2
2
  import { DB_File } from '@/database/schemas/files';
3
- import { PROXY_URL } from '@/services/_url';
3
+ import { URLS } from '@/services/_url';
4
4
  import { FilePreview } from '@/types/files';
5
5
  import compressImage from '@/utils/compressImage';
6
6
 
@@ -43,7 +43,7 @@ class FileService {
43
43
  }
44
44
 
45
45
  async uploadImageByUrl(url: string, file: Pick<DB_File, 'name' | 'metadata'>) {
46
- const res = await fetch(PROXY_URL, { body: url, method: 'POST' });
46
+ const res = await fetch(URLS.proxy, { body: url, method: 'POST' });
47
47
  const data = await res.arrayBuffer();
48
48
  const fileType = res.headers.get('content-type') || 'image/webp';
49
49
 
@@ -4,9 +4,8 @@ import {
4
4
  pluginManifestSchema,
5
5
  } from '@lobehub/chat-plugin-sdk';
6
6
 
7
- import { getPluginIndexJSON } from '@/const/url';
8
7
  import { PluginModel } from '@/database/models/plugin';
9
- import { PROXY_URL } from '@/services/_url';
8
+ import { PLUGINS_URLS, URLS } from '@/services/_url';
10
9
  import { globalHelpers } from '@/store/global/helpers';
11
10
  import { OpenAIPluginManifest } from '@/types/openai/plugin';
12
11
  import { LobeTool } from '@/types/tool';
@@ -22,7 +21,7 @@ class PluginService {
22
21
  // 2. 发送请求
23
22
  let res: Response;
24
23
  try {
25
- res = await (proxy ? fetch(PROXY_URL, { body: url, method: 'POST' }) : fetch(url));
24
+ res = await (proxy ? fetch(URLS.proxy, { body: url, method: 'POST' }) : fetch(url));
26
25
  } catch {
27
26
  throw new TypeError('fetchError');
28
27
  }
@@ -52,14 +51,12 @@ class PluginService {
52
51
  /**
53
52
  * get plugin list from store
54
53
  */
55
- getPluginList = async () => {
56
- const url = getPluginIndexJSON(globalHelpers.getCurrentLanguage());
54
+ getPluginList = async (): Promise<LobeChatPluginsMarketIndex> => {
55
+ const locale = globalHelpers.getCurrentLanguage();
57
56
 
58
- const res = await fetch(url);
57
+ const res = await fetch(`${PLUGINS_URLS.store}?locale=${locale}`);
59
58
 
60
- const data: LobeChatPluginsMarketIndex = await res.json();
61
-
62
- return data;
59
+ return res.json();
63
60
  };
64
61
 
65
62
  getPluginManifest = async (
@@ -94,6 +94,48 @@ describe('settingsSelectors', () => {
94
94
  expect(result).toMatchSnapshot();
95
95
  });
96
96
 
97
+ it('should delete model', () => {
98
+ const s = {
99
+ serverConfig: {
100
+ customModelName: '-gpt-4',
101
+ },
102
+ settings: {
103
+ languageModel: {
104
+ openAI: {},
105
+ },
106
+ },
107
+ } as unknown as GlobalStore;
108
+
109
+ const result = settingsSelectors.modelList(s);
110
+
111
+ expect(result).toEqual([
112
+ {
113
+ displayName: 'gpt-3.5-turbo',
114
+ name: 'gpt-3.5-turbo',
115
+ },
116
+ {
117
+ displayName: 'gpt-3.5-turbo-1106',
118
+ name: 'gpt-3.5-turbo-1106',
119
+ },
120
+ {
121
+ displayName: 'gpt-3.5-turbo-16k',
122
+ name: 'gpt-3.5-turbo-16k',
123
+ },
124
+ {
125
+ displayName: 'gpt-4-32k',
126
+ name: 'gpt-4-32k',
127
+ },
128
+ {
129
+ displayName: 'gpt-4-1106-preview',
130
+ name: 'gpt-4-1106-preview',
131
+ },
132
+ {
133
+ displayName: 'gpt-4-vision-preview',
134
+ name: 'gpt-4-vision-preview',
135
+ },
136
+ ]);
137
+ });
138
+
97
139
  it('only add the model', () => {
98
140
  const s = {
99
141
  serverConfig: {},
@@ -31,6 +31,7 @@ const openAIProxyUrlSelectors = (s: GlobalStore) => s.settings.languageModel.ope
31
31
  const modelListSelectors = (s: GlobalStore) => {
32
32
  let models: CustomModels = [];
33
33
 
34
+ const removedModels: string[] = [];
34
35
  const modelNames = [
35
36
  ...DEFAULT_OPENAI_MODEL_LIST,
36
37
  ...(s.serverConfig.customModelName || '').split(/[,,]/).filter(Boolean),
@@ -47,6 +48,7 @@ const modelListSelectors = (s: GlobalStore) => {
47
48
  if (name === 'all') {
48
49
  models = [];
49
50
  }
51
+ removedModels.push(name);
50
52
  continue;
51
53
  }
52
54
 
@@ -62,7 +64,7 @@ const modelListSelectors = (s: GlobalStore) => {
62
64
  });
63
65
  }
64
66
 
65
- return models;
67
+ return models.filter((m) => !removedModels.includes(m.name));
66
68
  };
67
69
 
68
70
  export const exportSettings = (s: GlobalStore) => {