nothingworry commited on
Commit
a40db2d
·
1 Parent(s): 36722a7

fix the issue

Browse files
backend/api/services/agent_orchestrator.py CHANGED
@@ -1884,6 +1884,16 @@ Answer:"""
1884
  scratchpad_section = f"\n## Structured Notes\n{scratchpad_context}\n" if scratchpad_context else ""
1885
 
1886
  # Build prompt with Anthropic's structured format (XML-style sections)
 
 
 
 
 
 
 
 
 
 
1887
  prompt = (
1888
  f"<system>\n"
1889
  f"You are an assistant helping tenant {req.tenant_id}. "
@@ -1897,7 +1907,7 @@ Answer:"""
1897
  f"The following details have been gathered from reliable sources:\n\n"
1898
  f"{data_section}\n"
1899
  f"</information_collected>\n\n"
1900
- f"{f'<web_search_guidance>\n{web_fallback_note.strip()}\n</web_search_guidance>\n\n' if web_fallback_note else ''}"
1901
  f"<user_request>\n"
1902
  f"{req.message}\n"
1903
  f"</user_request>\n\n"
 
1884
  scratchpad_section = f"\n## Structured Notes\n{scratchpad_context}\n" if scratchpad_context else ""
1885
 
1886
  # Build prompt with Anthropic's structured format (XML-style sections)
1887
+ # Pre-build optional web guidance section to avoid complex nested f-strings
1888
+ if web_fallback_note:
1889
+ web_guidance_section = (
1890
+ "<web_search_guidance>\n"
1891
+ f"{web_fallback_note.strip()}\n"
1892
+ "</web_search_guidance>\n\n"
1893
+ )
1894
+ else:
1895
+ web_guidance_section = ""
1896
+
1897
  prompt = (
1898
  f"<system>\n"
1899
  f"You are an assistant helping tenant {req.tenant_id}. "
 
1907
  f"The following details have been gathered from reliable sources:\n\n"
1908
  f"{data_section}\n"
1909
  f"</information_collected>\n\n"
1910
+ f"{web_guidance_section}"
1911
  f"<user_request>\n"
1912
  f"{req.message}\n"
1913
  f"</user_request>\n\n"