Skip to content

Commit

Permalink
fix: Fix bug for issue #1669 (#1672)
Browse files Browse the repository at this point in the history
Co-authored-by: WangTing <[email protected]>
Co-authored-by: aries_ckt <[email protected]>
  • Loading branch information
3 people authored Jun 28, 2024
1 parent 2eeef2f commit cd2163e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion dbgpt/app/knowledge/document_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def get_knowledge_documents_count_bulk(self, space_names):
)

results = counts_query.all()
session.close()
docs_count = {result.space: result.document_count for result in results}
return docs_count

Expand Down Expand Up @@ -253,7 +254,9 @@ def update_knowledge_document(self, document: KnowledgeDocumentEntity):
session = self.get_raw_session()
updated_space = session.merge(document)
session.commit()
return updated_space.id
update_space_id = updated_space.id
session.close()
return update_space_id

#
def raw_delete(self, query: KnowledgeDocumentEntity):
Expand Down
11 changes: 8 additions & 3 deletions dbgpt/app/knowledge/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,14 @@ async def document_summary(self, request: DocumentSummaryRequest):
document.status not in [SyncStatus.RUNNING.name]
and len(chunk_entities) == 0
):
self._sync_knowledge_document(
space_name=document.space,
doc=document,
from dbgpt.serve.rag.service.service import Service

rag_service = Service.get_instance(CFG.SYSTEM_APP)
space = rag_service.get({"name": document.space})
document_vo = KnowledgeDocumentEntity.to_document_vo(documents)
await rag_service._sync_knowledge_document(
space_id=space.id,
doc_vo=document_vo[0],
chunk_parameters=chunk_parameters,
)
knowledge = KnowledgeFactory.create(
Expand Down
4 changes: 2 additions & 2 deletions dbgpt/storage/vector_store/chroma_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def similar_search_with_scores(
Chunk(
content=chroma_result[0],
metadata=chroma_result[1] or {},
score=chroma_result[2],
score=(1 - chroma_result[2]),
)
)
for chroma_result in zip(
Expand Down Expand Up @@ -195,7 +195,7 @@ def convert_metadata_filters(
where_filters = {}
filters_list = []
condition = filters.condition
chroma_condition = f"${condition}"
chroma_condition = f"${condition.value}"
if filters.filters:
for filter in filters.filters:
if filter.operator:
Expand Down

0 comments on commit cd2163e

Please sign in to comment.