Fix VectorDB search: use content field instead of text

The vector-db API returns message content in a top-level "content" field
with "author" and "channel" also top-level (not nested under metadata).
Previous code read "text" and "metadata.author" which returned empty strings,
making all vector search results invisible to the LLM.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
admin
2026-06-03 10:41:10 +00:00
Unverified
parent ae621ecbb5
commit a722e16fe2

View File

@@ -152,12 +152,11 @@ async def search_vector(query: str, top_k: int = 5) -> str:
return ""
lines = []
for h in hits[:top_k]:
text = h.get("text", "")[:300]
text = h.get("content", "") or h.get("text", "")
score = h.get("score", 0)
source = h.get("source", "unknown")
meta = h.get("metadata", {})
author = meta.get("author", "")
channel = meta.get("channel", "")
author = h.get("author", "")
channel = h.get("channel", "")
preview = text.replace("\n", " ")[:200]
lines.append(f"[{source}] @{author} in #{channel}: {preview} (score: {score:.2f})")
return "\n\n".join(lines)