mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-03-26 17:51:54 +01:00
Chat History Docs sometimes wrongly ordered (#1039)
This commit is contained in:
parent
c435bf3854
commit
4c9709ae4a
@ -685,12 +685,12 @@ def translate_db_search_doc_to_server_search_doc(
|
||||
|
||||
|
||||
def get_retrieval_docs_from_chat_message(chat_message: ChatMessage) -> RetrievalDocs:
|
||||
return RetrievalDocs(
|
||||
top_documents=[
|
||||
translate_db_search_doc_to_server_search_doc(db_doc)
|
||||
for db_doc in chat_message.search_docs
|
||||
]
|
||||
)
|
||||
top_documents = [
|
||||
translate_db_search_doc_to_server_search_doc(db_doc)
|
||||
for db_doc in chat_message.search_docs
|
||||
]
|
||||
top_documents = sorted(top_documents, key=lambda doc: doc.score, reverse=True) # type: ignore
|
||||
return RetrievalDocs(top_documents=top_documents)
|
||||
|
||||
|
||||
def translate_db_message_to_chat_message_detail(
|
||||
|
@ -132,13 +132,16 @@ class SearchDoc(BaseModel):
|
||||
|
||||
class SavedSearchDoc(SearchDoc):
|
||||
db_doc_id: int
|
||||
score: float = 0.0
|
||||
|
||||
@classmethod
|
||||
def from_search_doc(
|
||||
cls, search_doc: SearchDoc, db_doc_id: int = 0
|
||||
) -> "SavedSearchDoc":
|
||||
"""IMPORTANT: careful using this and not providing a db_doc_id"""
|
||||
return cls(**search_doc.dict(), db_doc_id=db_doc_id)
|
||||
search_doc_data = search_doc.dict()
|
||||
search_doc_data["score"] = search_doc_data.get("score", 0.0)
|
||||
return cls(**search_doc_data, db_doc_id=db_doc_id)
|
||||
|
||||
|
||||
class RetrievalDocs(BaseModel):
|
||||
|
Loading…
x
Reference in New Issue
Block a user