@lobehub/chat 0.126.0 → 0.126.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.126.1](https://github.com/lobehub/lobe-chat/compare/v0.126.0...v0.126.1)
6
+
7
+ <sup>Released on **2024-02-09**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Add basePath to support subdirectory.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Add basePath to support subdirectory, closes [#1179](https://github.com/lobehub/lobe-chat/issues/1179) ([43e544a](https://github.com/lobehub/lobe-chat/commit/43e544a))
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
+
5
30
  ## [Version 0.126.0](https://github.com/lobehub/lobe-chat/compare/v0.125.0...v0.126.0)
6
31
 
7
32
  <sup>Released on **2024-02-09**</sup>
package/README.md CHANGED
@@ -225,14 +225,14 @@ Our marketplace is not just a showcase platform but also a collaborative space.
225
225
 
226
226
  <!-- AGENT LIST -->
227
227
 
228
- | Recent Submits | Description |
229
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
230
- | [Jira Story Facilitator](https://chat-preview.lobehub.com/market?agent=jira-product-manager)<br/><sup>By **[emad-pg](https://github.com/emad-pg)** on **2024-02-07**</sup> | A Product manager agent that is specialised in transforming feature ideas into comprehensive Jira stories drafts for your team to pick up.<br/>`product-management` `story-creation` `jira` |
231
- | [Text Variator](https://chat-preview.lobehub.com/market?agent=text-variator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-07**</sup> | Please provide the text you would like me to generate different versions of<br/>`copywriting` `editing` `creative-writing` |
232
- | [Turkish/English Translator](https://chat-preview.lobehub.com/market?agent=turkish-english-translator)<br/><sup>By **[Zisan-uzum](https://github.com/Zisan-uzum)** on **2024-02-07**</sup> | Translates text into Turkish or English, as needed<br/>`turkish` `english` `translation` `writing` |
233
- | [CAN: Code Master](https://chat-preview.lobehub.com/market?agent=can)<br/><sup>By **[MrHuangJser](https://github.com/MrHuangJser)** on **2024-02-06**</sup> | CAN: Professional coding expert with years of experience and no character limit. Provides entrepreneurial services such as creative naming, slogans, user profiles, pain points, value propositions, sales channels, revenue streams, and cost structures.<br/>`coding` `communication` `questioning` |
234
-
235
- > 📊 Total agents: [<kbd>**159**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
228
+ | Recent Submits | Description |
229
+ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
230
+ | [Cloze Exercise Generator](https://chat-preview.lobehub.com/market?agent=cloze-exercise-generator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-08**</sup> | Specializes in generating summary cloze exercises. Please provide the theme of the paragraph.<br/>`summary` `exercise` `generator` `writing` `education` |
231
+ | [Reading Comprehension Wizard](https://chat-preview.lobehub.com/market?agent=reading-comprehension-exercise-generator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-08**</sup> | Specializes in generating reading comprehension exercises<br/>`reading-comprehension` `exercise-generation` `education` |
232
+ | [Thematic Vocabulary Worksheet Creator](https://chat-preview.lobehub.com/market?agent=thematic-vocabulary-worksheet-generator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-08**</sup> | Skilled in creating English thematic vocabulary worksheets<br/>`writing` `language-learning` `teaching` `assessment` `educational-resources` |
233
+ | [Vocabulary Worksheet Wizard](https://chat-preview.lobehub.com/market?agent=vocabulary-worksheet-wizard)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-08**</sup> | Specializes in generating English vocabulary worksheets<br/>`vocabulary` `worksheet` `education` `language-learning` |
234
+
235
+ > 📊 Total agents: [<kbd>**164**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
236
236
 
237
237
  <!-- AGENT LIST -->
238
238
 
package/README.zh-CN.md CHANGED
@@ -205,14 +205,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
205
205
 
206
206
  <!-- AGENT LIST -->
207
207
 
208
- | 最近新增 | 助手说明 |
209
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
210
- | [Jira 故事协助工具](https://chat-preview.lobehub.com/market?agent=jira-product-manager)<br/><sup>By **[emad-pg](https://github.com/emad-pg)** on **2024-02-07**</sup> | 一款专门将功能点子转化为全面的 Jira 故事草稿,供团队选择的产品经理代理。<br/>`产品管理` `故事创建` `jira` |
211
- | [文本变体生成器](https://chat-preview.lobehub.com/market?agent=text-variator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-07**</sup> | 请提供您希望我生成不同版本的文本<br/>`文案撰写` `编辑` `创意写作` |
212
- | [土耳其语 / 英语翻译器](https://chat-preview.lobehub.com/market?agent=turkish-english-translator)<br/><sup>By **[Zisan-uzum](https://github.com/Zisan-uzum)** on **2024-02-07**</sup> | 根据需要将文本翻译成土耳其语或英语<br/>`土耳其语` `英语` `翻译` `写作` |
213
- | [CAN: 编程大师](https://chat-preview.lobehub.com/market?agent=can)<br/><sup>By **[MrHuangJser](https://github.com/MrHuangJser)** on **2024-02-06**</sup> | CAN: 专业编程专家,多年经验,无字符限制。提供创意命名、标语、用户画像、痛点、价值主张、销售渠道、收入流、成本结构等创业计划服务。<br/>`编程` `交流` `提问` |
214
-
215
- > 📊 Total agents: [<kbd>**159**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
208
+ | 最近新增 | 助手说明 |
209
+ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
210
+ | [填空练习生成器](https://chat-preview.lobehub.com/market?agent=cloze-exercise-generator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-08**</sup> | 专门用于生成摘要填空练习。请提供段落的主题。<br/>`摘要` `练习` `生成器` `写作` `教育` |
211
+ | [阅读理解向导](https://chat-preview.lobehub.com/market?agent=reading-comprehension-exercise-generator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-08**</sup> | 专门生成阅读理解练习<br/>`阅读理解` `练习生成` `教育` |
212
+ | [主题词汇工作表创建器](https://chat-preview.lobehub.com/market?agent=thematic-vocabulary-worksheet-generator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-08**</sup> | 擅长创建英语主题词汇工作表<br/>`写作` `语言学习` `教学` `评估` `教育资源` |
213
+ | [词汇工作表向导](https://chat-preview.lobehub.com/market?agent=vocabulary-worksheet-wizard)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-08**</sup> | 专注于生成英语词汇工作表<br/>`词汇` `工作表` `教育` `语言学习` |
214
+
215
+ > 📊 Total agents: [<kbd>**164**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
216
216
 
217
217
  <!-- AGENT LIST -->
218
218
 
@@ -7,6 +7,7 @@ LobeChat provides additional configuration options during deployment, which can
7
7
  - [General Variables](#general-variables)
8
8
  - [`ACCESS_CODE`](#access_code)
9
9
  - [`ENABLE_OAUTH_SSO`](#enable_oauth_sso)
10
+ - [`NEXT_PUBLIC_BASE_PATH`](#next_public_base_path)
10
11
  - [Authentication Service Providers](#authentication-service-providers)
11
12
  - [Common Settings](#common-settings)
12
13
  - [Auth0](#auth0)
@@ -41,7 +42,14 @@ LobeChat provides additional configuration options during deployment, which can
41
42
  - Type: Optional
42
43
  - Description: Enable OAuth single sign-on (SSO) for LobeChat. Set to `1` to enable OAuth SSO. See [Authentication Service Providers](#authentication-service-providers) for more details.
43
44
  - Default: `-`
44
- - Example: `1` or `0`
45
+ - Example: `1`
46
+
47
+ ### `NEXT_PUBLIC_BASE_PATH`
48
+
49
+ - Type:Optional
50
+ - Description:add `basePath` for LobeChat
51
+ - Default: `-`
52
+ - Example: `/test`
45
53
 
46
54
  ## Authentication Service Providers
47
55
 
@@ -7,6 +7,7 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
7
7
  - [通用变量](#通用变量)
8
8
  - [`ACCESS_CODE`](#access_code)
9
9
  - [`ENABLE_OAUTH_SSO`](#enable_oauth_sso)
10
+ - [`NEXT_PUBLIC_BASE_PATH`](#next_public_base_path)
10
11
  - [身份验证服务](#身份验证服务)
11
12
  - [通用设置](#通用设置)
12
13
  - [Auth0](#auth0)
@@ -41,7 +42,14 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
41
42
  - 类型:可选
42
43
  - 描述:为 LobeChat 启用单点登录 (SSO)。设置为 `1` 以启用单点登录。有关详细信息,请参阅[身份验证服务](#身份验证服务)。
43
44
  - 默认值: `-`
44
- - 示例: `1` 或 `0`
45
+ - 示例: `1`
46
+
47
+ ### `NEXT_PUBLIC_BASE_PATH`
48
+
49
+ - 类型:可选
50
+ - 描述:为 LobeChat 添加 `basePath`
51
+ - 默认值: `-`
52
+ - 示例: `/test`
45
53
 
46
54
  ## 身份验证服务
47
55
 
package/next.config.mjs CHANGED
@@ -7,6 +7,8 @@ const buildWithDocker = process.env.DOCKER === 'true';
7
7
  // if you need to proxy the api endpoint to remote server
8
8
  const API_PROXY_ENDPOINT = process.env.API_PROXY_ENDPOINT || '';
9
9
 
10
+ const basePath = process.env.NEXT_PUBLIC_BASE_PATH;
11
+
10
12
  const withBundleAnalyzer = analyzer({
11
13
  enabled: process.env.ANALYZE === 'true',
12
14
  });
@@ -22,6 +24,7 @@ const withPWA = nextPWA({
22
24
  /** @type {import('next').NextConfig} */
23
25
  const nextConfig = {
24
26
  compress: isProd,
27
+ basePath,
25
28
  experimental: {
26
29
  optimizePackageImports: [
27
30
  'emoji-mart',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.126.0",
3
+ "version": "0.126.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",
@@ -1,11 +1,13 @@
1
1
  import { createStyles } from 'antd-style';
2
2
 
3
+ import { imageUrl } from '@/const/url';
4
+
3
5
  export const useStyles = createStyles(({ css, token, stylish, cx }, withBackground: boolean) => ({
4
6
  background: css`
5
7
  padding: 24px;
6
8
 
7
9
  background-color: ${token.colorBgLayout};
8
- background-image: url('/images/screenshot_background.webp');
10
+ background-image: url(${imageUrl('screenshot_background.webp')});
9
11
  background-position: center;
10
12
  background-size: 120% 120%;
11
13
  `,
@@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next';
6
6
  import { Flexbox } from 'react-layout-kit';
7
7
  import { Virtuoso, VirtuosoHandle } from 'react-virtuoso';
8
8
 
9
+ import { imageUrl } from '@/const/url';
9
10
  import { useChatStore } from '@/store/chat';
10
11
  import { topicSelectors } from '@/store/chat/selectors';
11
12
  import { useGlobalStore } from '@/store/global';
@@ -60,7 +61,7 @@ export const Topic = memo(() => {
60
61
  <Flexbox flex={1}>
61
62
  <EmptyCard
62
63
  alt={t('topic.guide.desc')}
63
- cover={`/images/empty_topic_${isDarkMode ? 'dark' : 'light'}.webp`}
64
+ cover={imageUrl(`empty_topic_${isDarkMode ? 'dark' : 'light'}.webp`)}
64
65
  desc={t('topic.guide.desc')}
65
66
  height={120}
66
67
  onVisibleChange={(visible) => {
@@ -5,7 +5,7 @@ import Image from 'next/image';
5
5
  import { memo } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
 
8
- import { AGENTS_INDEX_GITHUB } from '@/const/url';
8
+ import { AGENTS_INDEX_GITHUB, imageUrl } from '@/const/url';
9
9
 
10
10
  const Inner = memo(() => {
11
11
  const { t } = useTranslation('market');
@@ -14,7 +14,7 @@ const Inner = memo(() => {
14
14
  <Image
15
15
  alt={'banner'}
16
16
  height={602}
17
- src={'/images/banner_market_modal.webp'}
17
+ src={imageUrl('banner_market_modal.webp')}
18
18
  style={{ height: 'auto', marginBottom: 24, width: '100%' }}
19
19
  width={1602}
20
20
  />
@@ -1,5 +1,6 @@
1
1
  import { Metadata } from 'next';
2
2
 
3
+ import { getClientConfig } from '@/config/client';
3
4
  import { getServerConfig } from '@/config/server';
4
5
 
5
6
  import pkg from '../../package.json';
@@ -8,6 +9,10 @@ const title = 'LobeChat';
8
9
  const { description, homepage } = pkg;
9
10
 
10
11
  const { METADATA_BASE_URL = 'https://chat-preview.lobehub.com/' } = getServerConfig();
12
+ const { BASE_PATH } = getClientConfig();
13
+
14
+ // if there is a base path, then we don't need the manifest
15
+ const noManifest = !!BASE_PATH;
11
16
 
12
17
  const metadata: Metadata = {
13
18
  appleWebApp: {
@@ -22,7 +27,7 @@ const metadata: Metadata = {
22
27
  shortcut:
23
28
  'https://registry.npmmirror.com/@lobehub/assets-favicons/latest/files/assets/favicon.ico',
24
29
  },
25
- manifest: '/manifest.json',
30
+ manifest: noManifest ? undefined : '/manifest.json',
26
31
  metadataBase: new URL(METADATA_BASE_URL),
27
32
  openGraph: {
28
33
  description: description,
@@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next';
8
8
 
9
9
  import { FORM_STYLE } from '@/const/layoutTokens';
10
10
  import { DEFAULT_SETTINGS } from '@/const/settings';
11
+ import { imageUrl } from '@/const/url';
11
12
  import AvatarWithUpload from '@/features/AvatarWithUpload';
12
13
  import { localeOptions } from '@/locales/resources';
13
14
  import { useChatStore } from '@/store/chat';
@@ -118,19 +119,19 @@ const Common = memo<SettingsCommonProps>(({ showAccessCodeConfig, showOAuthLogin
118
119
  options={[
119
120
  {
120
121
  icon: Sun,
121
- img: '/images/theme_light.webp',
122
+ img: imageUrl('theme_light.webp'),
122
123
  label: t('settingTheme.themeMode.light'),
123
124
  value: 'light',
124
125
  },
125
126
  {
126
127
  icon: Moon,
127
- img: '/images/theme_dark.webp',
128
+ img: imageUrl('theme_dark.webp'),
128
129
  label: t('settingTheme.themeMode.dark'),
129
130
  value: 'dark',
130
131
  },
131
132
  {
132
133
  icon: Monitor,
133
- img: '/images/theme_auto.webp',
134
+ img: imageUrl('theme_auto.webp'),
134
135
  label: t('settingTheme.themeMode.auto'),
135
136
  value: 'auto',
136
137
  },
@@ -38,6 +38,7 @@ declare global {
38
38
  }
39
39
 
40
40
  export const getClientConfig = () => ({
41
+ BASE_PATH: process.env.NEXT_PUBLIC_BASE_PATH || '',
41
42
  // Vercel Analytics
42
43
  ANALYTICS_VERCEL: process.env.NEXT_PUBLIC_ANALYTICS_VERCEL === '1',
43
44
  VERCEL_DEBUG: process.env.NEXT_PUBLIC_VERCEL_DEBUG === '1',
package/src/const/url.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import urlJoin from 'url-join';
2
2
 
3
+ import { withBasePath } from '@/utils/basePath';
4
+
3
5
  import pkg from '../../package.json';
4
6
  import { INBOX_SESSION_ID } from './session';
5
7
 
@@ -19,3 +21,5 @@ export const AGENTS_INDEX_GITHUB_ISSUE = urlJoin(AGENTS_INDEX_GITHUB, 'issues/ne
19
21
  export const SESSION_CHAT_URL = (id: string = INBOX_SESSION_ID, mobile?: boolean) =>
20
22
  mobile ? `/chat/mobile?session=${id}` : `/chat?session=${id}`;
21
23
  export const MANUAL_UPGRADE_URL = 'https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync';
24
+
25
+ export const imageUrl = (filename: string) => withBasePath(`/images/${filename}`);
@@ -7,6 +7,7 @@ import { memo, useMemo } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
 
9
9
  import { FORM_STYLE } from '@/const/layoutTokens';
10
+ import { imageUrl } from '@/const/url';
10
11
 
11
12
  import { useStore } from '../store';
12
13
  import ModelSelect from './ModelSelect';
@@ -46,13 +47,13 @@ const AgentConfig = memo(() => {
46
47
  options={[
47
48
  {
48
49
  icon: MessagesSquare,
49
- img: `/images/chatmode_chat_${isDarkMode ? 'dark' : 'light'}.webp`,
50
+ img: imageUrl(`chatmode_chat_${isDarkMode ? 'dark' : 'light'}.webp`),
50
51
  label: t('settingChat.chatStyleType.type.chat'),
51
52
  value: 'chat',
52
53
  },
53
54
  {
54
55
  icon: LayoutList,
55
- img: `/images/chatmode_docs_${isDarkMode ? 'dark' : 'light'}.webp`,
56
+ img: imageUrl(`chatmode_docs_${isDarkMode ? 'dark' : 'light'}.webp`),
56
57
  label: t('settingChat.chatStyleType.type.docs'),
57
58
  value: 'docs',
58
59
  },
@@ -9,7 +9,7 @@ import isEqual from 'fast-deep-equal';
9
9
  import { SWRConfiguration } from 'swr';
10
10
 
11
11
  import { createHeaderWithOpenAI } from '@/services/_header';
12
- import { OPENAI_URLS } from '@/services/_url';
12
+ import { API_ENDPOINTS } from '@/services/_url';
13
13
  import { useGlobalStore } from '@/store/global';
14
14
  import { settingsSelectors } from '@/store/global/selectors';
15
15
  import { useSessionStore } from '@/store/session';
@@ -39,7 +39,7 @@ export const useSTT = (config: STTConfig) => {
39
39
  options = {
40
40
  api: {
41
41
  headers: createHeaderWithOpenAI(),
42
- serviceUrl: OPENAI_URLS.stt,
42
+ serviceUrl: API_ENDPOINTS.stt,
43
43
  },
44
44
  autoStop,
45
45
  options: {
@@ -10,7 +10,7 @@ import {
10
10
  import isEqual from 'fast-deep-equal';
11
11
 
12
12
  import { createHeaderWithOpenAI } from '@/services/_header';
13
- import { OPENAI_URLS, TTS_URL } from '@/services/_url';
13
+ import { API_ENDPOINTS } from '@/services/_url';
14
14
  import { useGlobalStore } from '@/store/global';
15
15
  import { settingsSelectors } from '@/store/global/selectors';
16
16
  import { useSessionStore } from '@/store/session';
@@ -36,7 +36,7 @@ export const useTTS = (content: string, config?: TTSConfig) => {
36
36
  options = {
37
37
  api: {
38
38
  headers: createHeaderWithOpenAI(),
39
- serviceUrl: OPENAI_URLS.tts,
39
+ serviceUrl: API_ENDPOINTS.tts,
40
40
  },
41
41
  options: {
42
42
  model: ttsSettings.openAI.ttsModel,
@@ -64,7 +64,7 @@ export const useTTS = (content: string, config?: TTSConfig) => {
64
64
  useSelectedTTS = useMicrosoftSpeech;
65
65
  options = {
66
66
  api: {
67
- serviceUrl: TTS_URL.microsoft,
67
+ serviceUrl: API_ENDPOINTS.microsoft,
68
68
  },
69
69
  options: {
70
70
  voice: config?.voice || voice,
@@ -1,21 +1,39 @@
1
- export const URLS = {
1
+ /* eslint-disable sort-keys-fix/sort-keys-fix */
2
+ import { transform } from 'lodash-es';
3
+
4
+ import { withBasePath } from '@/utils/basePath';
5
+
6
+ const mapWithBasePath = <T extends object>(apis: T): T => {
7
+ return transform(apis, (result, value, key) => {
8
+ if (typeof value === 'string') {
9
+ // @ts-ignore
10
+ result[key] = withBasePath(value);
11
+ } else {
12
+ result[key] = value;
13
+ }
14
+ });
15
+ };
16
+
17
+ export const API_ENDPOINTS = mapWithBasePath({
2
18
  config: '/api/config',
3
- market: '/api/market',
4
19
  proxy: '/api/proxy',
5
- };
6
20
 
7
- export const PLUGINS_URLS = {
21
+ // agent markets
22
+ market: '/api/market',
23
+
24
+ // plugins
8
25
  gateway: '/api/plugin/gateway',
9
- store: '/api/plugin/store',
10
- };
26
+ pluginStore: '/api/plugin/store',
11
27
 
12
- export const OPENAI_URLS = {
28
+ // chat
29
+ chat: (provider: string) => withBasePath(`/api/chat/${provider}`),
30
+
31
+ // image
13
32
  images: '/api/openai/images',
33
+
34
+ // TTS & STT
14
35
  stt: '/api/openai/stt',
15
36
  tts: '/api/openai/tts',
16
- };
17
-
18
- export const TTS_URL = {
19
37
  edge: '/api/tts/edge-speech',
20
38
  microsoft: '/api/tts/microsoft-speech',
21
- };
39
+ });
@@ -16,7 +16,7 @@ import { fetchAIFactory, getMessageError } from '@/utils/fetch';
16
16
 
17
17
  import { createHeaderWithAuth } from './_auth';
18
18
  import { createHeaderWithOpenAI } from './_header';
19
- import { PLUGINS_URLS } from './_url';
19
+ import { API_ENDPOINTS } from './_url';
20
20
 
21
21
  interface FetchOptions {
22
22
  signal?: AbortSignal | undefined;
@@ -81,7 +81,7 @@ class ChatService {
81
81
  provider,
82
82
  });
83
83
 
84
- return fetch(`/api/chat/${provider}`, {
84
+ return fetch(API_ENDPOINTS.chat(provider), {
85
85
  body: JSON.stringify(payload),
86
86
  headers,
87
87
  method: 'POST',
@@ -102,7 +102,7 @@ class ChatService {
102
102
 
103
103
  const gatewayURL = manifest?.gateway;
104
104
 
105
- const res = await fetch(gatewayURL ?? PLUGINS_URLS.gateway, {
105
+ const res = await fetch(gatewayURL ?? API_ENDPOINTS.gateway, {
106
106
  body: JSON.stringify({ ...params, manifest }),
107
107
  // TODO: we can have a better auth way
108
108
  headers: createHeadersWithPluginSettings(settings, createHeaderWithOpenAI()),
@@ -1,9 +1,10 @@
1
1
  import { FileModel } from '@/database/models/file';
2
2
  import { DB_File } from '@/database/schemas/files';
3
- import { URLS } from '@/services/_url';
4
3
  import { FilePreview } from '@/types/files';
5
4
  import compressImage from '@/utils/compressImage';
6
5
 
6
+ import { API_ENDPOINTS } from './_url';
7
+
7
8
  class FileService {
8
9
  private isImage(fileType: string) {
9
10
  const imageRegex = /^image\//;
@@ -43,7 +44,7 @@ class FileService {
43
44
  }
44
45
 
45
46
  async uploadImageByUrl(url: string, file: Pick<DB_File, 'name' | 'metadata'>) {
46
- const res = await fetch(URLS.proxy, { body: url, method: 'POST' });
47
+ const res = await fetch(API_ENDPOINTS.proxy, { body: url, method: 'POST' });
47
48
  const data = await res.arrayBuffer();
48
49
  const fileType = res.headers.get('content-type') || 'image/webp';
49
50
 
@@ -1,6 +1,7 @@
1
- import { URLS } from '@/services/_url';
2
1
  import { GlobalServerConfig } from '@/types/settings';
3
2
 
3
+ import { API_ENDPOINTS } from './_url';
4
+
4
5
  const VERSION_URL = 'https://registry.npmmirror.com/@lobehub/chat';
5
6
 
6
7
  class GlobalService {
@@ -15,7 +16,7 @@ class GlobalService {
15
16
  };
16
17
 
17
18
  getGlobalConfig = async (): Promise<GlobalServerConfig> => {
18
- const res = await fetch(URLS.config);
19
+ const res = await fetch(API_ENDPOINTS.config);
19
20
 
20
21
  return res.json();
21
22
  };
@@ -1,7 +1,8 @@
1
1
  import { createHeaderWithOpenAI } from '@/services/_header';
2
- import { OPENAI_URLS } from '@/services/_url';
3
2
  import { OpenAIImagePayload } from '@/types/openai/image';
4
3
 
4
+ import { API_ENDPOINTS } from './_url';
5
+
5
6
  interface FetchOptions {
6
7
  signal?: AbortSignal | undefined;
7
8
  }
@@ -10,7 +11,7 @@ class ImageGenerationService {
10
11
  async generateImage(params: Omit<OpenAIImagePayload, 'model' | 'n'>, options?: FetchOptions) {
11
12
  const payload: OpenAIImagePayload = { ...params, model: 'dall-e-3', n: 1 };
12
13
 
13
- const res = await fetch(OPENAI_URLS.images, {
14
+ const res = await fetch(API_ENDPOINTS.images, {
14
15
  body: JSON.stringify(payload),
15
16
  headers: createHeaderWithOpenAI({ 'Content-Type': 'application/json' }),
16
17
  method: 'POST',
@@ -1,9 +1,10 @@
1
- import { URLS } from '@/services/_url';
2
1
  import { LobeChatAgentsMarketIndex } from '@/types/market';
3
2
 
3
+ import { API_ENDPOINTS } from './_url';
4
+
4
5
  class MarketService {
5
6
  getAgentList = async (locale: string): Promise<LobeChatAgentsMarketIndex> => {
6
- const res = await fetch(`${URLS.market}?locale=${locale}`);
7
+ const res = await fetch(`${API_ENDPOINTS.market}?locale=${locale}`);
7
8
 
8
9
  return res.json();
9
10
  };
@@ -13,7 +14,7 @@ class MarketService {
13
14
  */
14
15
  getAgentManifest = async (identifier: string, locale: string) => {
15
16
  if (!identifier) return;
16
- const res = await fetch(`${URLS.market}/${identifier}?locale=${locale}`);
17
+ const res = await fetch(`${API_ENDPOINTS.market}/${identifier}?locale=${locale}`);
17
18
 
18
19
  return res.json();
19
20
  };
@@ -5,12 +5,13 @@ import {
5
5
  } from '@lobehub/chat-plugin-sdk';
6
6
 
7
7
  import { PluginModel } from '@/database/models/plugin';
8
- import { PLUGINS_URLS, URLS } from '@/services/_url';
9
8
  import { globalHelpers } from '@/store/global/helpers';
10
9
  import { OpenAIPluginManifest } from '@/types/openai/plugin';
11
10
  import { LobeTool } from '@/types/tool';
12
11
  import { LobeToolCustomPlugin } from '@/types/tool/plugin';
13
12
 
13
+ import { API_ENDPOINTS } from './_url';
14
+
14
15
  export interface InstallPluginParams {
15
16
  identifier: string;
16
17
  manifest: LobeChatPluginManifest;
@@ -21,7 +22,7 @@ class PluginService {
21
22
  // 2. 发送请求
22
23
  let res: Response;
23
24
  try {
24
- res = await (proxy ? fetch(URLS.proxy, { body: url, method: 'POST' }) : fetch(url));
25
+ res = await (proxy ? fetch(API_ENDPOINTS.proxy, { body: url, method: 'POST' }) : fetch(url));
25
26
  } catch {
26
27
  throw new TypeError('fetchError');
27
28
  }
@@ -54,7 +55,7 @@ class PluginService {
54
55
  getPluginList = async (): Promise<LobeChatPluginsMarketIndex> => {
55
56
  const locale = globalHelpers.getCurrentLanguage();
56
57
 
57
- const res = await fetch(`${PLUGINS_URLS.store}?locale=${locale}`);
58
+ const res = await fetch(`${API_ENDPOINTS.pluginStore}?locale=${locale}`);
58
59
 
59
60
  return res.json();
60
61
  };
@@ -112,9 +112,6 @@ export const chatPlugin: StateCreator<
112
112
 
113
113
  invokeStandaloneTypePlugin: async (id, payload) => {
114
114
  const result = await useToolStore.getState().validatePluginSettings(payload.identifier);
115
- console.log('------------------');
116
- console.log(result);
117
- console.log('------------------');
118
115
  if (!result) return;
119
116
 
120
117
  // if the plugin settings is not valid, then set the message with error type
@@ -0,0 +1,3 @@
1
+ import { getClientConfig } from '@/config/client';
2
+
3
+ export const withBasePath = (path: string) => getClientConfig().BASE_PATH + path;