perf: 连续手动输入数据

This commit is contained in:
archer
2023-04-06 16:02:35 +08:00
parent f88c6031f5
commit 881c36542c
2 changed files with 12 additions and 8 deletions

View File

@@ -35,7 +35,7 @@ const InputDataModal = ({
const [importing, setImporting] = useState(false);
const { toast } = useToast();
const { register, handleSubmit } = useForm<FormData>({
const { register, handleSubmit, reset } = useForm<FormData>({
defaultValues
});
@@ -64,14 +64,17 @@ const InputDataModal = ({
title: res === 0 ? '导入数据成功,需要一段时间训练' : '数据导入异常',
status: res === 0 ? 'success' : 'warning'
});
onClose();
reset({
text: '',
q: ''
});
onSuccess();
} catch (err) {
console.log(err);
}
setImporting(false);
},
[modelId, onClose, onSuccess, toast]
[modelId, onSuccess, reset, toast]
);
const updateData = useCallback(
@@ -91,7 +94,7 @@ const InputDataModal = ({
onClose();
onSuccess();
},
[defaultValues.q, onClose, onSuccess, toast]
[defaultValues, onClose, onSuccess, toast]
);
return (

View File

@@ -97,18 +97,19 @@ export async function generateQA(next = false): Promise<any> {
}
)
.then((res) => {
const rawContent = res?.data.choices[0].message?.content || '';
const rawContent = res?.data.choices[0].message?.content || ''; // chatgpt 原本的回复
const result = splitText(res?.data.choices[0].message?.content || ''); // 格式化后的QA对
// 计费
pushSplitDataBill({
isPay: !userApiKey,
isPay: !userApiKey && result.length > 0,
userId: dataItem.userId,
type: 'QA',
text: systemPrompt.content + text + rawContent,
tokenLen: res.data.usage?.total_tokens || 0
});
return {
rawContent, // chatgpt 原本的回复
result: splitText(res?.data.choices[0].message?.content || '') // 格式化后的QA对
rawContent,
result
};
})
)