- Added a new visitor chat API endpoint (`/api/chat/visitor`) to allow unauthenticated users to engage in conversations without requiring customer data. - Introduced a visitor context dependency to manage visitor interactions seamlessly. - Enhanced the chat API to support explicit session termination and improved response handling for customer service interactions. - Updated the database configuration to include Redis client support for caching visitor data. - Added a new customer note repository to persist user notes independently of the L1 profile slots. This update significantly improves the customer service experience by enabling visitor interactions and ensuring efficient data handling for both registered and unregistered users.
37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
"""快速测试 Milvus 检索是否正常工作。"""
|
|
import sys
|
|
sys.path.insert(0, "d:/金融系统")
|
|
|
|
from app.tool.embedding_tool import get_embedder
|
|
from app.tool.milvus_tool import get_milvus_client
|
|
|
|
e = get_embedder()
|
|
m = get_milvus_client()
|
|
|
|
# 测试产品检索
|
|
v = e.embed("R3中风险产品有哪些")
|
|
hits = m.search("fin_product", v, top_k=3)
|
|
print("=== 产品检索 ===")
|
|
for h in hits:
|
|
score = h.get("score", 0)
|
|
text = h.get("chunk_text", "")[:100]
|
|
print(f"score={score:.4f} | {text}")
|
|
|
|
# 测试 FAQ 检索
|
|
v2 = e.embed("开户需要什么材料")
|
|
hits2 = m.search("fin_faq", v2, top_k=3)
|
|
print("\n=== FAQ 检索 ===")
|
|
for h in hits2:
|
|
score = h.get("score", 0)
|
|
text = h.get("chunk_text", "")[:100]
|
|
print(f"score={score:.4f} | {text}")
|
|
|
|
# 测试政策检索
|
|
v3 = e.embed("投资者适当性匹配规则")
|
|
hits3 = m.search("fin_policy", v3, top_k=3)
|
|
print("\n=== 政策检索 ===")
|
|
for h in hits3:
|
|
score = h.get("score", 0)
|
|
text = h.get("chunk_text", "")[:100]
|
|
print(f"score={score:.4f} | {text}")
|