diff --git a/packages/service/core/ai/config.ts b/packages/service/core/ai/config.ts index 3662b1fa3..bc9832639 100644 --- a/packages/service/core/ai/config.ts +++ b/packages/service/core/ai/config.ts @@ -2,9 +2,6 @@ import type { UserModelSchema } from '@fastgpt/global/support/user/type'; import OpenAI from '@fastgpt/global/core/ai'; export const openaiBaseUrl = process.env.OPENAI_BASE_URL || 'https://api.openai.com/v1'; -export const baseUrl = global?.systemEnv?.oneapiUrl || process.env.ONEAPI_URL || openaiBaseUrl; - -export const systemAIChatKey = global?.systemEnv?.chatApiKey || process.env.CHAT_API_KEY || ''; export const getAIApi = (props?: { userKey?: UserModelSchema['openaiAccount']; @@ -12,9 +9,13 @@ export const getAIApi = (props?: { }) => { const { userKey, timeout } = props || {}; + const baseUrl = + userKey?.baseUrl || global?.systemEnv?.oneapiUrl || process.env.ONEAPI_URL || openaiBaseUrl; + const apiKey = userKey?.key || global?.systemEnv?.chatApiKey || process.env.CHAT_API_KEY || ''; + return new OpenAI({ - apiKey: userKey?.key || systemAIChatKey, - baseURL: userKey?.baseUrl || baseUrl, + baseURL: baseUrl, + apiKey, httpAgent: global.httpsAgent, timeout, maxRetries: 2 diff --git a/projects/app/src/pages/chat/components/ChatHistorySlider.tsx b/projects/app/src/pages/chat/components/ChatHistorySlider.tsx index 2aab07bd5..6a3e72ff2 100644 --- a/projects/app/src/pages/chat/components/ChatHistorySlider.tsx +++ b/projects/app/src/pages/chat/components/ChatHistorySlider.tsx @@ -304,6 +304,7 @@ const ChatHistorySlider = ({ onClick: () => { router.replace({ query: { + ...router.query, appId: item._id } }); diff --git a/projects/app/src/service/moduleDispatch/tools/http468.ts b/projects/app/src/service/moduleDispatch/tools/http468.ts index f20630be6..bc9cd865b 100644 --- a/projects/app/src/service/moduleDispatch/tools/http468.ts +++ b/projects/app/src/service/moduleDispatch/tools/http468.ts @@ -61,7 +61,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise { - item.key = replaceVariable(item.key, concatVariables); - item.value = replaceVariable(item.value, concatVariables); - // @ts-ignore - acc[item.key] = valueTypeFormat(item.value, 'string'); + return httpHeader.reduce((acc: Record, item) => { + const key = replaceVariable(item.key, concatVariables); + const value = replaceVariable(item.value, concatVariables); + acc[key] = valueTypeFormat(value, 'string'); return acc; }, {}); } catch (error) { return Promise.reject('Header 为非法 JSON 格式'); } })(); - const params = httpParams.reduce((acc, item) => { - item.key = replaceVariable(item.key, concatVariables); - item.value = replaceVariable(item.value, concatVariables); - // @ts-ignore - acc[item.key] = valueTypeFormat(item.value, 'string'); + const params = httpParams.reduce((acc: Record, item) => { + const key = replaceVariable(item.key, concatVariables); + const value = replaceVariable(item.value, concatVariables); + acc[key] = valueTypeFormat(value, 'string'); return acc; }, {}); const requestBody = await (() => { @@ -101,7 +99,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise