fix: request config
This commit is contained in:
@@ -12,7 +12,11 @@ import { ModelSplitDataSchema } from '@/types/mongoSchema';
|
||||
|
||||
export async function generateQA(next = false): Promise<any> {
|
||||
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) => {
|
||||
|
||||
@@ -4,7 +4,11 @@ import { PgClient } from '@/service/pg';
|
||||
|
||||
export async function generateVector(next = false): Promise<any> {
|
||||
if (process.env.queueTask !== '1') {
|
||||
fetch(process.env.parentUrl || '');
|
||||
try {
|
||||
fetch(process.env.parentUrl || '');
|
||||
} catch (error) {
|
||||
console.log('parentUrl fetch error', error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,12 +39,7 @@ export const jsonRes = <T = any>(
|
||||
} 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({
|
||||
|
||||
@@ -85,7 +85,7 @@ export const openaiCreateEmbedding = async ({
|
||||
},
|
||||
{
|
||||
timeout: 60000,
|
||||
...axiosConfig
|
||||
...axiosConfig()
|
||||
}
|
||||
)
|
||||
.then((res) => ({
|
||||
|
||||
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user