Skip to content

Commit

Permalink
fix: Inform the LLM when the claim update is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Jan 30, 2024
1 parent e4f0cc6 commit 6902b8b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,12 +942,10 @@ def _error_response() -> Tuple[CallModel, ActionModel]:
content = f'Failed to update a non-editable field "{parameters['field']}".'
else:
try:
# Define the field
setattr(
call.claim, parameters["field"], parameters["value"]
)
# Trigger a re-validation to spot errors before saving
ClaimModel.model_validate(call.claim)
# Define the field and force to trigger validation
copy = call.claim.model_dump()
copy[parameters["field"]] = parameters["value"]
call.claim = ClaimModel.model_validate(copy)
except ValidationError as e:
content = f'Failed to edit field "{parameters["field"]}": {e.json()}'
if not content:
Expand Down

0 comments on commit 6902b8b

Please sign in to comment.