-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ToolCalling actions are no longer being recognised from model response #992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
ToolCalling actions are no longer being recognised from model response #992
Conversation
bac939e
to
2c4bdc8
Compare
@sysradium e432d41#diff-0319e64c7d0f9e302a7c7a0dd60f04dedb7d4dcf7dbe9e046543335654a9efa1R893 did not change the LiteLLM class, so the issue must date back before: it seems to affect all models where the underlying API does not properly return tool calls, where tool calls must be "manually" parsed. |
2c4bdc8
to
a789575
Compare
@aymeric-roucher largely the PR became redundant. However I decided to update a few things still. The model quite often jumps between Also before json parsing used to fail if the remainder of the output not only contained some garbage, but hat an invalid json payload, like:
My version fixes that. |
a789575
to
70a26a6
Compare
Sorry, rebased once again instead of merging the main in, as asked by @albertvillanova before. |
@@ -228,16 +231,23 @@ def get_clean_message_list( | |||
return output_message_list | |||
|
|||
|
|||
def get_tool_call_from_text(text: str, tool_name_key: str, tool_arguments_key: str) -> ChatMessageToolCall: | |||
def get_tool_call_from_text( | |||
text: str, tool_name_key: str, tool_arguments_key: Union[list[str], str] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I understood well the last argument should betool_arguments_keys
instead of tool_arguments_key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to keep the name not to break anything. As you can see it's either a list or a single value
src/smolagents/utils.py
Outdated
break | ||
|
||
if end_index is None: | ||
raise ValueError("No complete JSON object found: braces are not balanced.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting to use parity for this! It seems the only case where this message would appear i when the brace count went up and did never go down to zero, i.e. more braces were opened than closed: maybe mention it, as in "caution: not all opened braces were closed?"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I improved the error reporting as well as the algorithm a bit and added a few more test-cases.
70a26a6
to
1aed4d5
Compare
@aymeric-roucher
I think it has been another ToolCallingAgent related regression coming from:
e432d41#diff-0319e64c7d0f9e302a7c7a0dd60f04dedb7d4dcf7dbe9e046543335654a9efa1R893
Looks like you made your mind to remove ToolCallingAgent support :)
Basically if a model returns
Action:\n{}
it does not get mapped into tool_calls here https://github.com/huggingface/smolagents/blob/main/src/smolagents/models.py#L987-L987And hence it keeps indefinitely failing here: https://github.com/huggingface/smolagents/blob/main/src/smolagents/agents.py#L1066-L1066
I came across this problem by playing with: