-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
General fixes for tool calling #2954
base: main
Are you sure you want to change the base?
Conversation
Necessary to keep compatibility with openai. The usage of tgi with openai compatible libraries for function calling was broken.
The streaming API for tool calling now starts when the name is parsed and then send arguments as token are generated and stops properly.
@Trofleb Do you happen to have the response handy for the non streaming aka |
@Datta0 We had the same issue, I added the samples for the non stream version to my initial message. |
Looking at other PR, maybe @OlivierDehaene or @Narsil can you review this ? |
It's one of the slight api differences. The code was allowing both arguments and parameters in function definition which is not the case with openai. It was a side effect of using the same struct for function definition and function call. By removing it I changed a bit the accepted values, making it closer to openai. Thinking about it now, I should have made it a non breaking change. I'll fix it if anyone thinks it's a problem. |
General fixes for tool calling
Tool calling was incompatible with the openai api on both the stream and non stream implementation.
Fixes:
Small changes
Fixes the following issues I think:
#2461
#2480
#2864
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Details
Arguments are now strings, as per openai's API
Open AI - non stream
Before - non stream
Now - non stream
Streaming has a particular behaviour for tool calling, I did my best to conform to what the openai api was giving out.
Open AI - stream
Before - stream
Now - stream
Testing
The test I could run seem to still pass ( I don't have a premium hugging face account - yet ;). I adapted the tests that needed to be adapted but I'm not sure how to add test for streaming. I welcome any help I can get on that front.
I did some tests by doing the following:
Other PR
A PR was created before I could make mine. As I went bit further I still wanted to finish mine. Of course I'm open to closing mine, or group our changes.
Review
Not sure who to tag here.
FYI: I'm by no means a rust expert and welcomes criticism/improvements.