fix: request config
This commit is contained in:
parent
56b3ddc147
commit
cd9acab938
@ -88,7 +88,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
{
|
{
|
||||||
timeout: 40000,
|
timeout: 40000,
|
||||||
responseType: 'stream',
|
responseType: 'stream',
|
||||||
...axiosConfig
|
...axiosConfig()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -150,7 +150,7 @@ ${
|
|||||||
{
|
{
|
||||||
timeout: 40000,
|
timeout: 40000,
|
||||||
responseType: 'stream',
|
responseType: 'stream',
|
||||||
...axiosConfig
|
...axiosConfig()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
|
|
||||||
const data = await axios
|
const data = await axios
|
||||||
.get(url, {
|
.get(url, {
|
||||||
httpsAgent: axiosConfig.httpsAgent
|
httpsAgent: axiosConfig().httpsAgent
|
||||||
})
|
})
|
||||||
.then((res) => res.data as string);
|
.then((res) => res.data as string);
|
||||||
|
|
||||||
|
|||||||
@ -100,7 +100,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
{
|
{
|
||||||
timeout: 40000,
|
timeout: 40000,
|
||||||
responseType: isStream ? 'stream' : 'json',
|
responseType: isStream ? 'stream' : 'json',
|
||||||
...axiosConfig
|
...axiosConfig()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -120,7 +120,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
timeout: 180000,
|
timeout: 180000,
|
||||||
...axiosConfig
|
...axiosConfig()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
{
|
{
|
||||||
timeout: 180000,
|
timeout: 180000,
|
||||||
responseType: isStream ? 'stream' : 'json',
|
responseType: isStream ? 'stream' : 'json',
|
||||||
...axiosConfig
|
...axiosConfig()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -171,7 +171,7 @@ ${
|
|||||||
{
|
{
|
||||||
timeout: 180000,
|
timeout: 180000,
|
||||||
responseType: isStream ? 'stream' : 'json',
|
responseType: isStream ? 'stream' : 'json',
|
||||||
...axiosConfig
|
...axiosConfig()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,6 @@ const ModelDetail = ({ modelId }: { modelId: string }) => {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const res = await getModelById(modelId);
|
const res = await getModelById(modelId);
|
||||||
console.log(res);
|
|
||||||
setModel(res);
|
setModel(res);
|
||||||
formHooks.reset(res);
|
formHooks.reset(res);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
|||||||
@ -12,7 +12,11 @@ import { ModelSplitDataSchema } from '@/types/mongoSchema';
|
|||||||
|
|
||||||
export async function generateQA(next = false): Promise<any> {
|
export async function generateQA(next = false): Promise<any> {
|
||||||
if (process.env.queueTask !== '1') {
|
if (process.env.queueTask !== '1') {
|
||||||
fetch(process.env.parentUrl || '');
|
try {
|
||||||
|
fetch(process.env.parentUrl || '');
|
||||||
|
} catch (error) {
|
||||||
|
console.log('parentUrl fetch error', error);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (global.generatingQA === true && !next) return;
|
if (global.generatingQA === true && !next) return;
|
||||||
@ -97,7 +101,7 @@ A2:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
timeout: 180000,
|
timeout: 180000,
|
||||||
...axiosConfig
|
...axiosConfig()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
|||||||
@ -4,7 +4,11 @@ import { PgClient } from '@/service/pg';
|
|||||||
|
|
||||||
export async function generateVector(next = false): Promise<any> {
|
export async function generateVector(next = false): Promise<any> {
|
||||||
if (process.env.queueTask !== '1') {
|
if (process.env.queueTask !== '1') {
|
||||||
fetch(process.env.parentUrl || '');
|
try {
|
||||||
|
fetch(process.env.parentUrl || '');
|
||||||
|
} catch (error) {
|
||||||
|
console.log('parentUrl fetch error', error);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,12 +39,7 @@ export const jsonRes = <T = any>(
|
|||||||
} else if (openaiError[error?.response?.statusText]) {
|
} else if (openaiError[error?.response?.statusText]) {
|
||||||
msg = openaiError[error.response.statusText];
|
msg = openaiError[error.response.statusText];
|
||||||
}
|
}
|
||||||
console.log(`error-> msg:${msg}`);
|
console.log(error);
|
||||||
// request 时候报错
|
|
||||||
if (error?.response) {
|
|
||||||
console.log('statusText:', error?.response?.statusText);
|
|
||||||
console.log('openai error:', error?.response?.data?.error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
|
|||||||
@ -85,7 +85,7 @@ export const openaiCreateEmbedding = async ({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
...axiosConfig
|
...axiosConfig()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((res) => ({
|
.then((res) => ({
|
||||||
|
|||||||
@ -85,12 +85,12 @@ export const authOpenApiKey = async (req: NextApiRequest) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* openai axios config */
|
/* openai axios config */
|
||||||
export const axiosConfig = {
|
export const axiosConfig = () => ({
|
||||||
httpsAgent: global.httpsAgent,
|
httpsAgent: global.httpsAgent,
|
||||||
headers: {
|
headers: {
|
||||||
auth: process.env.OPENAI_BASE_URL_AUTH || ''
|
auth: process.env.OPENAI_BASE_URL_AUTH || ''
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
/* delete invalid symbol */
|
/* delete invalid symbol */
|
||||||
const simplifyStr = (str: string) =>
|
const simplifyStr = (str: string) =>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user