Skip to content

Commit

Permalink
fix: embeddingUpsert logic
Browse files Browse the repository at this point in the history
  • Loading branch information
blinko-space committed Dec 2, 2024
1 parent aab43ef commit e1163d2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/store/blinkoStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ export class BlinkoStore implements Store {
type = this.noteTypeDefault
}
const res = await api.notes.upsert.mutate({ content, type, isArchived, id, attachments, isTop, isShare })
if (res?.id) {
api.ai.embeddingUpsert.mutate({ id: res!.id, content: res!.content, type: id ? 'update' : 'insert' }, { context: { skipBatch: true } })
}

for (const attachment of attachments) {
api.ai.embeddingInsertAttachments.mutate({ id: res!.id, filePath: attachment.path }, { context: { skipBatch: true } })
if (this.config.value?.isUseAI) {
if (res?.id) {
api.ai.embeddingUpsert.mutate({ id: res!.id, content: res!.content, type: id ? 'update' : 'insert' }, { context: { skipBatch: true } })
}
for (const attachment of attachments) {
api.ai.embeddingInsertAttachments.mutate({ id: res!.id, filePath: attachment.path }, { context: { skipBatch: true } })
}
}
eventBus.emit('editor:clear')
showToast && RootStore.Get(ToastPlugin).success(id ? i18n.t("update-successfully") : i18n.t("create-successfully"))
Expand Down

0 comments on commit e1163d2

Please sign in to comment.