From 4fb0e3fea0e6442ce32e48a50406655e46e37efa Mon Sep 17 00:00:00 2001 From: Piotr Czekaj Date: Mon, 10 Feb 2025 09:52:18 +0100 Subject: [PATCH] Add tools support for o3-mini o3-mini will fail with `Unsupported parameter: 'parallel_tool_calls' is not supported with this model.` if parallel_tool_calls is specified --- core/llm/llms/OpenAI.ts | 2 +- core/llm/toolSupport.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/llm/llms/OpenAI.ts b/core/llm/llms/OpenAI.ts index e0acc961e..73bade7b0 100644 --- a/core/llm/llms/OpenAI.ts +++ b/core/llm/llms/OpenAI.ts @@ -267,7 +267,7 @@ class OpenAI extends BaseLLM { body.max_completion_tokens = undefined; } - if (body.tools?.length) { + if (body.tools?.length && !body.model?.startsWith("o3")) { // To ensure schema adherence: https://platform.openai.com/docs/guides/function-calling#parallel-function-calling-and-structured-outputs // In practice, setting this to true and asking for multiple tool calls // leads to "arguments" being something like '{"file": "test.ts"}{"file": "test.js"}' diff --git a/core/llm/toolSupport.ts b/core/llm/toolSupport.ts index dd8f72fb0..9b93fa279 100644 --- a/core/llm/toolSupport.ts +++ b/core/llm/toolSupport.ts @@ -13,7 +13,7 @@ export const PROVIDER_TOOL_SUPPORT: Record< }, openai: (model) => { // https://platform.openai.com/docs/guides/function-calling#models-supporting-function-calling - if (model.toLowerCase().startsWith("gpt-4")) { + if (model.toLowerCase().startsWith("gpt-4") || model.toLowerCase().startsWith("o3")) { return true; } },