A new parameter model called "native_tool_call" is added.
If false (the default), the behaviour when there are tools enabled doesn't change: a prompt is built which asks the model to generate a function call compatible with the offered tools. If it's valid the ouput is the added to the context.
If true, the native mechanism that the API has is used instead. That means that the responses have to be inspected to detect if a tool_call has to be handled and act accordingly. This allows more complex behaviours where the model can try several strategies and call tools knowing the output of others.
Ollama tool calling API only supports non streaming requests. In case both streaming and native_tool call are present, native tool calling is silently ignored.
Testing
The feature has been tested through the ui and using a script which calls these endpoints using
/api/chat/completions
/ollama/api/chat
With the OpenAI API, these models have been tested, with varying success
With the Ollama API, only llama3.2:3b has been tested.
These are prompts used with two functions provided:
get_current_time
get_sensor_data with a single argument which just returns the sensorid multiplied by two.
("what is the first letter of the latin alphabet", "no tools needed"),
("what is the date of today (use the get_current_time function)", " 1 tool no args"),
("what is the value of sensor 1", " 1 tool with args"),
("what are the value of sensors 1 and 4", " 2 tools (the may be run in parallel if the API supports it )"),
("if the value of sensors 1 is less that 5 m/s report the value of sensor 4. Otherwise report sensor 3", " 2 tools (in s
equence if the model does it )"),
("choose a integer between 1 an 10 write it here. If it's bigger that 5 report sensor 4. Otherwise report sensor 1", " tool call after having generated some text"),
("what is the value of sensor 'HELLO' ", "tool call raises an exception")
The full output is attached to the PR.
Before submitting, make sure you've checked the following:
Target branch: Please verify that the pull request targets the dev branch.
Description: Provide a concise description of the changes made in this pull request.
Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
[-] Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
If the PR gets accepted, I will update the docs accordingly.
Dependencies: Are there any new dependencies? Have you updated the dependency versions in the docume
ntation?
Testing: Have you written and run sufficient tests for validating the changes?
Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
Prefix: To cleary categorize this pull request, prefix the pull request title, using one of the following:
BREAKING CHANGE: Significant changes that may affect compatibility
build: Changes that affect the build system or external dependencies
ci: Changes to our continuous integration processes or workflows
chore: Refactor, cleanup, or other non-functional code changes
docs: Documentation update or addition
feat: Introduces a new feature or enhancement to the codebase
fix: Bug fix or error correction
i18n: Internationalization or localization changes
perf: Performance improvement
refactor: Code restructuring for better maintainability, readability, or scalability
style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)
test: Adding missing tests or correcting existing tests
WIP: Work in progress, a temporary label for incomplete or ongoing work
Changelog Entry
Description
A new parameter model called "native_tool_call" is added. If set to true, the tool calls are performed using the API and not the prompt based approach used until now.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/6836
**Author:** [@smonux](https://github.com/smonux)
**Created:** 11/10/2024
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `dev`
---
### 📝 Commits (1)
- [`6ab6379`](https://github.com/open-webui/open-webui/commit/6ab637965b196465169443a6fcb03c5591740d1c) feat: A new parameter model called "native_tool_call" is present.
### 📊 Changes
**6 files changed** (+346 additions, -39 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/apps/ollama/main.py` (+2 -0)
📝 `backend/open_webui/apps/openai/main.py` (+4 -0)
📝 `backend/open_webui/main.py` (+294 -39)
📝 `backend/open_webui/utils/payload.py` (+2 -0)
📝 `src/lib/components/chat/Chat.svelte` (+13 -0)
📝 `src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte` (+31 -0)
</details>
### 📄 Description
(squashed commit for easier review)
A new parameter model called "native_tool_call" is added.
If false (the default), the behaviour when there are tools enabled doesn't change: a prompt is built which asks the model to generate a function call compatible with the offered tools. If it's valid the ouput is the added to the context.
If true, the native mechanism that the API has is used instead. That means that the responses have to be inspected to detect if a tool_call has to be handled and act accordingly. This allows more complex behaviours where the model can try several strategies and call tools knowing the output of others.
Ollama tool calling API only supports non streaming requests. In case both streaming and native_tool call are present, native tool calling is silently ignored.
## Testing
The feature has been tested through the ui and using a script which calls these endpoints using
/api/chat/completions
/ollama/api/chat
With the OpenAI API, these models have been tested, with varying success
- OK
gpt-4o-mini
qwen/qwen-2.5-72b-instruct (OpenRouter endpoint)
anthropic/claude-3-haiku (OpenRouter endpoint)
deepseek/deepseek-chat (OpenRouter endpoint)
google/gemini-pro (OpenRouter endpoint)
- Partial support
cohere/command-r-plus (OpenRouter endpoint)
-Fails
meta-llama/llama-3.1-70b-instruct (OpenRouter endpoint)
With the Ollama API, only llama3.2:3b has been tested.
These are prompts used with two functions provided:
- get_current_time
- get_sensor_data with a single argument which just returns the sensorid multiplied by two.
```
("what is the first letter of the latin alphabet", "no tools needed"),
("what is the date of today (use the get_current_time function)", " 1 tool no args"),
("what is the value of sensor 1", " 1 tool with args"),
("what are the value of sensors 1 and 4", " 2 tools (the may be run in parallel if the API supports it )"),
("if the value of sensors 1 is less that 5 m/s report the value of sensor 4. Otherwise report sensor 3", " 2 tools (in s
equence if the model does it )"),
("choose a integer between 1 an 10 write it here. If it's bigger that 5 report sensor 4. Otherwise report sensor 1", " tool call after having generated some text"),
("what is the value of sensor 'HELLO' ", "tool call raises an exception")
```
The full output is attached to the PR.
**Before submitting, make sure you've checked the following:**
- [X] **Target branch:** Please verify that the pull request targets the `dev` branch.
- [X] **Description:** Provide a concise description of the changes made in this pull request.
- [X] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description.
- [-] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources?
If the PR gets accepted, I will update the docs accordingly.
- [X] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the docume
ntation?
- [X] **Testing:** Have you written and run sufficient tests for validating the changes?
- [X] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
- [X] **Prefix:** To cleary categorize this pull request, prefix the pull request title, using one of the following:
- **BREAKING CHANGE**: Significant changes that may affect compatibility
- **build**: Changes that affect the build system or external dependencies
- **ci**: Changes to our continuous integration processes or workflows
- **chore**: Refactor, cleanup, or other non-functional code changes
- **docs**: Documentation update or addition
- **feat**: Introduces a new feature or enhancement to the codebase
- **fix**: Bug fix or error correction
- **i18n**: Internationalization or localization changes
- **perf**: Performance improvement
- **refactor**: Code restructuring for better maintainability, readability, or scalability
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)
- **test**: Adding missing tests or correcting existing tests
- **WIP**: Work in progress, a temporary label for incomplete or ongoing work
# Changelog Entry
### Description
A new parameter model called "native_tool_call" is added. If set to true, the tool calls are performed using the API and not the prompt based approach used until now.
[output.txt](https://github.com/user-attachments/files/17691240/output.txt)
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/6836
Author: @smonux
Created: 11/10/2024
Status: ❌ Closed
Base:
dev← Head:dev📝 Commits (1)
6ab6379feat: A new parameter model called "native_tool_call" is present.📊 Changes
6 files changed (+346 additions, -39 deletions)
View changed files
📝
backend/open_webui/apps/ollama/main.py(+2 -0)📝
backend/open_webui/apps/openai/main.py(+4 -0)📝
backend/open_webui/main.py(+294 -39)📝
backend/open_webui/utils/payload.py(+2 -0)📝
src/lib/components/chat/Chat.svelte(+13 -0)📝
src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte(+31 -0)📄 Description
(squashed commit for easier review)
A new parameter model called "native_tool_call" is added.
If false (the default), the behaviour when there are tools enabled doesn't change: a prompt is built which asks the model to generate a function call compatible with the offered tools. If it's valid the ouput is the added to the context.
If true, the native mechanism that the API has is used instead. That means that the responses have to be inspected to detect if a tool_call has to be handled and act accordingly. This allows more complex behaviours where the model can try several strategies and call tools knowing the output of others.
Ollama tool calling API only supports non streaming requests. In case both streaming and native_tool call are present, native tool calling is silently ignored.
Testing
The feature has been tested through the ui and using a script which calls these endpoints using
/api/chat/completions
/ollama/api/chat
With the OpenAI API, these models have been tested, with varying success
gpt-4o-mini
qwen/qwen-2.5-72b-instruct (OpenRouter endpoint)
anthropic/claude-3-haiku (OpenRouter endpoint)
deepseek/deepseek-chat (OpenRouter endpoint)
google/gemini-pro (OpenRouter endpoint)
cohere/command-r-plus (OpenRouter endpoint)
-Fails
meta-llama/llama-3.1-70b-instruct (OpenRouter endpoint)
With the Ollama API, only llama3.2:3b has been tested.
These are prompts used with two functions provided:
The full output is attached to the PR.
Before submitting, make sure you've checked the following:
devbranch.If the PR gets accepted, I will update the docs accordingly.
ntation?
Changelog Entry
Description
A new parameter model called "native_tool_call" is added. If set to true, the tool calls are performed using the API and not the prompt based approach used until now.
output.txt
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.