Skip to content

Commit cd2163e

Browse files
ArmandwtWangTingAries-ckt
authored
fix: Fix bug for issue #1669 (#1672)
Co-authored-by: WangTing <wangting@192.168.1.10> Co-authored-by: aries_ckt <916701291@qq.com>
1 parent 2eeef2f commit cd2163e

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

dbgpt/app/knowledge/document_db.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ def get_knowledge_documents_count_bulk(self, space_names):
219219
)
220220

221221
results = counts_query.all()
222+
session.close()
222223
docs_count = {result.space: result.document_count for result in results}
223224
return docs_count
224225

@@ -253,7 +254,9 @@ def update_knowledge_document(self, document: KnowledgeDocumentEntity):
253254
session = self.get_raw_session()
254255
updated_space = session.merge(document)
255256
session.commit()
256-
return updated_space.id
257+
update_space_id = updated_space.id
258+
session.close()
259+
return update_space_id
257260

258261
#
259262
def raw_delete(self, query: KnowledgeDocumentEntity):

dbgpt/app/knowledge/service.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,14 @@ async def document_summary(self, request: DocumentSummaryRequest):
220220
document.status not in [SyncStatus.RUNNING.name]
221221
and len(chunk_entities) == 0
222222
):
223-
self._sync_knowledge_document(
224-
space_name=document.space,
225-
doc=document,
223+
from dbgpt.serve.rag.service.service import Service
224+
225+
rag_service = Service.get_instance(CFG.SYSTEM_APP)
226+
space = rag_service.get({"name": document.space})
227+
document_vo = KnowledgeDocumentEntity.to_document_vo(documents)
228+
await rag_service._sync_knowledge_document(
229+
space_id=space.id,
230+
doc_vo=document_vo[0],
226231
chunk_parameters=chunk_parameters,
227232
)
228233
knowledge = KnowledgeFactory.create(

dbgpt/storage/vector_store/chroma_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def similar_search_with_scores(
133133
Chunk(
134134
content=chroma_result[0],
135135
metadata=chroma_result[1] or {},
136-
score=chroma_result[2],
136+
score=(1 - chroma_result[2]),
137137
)
138138
)
139139
for chroma_result in zip(
@@ -195,7 +195,7 @@ def convert_metadata_filters(
195195
where_filters = {}
196196
filters_list = []
197197
condition = filters.condition
198-
chroma_condition = f"${condition}"
198+
chroma_condition = f"${condition.value}"
199199
if filters.filters:
200200
for filter in filters.filters:
201201
if filter.operator:

0 commit comments

Comments
 (0)