diff --git a/src/pages/api/chat/chatGpt.ts b/src/pages/api/chat/chatGpt.ts index 5154c2364..b4c2c241b 100644 --- a/src/pages/api/chat/chatGpt.ts +++ b/src/pages/api/chat/chatGpt.ts @@ -88,7 +88,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) { timeout: 40000, responseType: 'stream', - ...axiosConfig + ...axiosConfig() } ); diff --git a/src/pages/api/chat/vectorGpt.ts b/src/pages/api/chat/vectorGpt.ts index ec74a004a..a088dca27 100644 --- a/src/pages/api/chat/vectorGpt.ts +++ b/src/pages/api/chat/vectorGpt.ts @@ -150,7 +150,7 @@ ${ { timeout: 40000, responseType: 'stream', - ...axiosConfig + ...axiosConfig() } ); diff --git a/src/pages/api/model/data/fetchingUrlData.ts b/src/pages/api/model/data/fetchingUrlData.ts index f032c64b1..2c03de49a 100644 --- a/src/pages/api/model/data/fetchingUrlData.ts +++ b/src/pages/api/model/data/fetchingUrlData.ts @@ -22,7 +22,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) const data = await axios .get(url, { - httpsAgent: axiosConfig.httpsAgent + httpsAgent: axiosConfig().httpsAgent }) .then((res) => res.data as string); diff --git a/src/pages/api/openapi/chat/chatGpt.ts b/src/pages/api/openapi/chat/chatGpt.ts index 7c83b4029..e346021d7 100644 --- a/src/pages/api/openapi/chat/chatGpt.ts +++ b/src/pages/api/openapi/chat/chatGpt.ts @@ -100,7 +100,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) { timeout: 40000, responseType: isStream ? 'stream' : 'json', - ...axiosConfig + ...axiosConfig() } ); diff --git a/src/pages/api/openapi/chat/lafGpt.ts b/src/pages/api/openapi/chat/lafGpt.ts index c9ad32181..549cb08cd 100644 --- a/src/pages/api/openapi/chat/lafGpt.ts +++ b/src/pages/api/openapi/chat/lafGpt.ts @@ -120,7 +120,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) }, { timeout: 180000, - ...axiosConfig + ...axiosConfig() } ); @@ -196,7 +196,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) { timeout: 180000, responseType: isStream ? 'stream' : 'json', - ...axiosConfig + ...axiosConfig() } ); diff --git a/src/pages/api/openapi/chat/vectorGpt.ts b/src/pages/api/openapi/chat/vectorGpt.ts index 39cbca7c2..1b9997ddf 100644 --- a/src/pages/api/openapi/chat/vectorGpt.ts +++ b/src/pages/api/openapi/chat/vectorGpt.ts @@ -171,7 +171,7 @@ ${ { timeout: 180000, responseType: isStream ? 'stream' : 'json', - ...axiosConfig + ...axiosConfig() } ); diff --git a/src/pages/model/detail/index.tsx b/src/pages/model/detail/index.tsx index 759ceeb0e..96a37d3f9 100644 --- a/src/pages/model/detail/index.tsx +++ b/src/pages/model/detail/index.tsx @@ -39,7 +39,6 @@ const ModelDetail = ({ modelId }: { modelId: string }) => { setLoading(true); try { const res = await getModelById(modelId); - console.log(res); setModel(res); formHooks.reset(res); } catch (err: any) { diff --git a/src/service/events/generateQA.ts b/src/service/events/generateQA.ts index 472d342cd..68bdc1ce8 100644 --- a/src/service/events/generateQA.ts +++ b/src/service/events/generateQA.ts @@ -12,7 +12,11 @@ import { ModelSplitDataSchema } from '@/types/mongoSchema'; export async function generateQA(next = false): Promise { if (process.env.queueTask !== '1') { - fetch(process.env.parentUrl || ''); + try { + fetch(process.env.parentUrl || ''); + } catch (error) { + console.log('parentUrl fetch error', error); + } return; } if (global.generatingQA === true && !next) return; @@ -97,7 +101,7 @@ A2: }, { timeout: 180000, - ...axiosConfig + ...axiosConfig() } ) .then((res) => { diff --git a/src/service/events/generateVector.ts b/src/service/events/generateVector.ts index 7d88d58bf..53ad92756 100644 --- a/src/service/events/generateVector.ts +++ b/src/service/events/generateVector.ts @@ -4,7 +4,11 @@ import { PgClient } from '@/service/pg'; export async function generateVector(next = false): Promise { if (process.env.queueTask !== '1') { - fetch(process.env.parentUrl || ''); + try { + fetch(process.env.parentUrl || ''); + } catch (error) { + console.log('parentUrl fetch error', error); + } return; } diff --git a/src/service/response.ts b/src/service/response.ts index c119c9562..a326488ad 100644 --- a/src/service/response.ts +++ b/src/service/response.ts @@ -39,12 +39,7 @@ export const jsonRes = ( } else if (openaiError[error?.response?.statusText]) { msg = openaiError[error.response.statusText]; } - console.log(`error-> msg:${msg}`); - // request 时候报错 - if (error?.response) { - console.log('statusText:', error?.response?.statusText); - console.log('openai error:', error?.response?.data?.error); - } + console.log(error); } res.json({ diff --git a/src/service/utils/openai.ts b/src/service/utils/openai.ts index 3fbd23bc1..0c079a518 100644 --- a/src/service/utils/openai.ts +++ b/src/service/utils/openai.ts @@ -85,7 +85,7 @@ export const openaiCreateEmbedding = async ({ }, { timeout: 60000, - ...axiosConfig + ...axiosConfig() } ) .then((res) => ({ diff --git a/src/service/utils/tools.ts b/src/service/utils/tools.ts index bd40b39f1..48848a89c 100644 --- a/src/service/utils/tools.ts +++ b/src/service/utils/tools.ts @@ -85,12 +85,12 @@ export const authOpenApiKey = async (req: NextApiRequest) => { }; /* openai axios config */ -export const axiosConfig = { +export const axiosConfig = () => ({ httpsAgent: global.httpsAgent, headers: { auth: process.env.OPENAI_BASE_URL_AUTH || '' } -}; +}); /* delete invalid symbol */ const simplifyStr = (str: string) =>