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: Fine-tune prompt completion validation feedback

Clémence Lesnéaab914a27112
diff --git a/helpers/llm_worker.py b/helpers/llm_worker.py
index 1e94af4..ee8ee73 100644
--- a/helpers/llm_worker.py
+++ b/helpers/llm_worker.py
@@ -257,20 +257,16 @@ async def completion_sync(
# Initialize prompts
messages = system
if _validation_error:
- messages.append(
- ChatCompletionSystemMessageParam(
- role="system",
- content=f"""
- A validation error occurred during the previous attempt.
-
- # Previous result
- {_previous_result or "N/A"}
-
- # Error details
- {_validation_error}
- """,
- )
- )
+ messages += [
+ ChatCompletionAssistantMessageParam(
+ content=_previous_result or "",
+ role="assistant",
+ ),
+ ChatCompletionUserMessageParam(
+ content=f"A validation error occurred, please retry: {_validation_error}",
+ role="user",
+ ),
+ ]
# Generate
res_content: Optional[str] = await _completion_sync_worker(