Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

quality: Enhance synthesis by removing invisible context

Clémence Lesné7ba8254dad0d
diff --git a/helpers/config_models/prompts.py b/helpers/config_models/prompts.py
index 31f3ab6..2732529 100644
--- a/helpers/config_models/prompts.py
+++ b/helpers/config_models/prompts.py
@@ -265,7 +265,14 @@ class LlmModel(BaseSettings, env_prefix="prompts_llm_"):
self.sms_summary_system_tpl,
claim=_pydantic_to_str(claim),
conversation_lang=CONFIG.workflow.conversation_lang,
- messages=_pydantic_to_str(messages),
+ messages=_pydantic_to_str(
+ [
+ message
+ for message in messages
+ if message.persona is not MessagePersona.TOOL
+ ],
+ exclude={"tool_calls"},
+ ), # Filter out tool messages, to avoid LLM to summarize invisible messages (from the user perspective)
reminders=_pydantic_to_str(reminders),
)
@@ -281,7 +288,14 @@ class LlmModel(BaseSettings, env_prefix="prompts_llm_"):
self.synthesis_short_system_tpl,
claim=_pydantic_to_str(claim),
conversation_lang=CONFIG.workflow.conversation_lang,
- messages=_pydantic_to_str(messages),
+ messages=_pydantic_to_str(
+ [
+ message
+ for message in messages
+ if message.persona is not MessagePersona.TOOL
+ ],
+ exclude={"tool_calls"},
+ ), # Filter out tool messages, to avoid LLM to summarize invisible messages (from the user perspective)
reminders=_pydantic_to_str(reminders),
)
@@ -297,7 +311,15 @@ class LlmModel(BaseSettings, env_prefix="prompts_llm_"):
self.synthesis_long_system_tpl,
claim=_pydantic_to_str(claim),
conversation_lang=CONFIG.workflow.conversation_lang,
- messages=_pydantic_to_str(messages),
+ messages=_pydantic_to_str(
+ [
+ message
+ for message in messages
+ if message.persona is not MessagePersona.TOOL
+ ],
+ exclude={"tool_calls"},
+ ), # Filter out tool messages, to avoid LLM to summarize invisible messages (from the user perspective)
+ reminders=_pydantic_to_str(reminders),
)
def citations(