fix: ensure JSON output instruction in system prompt override + retry on ValueError
This commit is contained in:
@@ -535,6 +535,13 @@ async def classify_global_event(
|
|||||||
model_name = resolved.model_name
|
model_name = resolved.model_name
|
||||||
if resolved.system_prompt:
|
if resolved.system_prompt:
|
||||||
prompts["system"] = resolved.system_prompt
|
prompts["system"] = resolved.system_prompt
|
||||||
|
# Ensure JSON output instruction is always present regardless
|
||||||
|
# of custom system prompt (prevents YAML/bullet-point output)
|
||||||
|
if "json" not in prompts["system"].lower():
|
||||||
|
prompts["system"] += (
|
||||||
|
"\n\nReturn ONLY a single JSON object. "
|
||||||
|
"No markdown, no explanation."
|
||||||
|
)
|
||||||
|
|
||||||
# Input token limit truncation
|
# Input token limit truncation
|
||||||
if resolved is not None and resolved.input_token_limit > 0:
|
if resolved is not None and resolved.input_token_limit > 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user