[GH-ISSUE #5256] openai ChatCompletionRequest missing tools field? #3291

Closed
opened 2026-04-12 13:51:27 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @bingo789 on GitHub (Jun 24, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/5256

What is the issue?

when i use ChatOpenAI client in langchain, ollama server receive:

{
	"messages": [{
		"content": "what is the weather in Boston?",
		"role": "user"
	}],
	"model": "llama3:8b-instruct-q4_0",
	"n": 1,
	"stream": false,
	"temperature": 0.0,
	"tools": [{
		"type": "function",
		"function": {
			"name": "tavily_search_results_json",
			"description": "A search engine optimized for comprehensive, accurate, and trusted results. Useful for when you need to answer questions about current events. Input should be a search query.",
			"parameters": {
				"type": "object",
				"properties": {
					"location": {
						"description": "The city and state, e.g. San Francisco, CA",
						"type": "string"
					}
				},
				"required": ["location"]
			}
		}
	}]
}

but in Middleware() funtion, it transform to ChatCompletionRequest, and ChatCompletionRequest have no tools field

type ChatCompletionRequest struct {
	Model            string          `json:"model"`
	Messages         []Message       `json:"messages"`
	Stream           bool            `json:"stream"`
	MaxTokens        *int            `json:"max_tokens"`
	Seed             *int            `json:"seed"`
	Stop             any             `json:"stop"`
	Temperature      *float64        `json:"temperature"`
	FrequencyPenalty *float64        `json:"frequency_penalty"`
	PresencePenalty  *float64        `json:"presence_penalty_penalty"`
	TopP             *float64        `json:"top_p"`
	ResponseFormat   *ResponseFormat `json:"response_format"`
}

func Middleware() gin.HandlerFunc {
	return func(c *gin.Context) {
		var req ChatCompletionRequest
		err := c.ShouldBindJSON(&req)
                 ......}

so i think it's not support function calling?

OS

macOS

GPU

Apple

CPU

Apple

Ollama version

v0.1.46

Originally created by @bingo789 on GitHub (Jun 24, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/5256 ### What is the issue? when i use ChatOpenAI client in langchain, ollama server receive: ``` { "messages": [{ "content": "what is the weather in Boston?", "role": "user" }], "model": "llama3:8b-instruct-q4_0", "n": 1, "stream": false, "temperature": 0.0, "tools": [{ "type": "function", "function": { "name": "tavily_search_results_json", "description": "A search engine optimized for comprehensive, accurate, and trusted results. Useful for when you need to answer questions about current events. Input should be a search query.", "parameters": { "type": "object", "properties": { "location": { "description": "The city and state, e.g. San Francisco, CA", "type": "string" } }, "required": ["location"] } } }] } ``` but in Middleware() funtion, it transform to ChatCompletionRequest, and ChatCompletionRequest have no tools field ``` type ChatCompletionRequest struct { Model string `json:"model"` Messages []Message `json:"messages"` Stream bool `json:"stream"` MaxTokens *int `json:"max_tokens"` Seed *int `json:"seed"` Stop any `json:"stop"` Temperature *float64 `json:"temperature"` FrequencyPenalty *float64 `json:"frequency_penalty"` PresencePenalty *float64 `json:"presence_penalty_penalty"` TopP *float64 `json:"top_p"` ResponseFormat *ResponseFormat `json:"response_format"` } func Middleware() gin.HandlerFunc { return func(c *gin.Context) { var req ChatCompletionRequest err := c.ShouldBindJSON(&req) ......} ``` so i think it's not support function calling? ### OS macOS ### GPU Apple ### CPU Apple ### Ollama version v0.1.46
GiteaMirror added the bug label 2026-04-12 13:51:27 -05:00
Author
Owner

@rusenask commented on GitHub (Jun 27, 2024):

yeah stumbled upon this too, I saw someone started https://github.com/ollama/ollama/pull/5284

<!-- gh-comment-id:2193969015 --> @rusenask commented on GitHub (Jun 27, 2024): yeah stumbled upon this too, I saw someone started https://github.com/ollama/ollama/pull/5284
Author
Owner

@dhiltgen commented on GitHub (Jul 24, 2024):

This has been added recently. Please upgrade to the latest version and the tools field is now present.

<!-- gh-comment-id:2248718017 --> @dhiltgen commented on GitHub (Jul 24, 2024): This has been added recently. Please upgrade to the latest version and the tools field is now present.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#3291