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

fix: Avoid some hallucinations by removing line returns from tools calls

Clémence Lesné449570491718
diff --git a/helpers/llm_tools.py b/helpers/llm_tools.py
index 045955e..480cd77 100644
--- a/helpers/llm_tools.py
+++ b/helpers/llm_tools.py
@@ -74,8 +74,9 @@ def function_schema(f: Callable[..., Any]) -> ChatCompletionToolParam:
+ f"The annotations are missing for the following parameters: {', '.join(missing_s)}"
)
- description = f.__doc__ or ""
- name = f.__name__
+ # Removing newlines from the content to avoid hallucinations issues with GPT-4 Turbo
+ description = " ".join((f.__doc__ or "").splitlines()).strip()
+ name = " ".join((f.__name__).splitlines()).strip()
parameters: dict[str, object] = _parameters(
required, param_annotations, default_values=default_values
).model_dump()