Skip to content

Commit 753b164

Browse files
c121914yuyu-and-liunewfish-cmyk
authored
修复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 <[email protected]> Co-authored-by: archer <[email protected]> * fix: http variable and ai base url * remove log --------- Co-authored-by: yst <[email protected]> Co-authored-by: heheer <[email protected]>
1 parent 64492b8 commit 753b164

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

packages/service/core/ai/config.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@ import type { UserModelSchema } from '@fastgpt/global/support/user/type';
22
import OpenAI from '@fastgpt/global/core/ai';
33

44
export const openaiBaseUrl = process.env.OPENAI_BASE_URL || 'https://api.openai.com/v1';
5-
export const baseUrl = global?.systemEnv?.oneapiUrl || process.env.ONEAPI_URL || openaiBaseUrl;
6-
7-
export const systemAIChatKey = global?.systemEnv?.chatApiKey || process.env.CHAT_API_KEY || '';
85

96
export const getAIApi = (props?: {
107
userKey?: UserModelSchema['openaiAccount'];
118
timeout?: number;
129
}) => {
1310
const { userKey, timeout } = props || {};
1411

12+
const baseUrl =
13+
userKey?.baseUrl || global?.systemEnv?.oneapiUrl || process.env.ONEAPI_URL || openaiBaseUrl;
14+
const apiKey = userKey?.key || global?.systemEnv?.chatApiKey || process.env.CHAT_API_KEY || '';
15+
1516
return new OpenAI({
16-
apiKey: userKey?.key || systemAIChatKey,
17-
baseURL: userKey?.baseUrl || baseUrl,
17+
baseURL: baseUrl,
18+
apiKey,
1819
httpAgent: global.httpsAgent,
1920
timeout,
2021
maxRetries: 2

projects/app/src/pages/chat/components/ChatHistorySlider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ const ChatHistorySlider = ({
304304
onClick: () => {
305305
router.replace({
306306
query: {
307+
...router.query,
307308
appId: item._id
308309
}
309310
});

projects/app/src/service/moduleDispatch/tools/http468.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
6161
appId,
6262
chatId,
6363
responseChatItemId,
64-
variables,
64+
...variables,
6565
histories: histories.slice(0, 10),
6666
...body
6767
};
@@ -71,22 +71,20 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
7171
try {
7272
if (!httpHeader || httpHeader.length === 0) return {};
7373
// array
74-
return httpHeader.reduce((acc, item) => {
75-
item.key = replaceVariable(item.key, concatVariables);
76-
item.value = replaceVariable(item.value, concatVariables);
77-
// @ts-ignore
78-
acc[item.key] = valueTypeFormat(item.value, 'string');
74+
return httpHeader.reduce((acc: Record<string, string>, item) => {
75+
const key = replaceVariable(item.key, concatVariables);
76+
const value = replaceVariable(item.value, concatVariables);
77+
acc[key] = valueTypeFormat(value, 'string');
7978
return acc;
8079
}, {});
8180
} catch (error) {
8281
return Promise.reject('Header 为非法 JSON 格式');
8382
}
8483
})();
85-
const params = httpParams.reduce((acc, item) => {
86-
item.key = replaceVariable(item.key, concatVariables);
87-
item.value = replaceVariable(item.value, concatVariables);
88-
// @ts-ignore
89-
acc[item.key] = valueTypeFormat(item.value, 'string');
84+
const params = httpParams.reduce((acc: Record<string, string>, item) => {
85+
const key = replaceVariable(item.key, concatVariables);
86+
const value = replaceVariable(item.value, concatVariables);
87+
acc[key] = valueTypeFormat(value, 'string');
9088
return acc;
9189
}, {});
9290
const requestBody = await (() => {
@@ -101,7 +99,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
10199
return Promise.reject(`Invalid JSON body: ${httpJsonBody}`);
102100
}
103101
})();
104-
// console.log(params, requestBody, headers);
102+
// console.log(params, requestBody, headers, concatVariables);
105103

106104
try {
107105
const { formatResponse, rawResponse } = await fetchData({

0 commit comments

Comments
 (0)