Skip to content

Commit

Permalink
fix: milvus错误处理
Browse files Browse the repository at this point in the history
  • Loading branch information
MarleneJiang committed Oct 20, 2023
1 parent 34bd662 commit 321c523
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "llm-ops",
"version": "0.0.10",
"version": "0.0.11",
"description": "高效制作llm workflow的低代码框架",
"main": "package/index.js",
"author": "Marlene && IdeaLeap",
Expand Down
8 changes: 6 additions & 2 deletions package/db/milvus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,15 @@ export class milvusVectorDB {
async upload(params: milvusVectorDBUploadSchema) {
const { fields_data, index, partition_name } = params;
console.time("Upload time");
await this.milvusClient.insert({
const insertRes = await this.milvusClient.insert({
collection_name: this.COLLECTION_NAME,
fields_data: fields_data,
partition_name: partition_name || undefined,
});
if (insertRes.status.error_code != "Success") {
console.error(insertRes.status.reason);
throw new Error(insertRes.status.reason);
}
await this.milvusClient.createIndex({
collection_name: this.COLLECTION_NAME,
field_name: index.field_name,
Expand All @@ -172,7 +176,7 @@ export class milvusVectorDB {
this.llm = new LLM({});
}
const vector = await this.llm?.embedding(data);
if (!vector?.data[0]?.embedding) {
if (!vector|| !vector?.data[0] || !vector?.data[0]?.embedding) {
throw new Error("生成向量失败");
}
return vector?.data[0]?.embedding;
Expand Down

0 comments on commit 321c523

Please sign in to comment.