Skip to content

Commit

Permalink
修复4.6.9问题 (#976)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Mar 11, 2024
1 parent 64492b8 commit 753b164
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
11 changes: 6 additions & 5 deletions packages/service/core/ai/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ 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'];
timeout?: number;
}) => {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ const ChatHistorySlider = ({
onClick: () => {
router.replace({
query: {
...router.query,
appId: item._id
}
});
Expand Down
22 changes: 10 additions & 12 deletions projects/app/src/service/moduleDispatch/tools/http468.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
appId,
chatId,
responseChatItemId,
variables,
...variables,
histories: histories.slice(0, 10),
...body
};
Expand All @@ -71,22 +71,20 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
try {
if (!httpHeader || httpHeader.length === 0) return {};
// array
return httpHeader.reduce((acc, item) => {
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<string, string>, 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<string, string>, item) => {
const key = replaceVariable(item.key, concatVariables);
const value = replaceVariable(item.value, concatVariables);
acc[key] = valueTypeFormat(value, 'string');
return acc;
}, {});
const requestBody = await (() => {
Expand All @@ -101,7 +99,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
return Promise.reject(`Invalid JSON body: ${httpJsonBody}`);
}
})();
// console.log(params, requestBody, headers);
// console.log(params, requestBody, headers, concatVariables);

try {
const { formatResponse, rawResponse } = await fetchData({
Expand Down

0 comments on commit 753b164

Please sign in to comment.