Skip to content

Commit 7ba8254

Browse files
committed
quality: Enhance synthesis by removing invisible context
From the user point of view.
1 parent b46db35 commit 7ba8254

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

helpers/config_models/prompts.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,14 @@ def sms_summary_system(
265265
self.sms_summary_system_tpl,
266266
claim=_pydantic_to_str(claim),
267267
conversation_lang=CONFIG.workflow.conversation_lang,
268-
messages=_pydantic_to_str(messages),
268+
messages=_pydantic_to_str(
269+
[
270+
message
271+
for message in messages
272+
if message.persona is not MessagePersona.TOOL
273+
],
274+
exclude={"tool_calls"},
275+
), # Filter out tool messages, to avoid LLM to summarize invisible messages (from the user perspective)
269276
reminders=_pydantic_to_str(reminders),
270277
)
271278

@@ -281,7 +288,14 @@ def synthesis_short_system(
281288
self.synthesis_short_system_tpl,
282289
claim=_pydantic_to_str(claim),
283290
conversation_lang=CONFIG.workflow.conversation_lang,
284-
messages=_pydantic_to_str(messages),
291+
messages=_pydantic_to_str(
292+
[
293+
message
294+
for message in messages
295+
if message.persona is not MessagePersona.TOOL
296+
],
297+
exclude={"tool_calls"},
298+
), # Filter out tool messages, to avoid LLM to summarize invisible messages (from the user perspective)
285299
reminders=_pydantic_to_str(reminders),
286300
)
287301

@@ -297,7 +311,15 @@ def synthesis_long_system(
297311
self.synthesis_long_system_tpl,
298312
claim=_pydantic_to_str(claim),
299313
conversation_lang=CONFIG.workflow.conversation_lang,
300-
messages=_pydantic_to_str(messages),
314+
messages=_pydantic_to_str(
315+
[
316+
message
317+
for message in messages
318+
if message.persona is not MessagePersona.TOOL
319+
],
320+
exclude={"tool_calls"},
321+
), # Filter out tool messages, to avoid LLM to summarize invisible messages (from the user perspective)
322+
reminders=_pydantic_to_str(reminders),
301323
)
302324

303325
def citations(

0 commit comments

Comments
 (0)