-
Notifications
You must be signed in to change notification settings - Fork 654
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
WIP: Feature/function calling update #2700
base: main
Are you sure you want to change the base?
WIP: Feature/function calling update #2700
Conversation
@HaoyuWang4188 @Tushar-ml @YAMY1234 Can you review each other's code? #2576 |
99bb21f
to
25a03b0
Compare
25a03b0
to
63c3d4e
Compare
Sure! We’ll review each other’s code and collaborate to work out a great solution. 🚀 |
Hi! After a general review, I would like to initiate some discussions to help we determine the best solution: 1. Support for parallel_tool_calls OpenAI API supports
I tried to align these behaviours by set IMO, parallel_tool_calls should be supported in our function calling API (both static and stream).
2. Aligning Terms of model names
I prefer to change |
Please let me know your thoughts on the above discussion. @YAMY1234 @Thunderbeee @Tushar-ml @merrymercy |
Pull Request Description
Summary
This pull request introduces streaming modes for function calling within the OpenAI API integration, and updated the non-streaming framework for better extensibility. The changes include:
New Features:
FunctionCallParser
for robust and efficient parsing of function calls in both streaming and non-streaming contexts.parse_streaming_increment
method.Refactoring:
openai_api/adapter.py
to integrate streaming tool call parsing logic.openai_api/protocol.py
with additional models (ToolCallItem
,DeltaMessage
) to support streaming functionalities.Documentation:
Detailed Changes
docs/backend/function_calling_streaming.py
:python/sglang/srt/function_call_parser.py
:FunctionCallParser
,StreamingJSONParser
, and related utility functions to handle function calls during streaming responses.python/sglang/srt/openai_api/adapter.py
:FunctionCallParser
to enable real-time function call parsing during streaming response generation.python/sglang/srt/openai_api/protocol.py
:FunctionResponse
andToolCall
models to useOptional
fields for compatibility with the new parser.ToolCallItem
andDeltaMessage
models to streamline the representation of parsed tool calls and response deltas.Testing