mirror of
https://github.com/karpathy/nanochat.git
synced 2026-05-24 00:28:05 +00:00
fix(serve): strip system-prompt prefix before classifying user query
This commit is contained in:
parent
65e681add5
commit
297bc4bfb9
|
|
@ -264,8 +264,14 @@ class Inference:
|
|||
if msg.get("role") == "user":
|
||||
last_user = msg.get("content", "")
|
||||
break
|
||||
# chat-api inlines the system prompt into the first user message as
|
||||
# "{SYS_PROMPT}\n\n{actual_user_question}". Strip the sys prefix for
|
||||
# the classifier so Tavily gets a clean query.
|
||||
query_for_classify = last_user
|
||||
if "\n\n" in query_for_classify:
|
||||
query_for_classify = query_for_classify.rsplit("\n\n", 1)[-1].strip()
|
||||
try:
|
||||
needs_search, rewritten = self._needs_web_search(last_user)
|
||||
needs_search, rewritten = self._needs_web_search(query_for_classify)
|
||||
except Exception:
|
||||
needs_search, rewritten = False, ""
|
||||
if needs_search and rewritten:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user