Skip to content

Commit

Permalink
Avoid double-including error message in retry when Mode.TOOLS (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyanekhay-uta authored Mar 20, 2024
1 parent 6ecced4 commit c5c19fa
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions instructor/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
def reask_messages(response: ChatCompletion, mode: Mode, exception: Exception):
yield dump_message(response.choices[0].message)

# TODO: Give users more control on configuration
if mode == Mode.TOOLS:
for tool_call in response.choices[0].message.tool_calls: # type: ignore
yield {
Expand All @@ -34,9 +35,7 @@ def reask_messages(response: ChatCompletion, mode: Mode, exception: Exception):
"name": tool_call.function.name,
"content": f"Validation Error found:\n{exception}\nRecall the function correctly, fix the errors",
}

# TODO: Give users more control on configuration
if mode == Mode.MD_JSON:
elif mode == Mode.MD_JSON:
yield {
"role": "user",
"content": f"Correct your JSON ONLY RESPONSE, based on the following errors:\n{exception}",
Expand Down

0 comments on commit c5c19fa

Please sign in to comment.