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

perf: Optimize prompts by reducing blank spaces

Clémence Lesnéd49a6ccb2f7b
diff --git a/helpers/config_models/prompts.py b/helpers/config_models/prompts.py
index d9d8116..dc9a4f6 100644
--- a/helpers/config_models/prompts.py
+++ b/helpers/config_models/prompts.py
@@ -450,7 +450,7 @@ class LlmModel(BaseModel):
res += f"\n- {training.title}: {training.content}"
# Remove newlines to avoid hallucinations issues with GPT-4 Turbo
- res = " ".join(res.splitlines()).strip()
+ res = " ".join([line.strip() for line in res.splitlines()])
self._logger.debug(f"LLM prompt: {res}")
return res
diff --git a/models/message.py b/models/message.py
index bc5c72c..cb0378b 100644
--- a/models/message.py
+++ b/models/message.py
@@ -166,7 +166,7 @@ class MessageModel(BaseModel):
]
]:
# Removing newlines from the content to avoid hallucinations issues with GPT-4 Turbo
- content = " ".join(self.content.splitlines()).strip()
+ content = " ".join([line.strip() for line in self.content.splitlines()])
if self.persona == PersonaEnum.HUMAN:
return [