""" 向量化 """ from typing import List, Dict, Any from app.chat_qa_query.query_qa_state import QueryQAState from app.client.embedding_client_manager import embedding_client from app.repository.milvus.intent_classification_repository import IntentClassificationRepository from app.repository.milvus.message_qa_repository import QARepository from app.core.log import logger async def search_embed(state: QueryQAState): logger.info("search_embed") rewritten_query: List[str] = state.get("rewritten_query", "") original_query = state.get("original_query", "") #batch_embeddings = await embedding_client.aembed_query(rewritten_query) intent_class = IntentClassificationRepository() result: List[Dict[str, Any]] = await intent_class.search_by_intent_category(intent_category=rewritten_query, top_k=3) logger.info(f"原始问题:{original_query},改写后的问题:{rewritten_query},匹配结果:{result}") qa_pairs = [] for item in result: qa_pairs.append({ "intent_category": item.get("intent_category", ""), "content": item.get("content", "") + "," +item.get("review_content", ""), "score": item.get("score", 0) }) return {"qa_pairs": qa_pairs}