fix(llm): frame RAG notes as reference material, remove RSS from chat context
Add framing preamble to auto-injected notes so the model treats them as reference material rather than user input. Remove RSS semantic search injection from all chat conversations — the discuss tool handles that need. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -810,6 +810,8 @@ async def build_context(
|
|||||||
"score": round(score, 2),
|
"score": round(score, 2),
|
||||||
})
|
})
|
||||||
user_context_parts.append(
|
user_context_parts.append(
|
||||||
|
"[The following are reference excerpts from the user's personal notes, "
|
||||||
|
"not part of their message. Use them only if relevant to answering.]\n"
|
||||||
"--- Relevant Notes ---\n"
|
"--- Relevant Notes ---\n"
|
||||||
+ "\n\n".join(snippets)
|
+ "\n\n".join(snippets)
|
||||||
+ "\n--- End Relevant Notes ---"
|
+ "\n--- End Relevant Notes ---"
|
||||||
@@ -850,33 +852,6 @@ async def build_context(
|
|||||||
+ "\n--- End Included Notes ---"
|
+ "\n--- End Included Notes ---"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Semantically relevant RSS news items
|
|
||||||
try:
|
|
||||||
from fabledassistant.services.embeddings import get_embedding, semantic_search_rss_items
|
|
||||||
news_query_vec = await get_embedding(user_message)
|
|
||||||
news_hits = await semantic_search_rss_items(user_id, news_query_vec)
|
|
||||||
if news_hits:
|
|
||||||
news_snippets = []
|
|
||||||
for score, rss_item in news_hits:
|
|
||||||
feed_title = getattr(rss_item, "feed_title", "") or ""
|
|
||||||
excerpt = (rss_item.content or "")[:500].strip()
|
|
||||||
news_snippets.append(
|
|
||||||
f"[{feed_title or 'News'}] {rss_item.title} (relevance: {round(score * 100)}%)\n"
|
|
||||||
+ (f"{excerpt}\n" if excerpt else "")
|
|
||||||
+ f"URL: {rss_item.url}"
|
|
||||||
)
|
|
||||||
user_context_parts.append(
|
|
||||||
"--- Recent News You've Seen ---\n"
|
|
||||||
+ "\n\n".join(news_snippets)
|
|
||||||
+ "\n--- End Recent News ---"
|
|
||||||
)
|
|
||||||
context_meta["rss_news"] = [
|
|
||||||
{"id": item.id, "title": item.title, "score": round(score, 2)}
|
|
||||||
for score, item in news_hits
|
|
||||||
]
|
|
||||||
except Exception:
|
|
||||||
logger.debug("RSS semantic search skipped", exc_info=True)
|
|
||||||
|
|
||||||
# URL content fetched from links in the user message
|
# URL content fetched from links in the user message
|
||||||
urls = _find_urls(user_message)
|
urls = _find_urls(user_message)
|
||||||
for url in urls[:2]:
|
for url in urls[:2]:
|
||||||
|
|||||||
Reference in New Issue
Block a user