Skip to content

[Feature] Function Calling - #2544

Merged
merrymercy merged 20 commits into
sgl-project:mainfrom
Tushar-ml:func-tooling
Dec 29, 2024
Merged

merrymercy merged 20 commits into
sgl-project:mainfrom
Tushar-ml:func-tooling

Conversation

@Tushar-ml

@Tushar-ml Tushar-ml commented Dec 22, 2024 •

Copy link
Copy Markdown
Contributor

Motivation

This PR provides support for function calling #2429 . Currently function tooling implemented for tokenizer apply_chat_template. Streaming not support as well for function tooling.

Modifications

Checklist

  • Format your code according to the Contributor Guide.
  • Add unit tests as outlined in the Contributor Guide.
  • Update documentation as needed, including docstrings or example tutorials.

Comment thread python/sglang/srt/openai_api/adapter.py Resolved
Comment thread python/sglang/srt/openai_api/adapter.py Resolved
Comment thread python/sglang/srt/openai_api/adapter.py Resolved
@HaoyuWang4188

Copy link
Copy Markdown
Contributor

Based on the communication in Slack, I have left some of my review comments. 😄
Would @Ying1123 please assign an official reviewer? Thank you!

@merrymercy merrymercy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! I left a few comments.

Comment thread docs/references/function_calling.md Resolved
Comment thread docs/references/function_calling.md Resolved
Comment thread docs/references/function_calling.md Resolved
Comment thread docs/references/function_calling.md Resolved
Comment thread python/sglang/srt/openai_api/adapter.py Resolved
Comment thread python/sglang/srt/openai_api/adapter.py Resolved
Comment thread python/sglang/srt/openai_api/adapter.py Resolved
@Tushar-ml

Copy link
Copy Markdown
Contributor Author

@merrymercy @Ying1123 The above comments have been resolved

@merrymercy merrymercy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some final minor comments! Then we can merge this.

Comment thread docs/backend/function_tooling.ipynb Resolved
Comment thread docs/references/function_calling.md Resolved
Comment thread docs/references/function_calling.md Resolved
@Tushar-ml

Copy link
Copy Markdown
Contributor Author

Done @merrymercy

@Tushar-ml Tushar-ml changed the title [Feature] Function Tooling [Feature] Function Caling Dec 29, 2024
@Tushar-ml Tushar-ml changed the title [Feature] Function Caling [Feature] Function Calling Dec 29, 2024
@merrymercy
merrymercy merged commit 8ee9a85 into sgl-project:main Dec 29, 2024
Aaron1011 added a commit to tensorzero/tensorzero that referenced this pull request Jan 15, 2025
This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.
Aaron1011 added a commit to tensorzero/tensorzero that referenced this pull request Jan 15, 2025
This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.
Aaron1011 added a commit to tensorzero/tensorzero that referenced this pull request Jan 15, 2025
This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.
Aaron1011 added a commit to tensorzero/tensorzero that referenced this pull request Jan 15, 2025
This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.
Aaron1011 added a commit to tensorzero/tensorzero that referenced this pull request Jan 15, 2025
This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.
Aaron1011 added a commit to tensorzero/tensorzero that referenced this pull request Jan 16, 2025
This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.
Aaron1011 added a commit to tensorzero/tensorzero that referenced this pull request Jan 16, 2025
This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.
Aaron1011 added a commit to tensorzero/tensorzero that referenced this pull request Jan 16, 2025
This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.
Aaron1011 added a commit to tensorzero/tensorzero that referenced this pull request Jan 16, 2025
This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.
github-merge-queue Bot pushed a commit to tensorzero/tensorzero that referenced this pull request Jan 16, 2025
This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.

Co-authored-by: Aaron Hill <[email protected]>
Co-authored-by: Viraj Mehta <[email protected]>
github-merge-queue Bot pushed a commit to tensorzero/tensorzero that referenced this pull request Jan 16, 2025
* Add SGLang provider

This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.

* Use SGLANG_API_KEY in merge-queue.yml

---------

Co-authored-by: Aaron Hill <[email protected]>
Co-authored-by: Viraj Mehta <[email protected]>
github-merge-queue Bot pushed a commit to tensorzero/tensorzero that referenced this pull request Jan 16, 2025
* Add SGLang provider

This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.

* Use SGLANG_API_KEY in merge-queue.yml

---------

Co-authored-by: Aaron Hill <[email protected]>
Co-authored-by: Viraj Mehta <[email protected]>
github-merge-queue Bot pushed a commit to tensorzero/tensorzero that referenced this pull request Jan 16, 2025
* Add SGLang provider

This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.

* Use SGLANG_API_KEY in merge-queue.yml

---------

Co-authored-by: Aaron Hill <[email protected]>
Co-authored-by: Viraj Mehta <[email protected]>
github-merge-queue Bot pushed a commit to tensorzero/tensorzero that referenced this pull request Jan 16, 2025
* Add SGLang provider

This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.

* Use SGLANG_API_KEY in merge-queue.yml

---------

Co-authored-by: Aaron Hill <[email protected]>
Co-authored-by: Viraj Mehta <[email protected]>
github-merge-queue Bot pushed a commit to tensorzero/tensorzero that referenced this pull request Jan 16, 2025
* Add SGLang provider

This is heavily based on the existing OpenAI provider.
Current limitations:
* SGLang only support JSON output when a json schema is provided,
  so both 'json_mode = on' and 'json_mode = strict' require a schema
  to be provided
* Tool use was just implemneted in sgl-project/sglang#2544,
  which is not yet released. For now, we pass through tool parameters using
  the standard OpenAI API, but log a warning.
* Only chat completions (with/without streaming) are currently implemented.

* Use SGLANG_API_KEY in merge-queue.yml

---------

Co-authored-by: Aaron Hill <[email protected]>
Co-authored-by: Viraj Mehta <[email protected]>
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants