From e99e8b93fbe26ed08c2519ee8a17828a677e1105 Mon Sep 17 00:00:00 2001 From: Wang Baoling Date: Thu, 20 Jun 2024 09:43:39 +0800 Subject: [PATCH] fix:failed to Create new Chunk in database #1159 (#1214) ### What problem does this PR solve? fix bug: [1159](https://github.com/infiniflow/ragflow/issues/1159) using embd which user configured at knowledgebase when create new chunk in database ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/apps/chunk_app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/apps/chunk_app.py b/api/apps/chunk_app.py index 9e8b19450..1da5c92de 100644 --- a/api/apps/chunk_app.py +++ b/api/apps/chunk_app.py @@ -224,9 +224,11 @@ def create(): tenant_id = DocumentService.get_tenant_id(req["doc_id"]) if not tenant_id: return get_data_error_result(retmsg="Tenant not found!") - + + embd_id = DocumentService.get_embd_id(req["doc_id"]) embd_mdl = TenantLLMService.model_instance( - tenant_id, LLMType.EMBEDDING.value) + tenant_id, LLMType.EMBEDDING.value, embd_id) + v, c = embd_mdl.encode([doc.name, req["content_with_weight"]]) DocumentService.increment_chunk_num(req["doc_id"], doc.kb_id, c, 1, 0) v = 0.1 * v[0] + 0.9 * v[1]