Skip to content

Commit

Permalink
fix: with structured output we need to convert the pydantic object ba…
Browse files Browse the repository at this point in the history
…ck to json for retries
  • Loading branch information
provos committed Oct 10, 2024
1 parent 4cd1ee3 commit 5d24751
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/planai/llm_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ def generate_pydantic(
if extra_validation:
extra_error_message = extra_validation(response)
if extra_error_message:
if self.support_structured_outputs:
# the raw response was a pydantic object, so we need to dump it to a string
raw_response = raw_response.model_dump_json()
messages.extend(
[
{"role": "assistant", "content": raw_response},
Expand Down

0 comments on commit 5d24751

Please sign in to comment.