-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix non-function calls messages #5026
Conversation
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.
Except for some concern in adding function_calling_enabled
-- otherwise LGTM!
@@ -567,6 +567,7 @@ def format_messages_for_llm(self, messages: Message | list[Message]) -> list[dic | |||
for message in messages: | |||
message.cache_enabled = self.is_caching_prompt_active() | |||
message.vision_enabled = self.vision_is_active() | |||
message.function_calling_enabled = self.is_function_calling_active() |
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.
This will only be True for the selected set of model -- but we still send messages WITH tool_ids to the LLM
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.
Ahh so we need the part of the serializer that adds tool_call_id. OK, sure, I'll revert that. Sigh, this is messy. The attempt to separate things when function calling is native is because we need to send a single thing, not a list.
(I'll follow up on litellm too, they actually do this kind of conversion, so we don't have to play whack-a-mole anymore)
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.
@xingyaoww I actually restored this check, but it does send tool ids now. It just sends them as string, if non-native function calling, and as list if native. (because this applies now)
I started to work on refactoring the Message class. I think it needs to include tool calls/ids conversion part (at least as a single Message), do full serialization, and become closer to litellm's Message. I started to work on it on this branch, but in the meantime, I found out that people rely on this PR, and use it via docker because it solves what's broken with non-native function calling.
So I'll make another branch to work on the refactoring, and this PR is up for review again. If it's not too terrible, I'd say let's just fix the problems first, and refactor later.
(I'll clean up some leftover comment, too, but I prefer to do it if it's approved, because I think it would again break people's use via docker on the last commit.)
Co-authored-by: Xingyao Wang <[email protected]>
Co-authored-by: Xingyao Wang <[email protected]>
Co-authored-by: Xingyao Wang <[email protected]>
07c3643
to
ffca2b4
Compare
Updated the comment to note this fixes Fix #5142 |
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.
LGTM! Thanks!
End-user friendly description of the problem this fixes or functionality that this introduces
Give a summary of what the PR does, explaining any non-trivial design decisions
This PR proposes a refactoring of Messages and function calling. It will fix the LLMs without function calling enabled:
HF model example that works:
Link of any specific issues this addresses
Fix #4960
Fix #5090
Fix #5142
To run this PR locally, use the following command: