feat: 删除模型数据

This commit is contained in:
archer
2023-03-31 00:23:41 +08:00
parent 8239c58494
commit 837c132d24
5 changed files with 54 additions and 21 deletions

View File

@@ -29,9 +29,6 @@ export async function generateQA(next = false): Promise<any> {
return;
}
// 弹出文本
await SplitData.findByIdAndUpdate(dataItem._id, { $pop: { textList: 1 } });
const text = dataItem.textList[dataItem.textList.length - 1];
if (!text) {
throw new Error('无文本');
@@ -83,21 +80,23 @@ export async function generateQA(next = false): Promise<any> {
result: splitText(res?.data.choices[0].message?.content || '')
})); // 从 content 中提取 QA
// 插入 modelData 表,生成向量
await ModelData.insertMany(
response.result.map((item) => ({
modelId: dataItem.modelId,
userId: dataItem.userId,
text: item.a,
q: [
{
id: nanoid(),
text: item.q
}
],
status: 1
}))
);
await Promise.allSettled([
SplitData.findByIdAndUpdate(dataItem._id, { $pop: { textList: 1 } }),
ModelData.insertMany(
response.result.map((item) => ({
modelId: dataItem.modelId,
userId: dataItem.userId,
text: item.a,
q: [
{
id: nanoid(),
text: item.q
}
],
status: 1
}))
)
]);
console.log(
'生成QA成功time:',

View File

@@ -48,7 +48,7 @@ export async function generateVector(next = false): Promise<any> {
.then((vector) =>
redis.sendCommand([
'JSON.SET',
`${VecModelDataIndex}:${dataId}:${i}`,
`${VecModelDataIndex}:${item.id}`,
'$',
JSON.stringify({
dataId,