修复4.6.9问题 (#976)

* Fixbranch (#43)

* move components to web package (#37)

* move components

* fix

* openapi config

* fix team share bug

---------

Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
Co-authored-by: archer <545436317@qq.com>

* fix: http variable and ai base url

* remove log

---------

Co-authored-by: yst <77910600+yu-and-liu@users.noreply.github.com>
Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
This commit is contained in:
Archer 2024-03-11 20:12:55 +08:00 committed by GitHub
parent 64492b8b33
commit 753b164ea2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 17 deletions

View File

@ -2,9 +2,6 @@ import type { UserModelSchema } from '@fastgpt/global/support/user/type';
import OpenAI from '@fastgpt/global/core/ai'; import OpenAI from '@fastgpt/global/core/ai';
export const openaiBaseUrl = process.env.OPENAI_BASE_URL || 'https://api.openai.com/v1'; 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?: { export const getAIApi = (props?: {
userKey?: UserModelSchema['openaiAccount']; userKey?: UserModelSchema['openaiAccount'];
@ -12,9 +9,13 @@ export const getAIApi = (props?: {
}) => { }) => {
const { userKey, timeout } = 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({ return new OpenAI({
apiKey: userKey?.key || systemAIChatKey, baseURL: baseUrl,
baseURL: userKey?.baseUrl || baseUrl, apiKey,
httpAgent: global.httpsAgent, httpAgent: global.httpsAgent,
timeout, timeout,
maxRetries: 2 maxRetries: 2

View File

@ -304,6 +304,7 @@ const ChatHistorySlider = ({
onClick: () => { onClick: () => {
router.replace({ router.replace({
query: { query: {
...router.query,
appId: item._id appId: item._id
} }
}); });

View File

@ -61,7 +61,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
appId, appId,
chatId, chatId,
responseChatItemId, responseChatItemId,
variables, ...variables,
histories: histories.slice(0, 10), histories: histories.slice(0, 10),
...body ...body
}; };
@ -71,22 +71,20 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
try { try {
if (!httpHeader || httpHeader.length === 0) return {}; if (!httpHeader || httpHeader.length === 0) return {};
// array // array
return httpHeader.reduce((acc, item) => { return httpHeader.reduce((acc: Record<string, string>, item) => {
item.key = replaceVariable(item.key, concatVariables); const key = replaceVariable(item.key, concatVariables);
item.value = replaceVariable(item.value, concatVariables); const value = replaceVariable(item.value, concatVariables);
// @ts-ignore acc[key] = valueTypeFormat(value, 'string');
acc[item.key] = valueTypeFormat(item.value, 'string');
return acc; return acc;
}, {}); }, {});
} catch (error) { } catch (error) {
return Promise.reject('Header 为非法 JSON 格式'); return Promise.reject('Header 为非法 JSON 格式');
} }
})(); })();
const params = httpParams.reduce((acc, item) => { const params = httpParams.reduce((acc: Record<string, string>, item) => {
item.key = replaceVariable(item.key, concatVariables); const key = replaceVariable(item.key, concatVariables);
item.value = replaceVariable(item.value, concatVariables); const value = replaceVariable(item.value, concatVariables);
// @ts-ignore acc[key] = valueTypeFormat(value, 'string');
acc[item.key] = valueTypeFormat(item.value, 'string');
return acc; return acc;
}, {}); }, {});
const requestBody = await (() => { const requestBody = await (() => {
@ -101,7 +99,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
return Promise.reject(`Invalid JSON body: ${httpJsonBody}`); return Promise.reject(`Invalid JSON body: ${httpJsonBody}`);
} }
})(); })();
// console.log(params, requestBody, headers); // console.log(params, requestBody, headers, concatVariables);
try { try {
const { formatResponse, rawResponse } = await fetchData({ const { formatResponse, rawResponse } = await fetchData({