Commit 79868d49 authored by Vũ Hoàng Anh's avatar Vũ Hoàng Anh

fix: cast json_query to VARCHAR for StarRocks DISTINCT, add sku_color to API,...

fix: cast json_query to VARCHAR for StarRocks DISTINCT, add sku_color to API, merge knowledge tool to 1 query
parent 484a9c2b
......@@ -37,14 +37,14 @@ async def canifa_knowledge_search(query: str) -> str:
# 2. SINGLE QUERY: Tìm top K chunks → lấy full document theo title (1 round-trip)
sql = f"""
WITH top_chunks AS (
SELECT json_query(metadata, '$.title') AS title
SELECT CAST(json_query(metadata, '$.title') AS VARCHAR) AS title
FROM shared_source.chatbot_rsa_knowledge
ORDER BY approx_cosine_similarity(embedding, {v_str}) DESC
LIMIT {TOP_K_CHUNKS}
)
SELECT k.content, k.metadata
FROM shared_source.chatbot_rsa_knowledge k
WHERE json_query(k.metadata, '$.title') IN (
WHERE CAST(json_query(k.metadata, '$.title') AS VARCHAR) IN (
SELECT DISTINCT title FROM top_chunks WHERE title IS NOT NULL
)
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment