perf: 表格样式。代理配置
This commit is contained in:
@@ -5,7 +5,7 @@ import { authToken, getUserOpenaiKey } from '@/service/utils/tools';
|
||||
import { TrainingStatusEnum } from '@/constants/model';
|
||||
import { getOpenAIApi } from '@/service/utils/chat';
|
||||
import { TrainingItemType } from '@/types/training';
|
||||
import { openaiProxy } from '@/service/utils/tools';
|
||||
import { httpsAgent } from '@/service/utils/tools';
|
||||
|
||||
/* 获取我的模型 */
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
|
||||
@@ -47,12 +47,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||
if (training) {
|
||||
const openai = getOpenAIApi(await getUserOpenaiKey(userId));
|
||||
// 获取训练记录
|
||||
const tuneRecord = await openai.retrieveFineTune(training.tuneId, openaiProxy);
|
||||
const tuneRecord = await openai.retrieveFineTune(training.tuneId, { httpsAgent });
|
||||
|
||||
// 删除训练文件
|
||||
openai.deleteFile(tuneRecord.data.training_files[0].id, openaiProxy);
|
||||
openai.deleteFile(tuneRecord.data.training_files[0].id, { httpsAgent });
|
||||
// 取消训练
|
||||
openai.cancelFineTune(training.tuneId, openaiProxy);
|
||||
openai.cancelFineTune(training.tuneId, { httpsAgent });
|
||||
}
|
||||
|
||||
// 删除对应训练记录
|
||||
|
||||
@@ -9,7 +9,7 @@ import fs from 'fs';
|
||||
import type { ModelType } from '@/types/model';
|
||||
import type { OpenAIApi } from 'openai';
|
||||
import { ModelStatusEnum, TrainingStatusEnum } from '@/constants/model';
|
||||
import { openaiProxy } from '@/service/utils/tools';
|
||||
import { httpsAgent } from '@/service/utils/tools';
|
||||
|
||||
// 关闭next默认的bodyParser处理方式
|
||||
export const config = {
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { ModelType } from '@/types/model';
|
||||
import { TrainingItemType } from '@/types/training';
|
||||
import { ModelStatusEnum, TrainingStatusEnum } from '@/constants/model';
|
||||
import { OpenAiTuneStatusEnum } from '@/service/constants/training';
|
||||
import { openaiProxy } from '@/service/utils/tools';
|
||||
import { httpsAgent } from '@/service/utils/tools';
|
||||
|
||||
/* 更新训练状态 */
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
@@ -46,11 +46,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
const openai = getOpenAIApi(await getUserOpenaiKey(userId));
|
||||
|
||||
// 获取 openai 的训练情况
|
||||
const { data } = await openai.retrieveFineTune(training.tuneId, openaiProxy);
|
||||
const { data } = await openai.retrieveFineTune(training.tuneId, { httpsAgent });
|
||||
|
||||
if (data.status === OpenAiTuneStatusEnum.succeeded) {
|
||||
// 删除训练文件
|
||||
openai.deleteFile(data.training_files[0].id, openaiProxy);
|
||||
openai.deleteFile(data.training_files[0].id, { httpsAgent });
|
||||
|
||||
// 更新模型
|
||||
await Model.findByIdAndUpdate(modelId, {
|
||||
@@ -74,7 +74,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
|
||||
if (data.status === OpenAiTuneStatusEnum.cancelled) {
|
||||
// 删除训练文件
|
||||
openai.deleteFile(data.training_files[0].id, openaiProxy);
|
||||
openai.deleteFile(data.training_files[0].id, { httpsAgent });
|
||||
|
||||
// 更新模型
|
||||
await Model.findByIdAndUpdate(modelId, {
|
||||
|
||||
@@ -10,7 +10,7 @@ import fs from 'fs';
|
||||
import type { ModelType } from '@/types/model';
|
||||
import type { OpenAIApi } from 'openai';
|
||||
import { ModelStatusEnum, TrainingStatusEnum } from '@/constants/model';
|
||||
import { openaiProxy } from '@/service/utils/tools';
|
||||
import { httpsAgent } from '@/service/utils/tools';
|
||||
|
||||
// 关闭next默认的bodyParser处理方式
|
||||
export const config = {
|
||||
@@ -73,7 +73,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
// @ts-ignore
|
||||
fs.createReadStream(file.filepath),
|
||||
'fine-tune',
|
||||
openaiProxy
|
||||
{ httpsAgent }
|
||||
);
|
||||
uploadFileId = uploadRes.data.id; // 记录上传文件的 ID
|
||||
|
||||
@@ -84,7 +84,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
model: trainingType,
|
||||
suffix: model.name
|
||||
},
|
||||
openaiProxy
|
||||
{ httpsAgent }
|
||||
);
|
||||
|
||||
trainId = trainRes.data.id; // 记录训练 ID
|
||||
@@ -114,9 +114,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
// @ts-ignore
|
||||
if (openai) {
|
||||
// @ts-ignore
|
||||
uploadFileId && openai.deleteFile(uploadFileId, openaiProxy);
|
||||
uploadFileId && openai.deleteFile(uploadFileId, { httpsAgent });
|
||||
// @ts-ignore
|
||||
trainId && openai.cancelFineTune(trainId, openaiProxy);
|
||||
trainId && openai.cancelFineTune(trainId, { httpsAgent });
|
||||
}
|
||||
|
||||
jsonRes(res, {
|
||||
|
||||
Reference in New Issue
Block a user