31 lines
1009 B
Python
31 lines
1009 B
Python
from typing import List, Dict, Any
|
|
|
|
from langgraph.runtime import Runtime
|
|
|
|
from app.chat_qa.context import QAContext
|
|
from app.chat_qa.qa_state import QAState
|
|
from app.repository.milvus.summary_repository import SummaryRepository
|
|
from app.core.log import logger
|
|
|
|
"""
|
|
查询历史记录
|
|
"""
|
|
async def query_message(state: QAState, runtime: Runtime[QAContext]):
|
|
# 1 根据时间查询向量库
|
|
# 从state获取日期
|
|
date = state.get("msg_time")
|
|
|
|
if not date:
|
|
return {"retry_count": state.get("retry_count", 0) + 1, "message_summary": []}
|
|
|
|
# 根据日期查询向量库
|
|
repo = SummaryRepository()
|
|
message_list: List[Dict[str, Any]] = repo.query_by_date(date)
|
|
logger.info(f"根据时间{ date}查询向量库结果:{len(message_list)}")
|
|
message_content_list = [message["message_context"] for message in message_list]
|
|
retry_count = state.get("retry_count", 0)
|
|
return {
|
|
"retry_count": retry_count + 1,
|
|
"chat_history": message_content_list
|
|
}
|