From 077339939265691ee0be5d4d2eafae5b6ad41ea6 Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Thu, 7 Aug 2025 17:26:51 -0700 Subject: [PATCH] feat(ask_sb): Add reasoningEffort option to openai provider (#446) --- CHANGELOG.md | 1 + .../language-model-providers.mdx | 3 ++- docs/snippets/schemas/v3/index.schema.mdx | 20 +++++++++++++++++++ .../schemas/v3/languageModel.schema.mdx | 20 +++++++++++++++++++ packages/schemas/src/v3/index.schema.ts | 20 +++++++++++++++++++ packages/schemas/src/v3/index.type.ts | 4 ++++ .../schemas/src/v3/languageModel.schema.ts | 20 +++++++++++++++++++ packages/schemas/src/v3/languageModel.type.ts | 4 ++++ .../web/src/app/api/(server)/chat/route.ts | 2 +- schemas/v3/languageModel.json | 10 ++++++++++ 10 files changed, 102 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f6b03ff..e5e45747 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added multi-branch indexing support for Gerrit. [#433](https://github.com/sourcebot-dev/sourcebot/pull/433) +- [ask sb] Added `reasoningEffort` option to OpenAI provider. [#446](https://github.com/sourcebot-dev/sourcebot/pull/446) ### Fixed - Removed prefix from structured log output. [#443](https://github.com/sourcebot-dev/sourcebot/pull/443) diff --git a/docs/docs/configuration/language-model-providers.mdx b/docs/docs/configuration/language-model-providers.mdx index 1b442a43..514731ec 100644 --- a/docs/docs/configuration/language-model-providers.mdx +++ b/docs/docs/configuration/language-model-providers.mdx @@ -248,7 +248,8 @@ For a detailed description of all the providers, please refer to the [schema](ht "token": { "env": "OPENAI_API_KEY" }, - "baseUrl": "OPTIONAL_BASE_URL" + "baseUrl": "OPTIONAL_BASE_URL", + "reasoningEffort": "OPTIONAL_REASONING_EFFORT" // defaults to "medium" } ] } diff --git a/docs/snippets/schemas/v3/index.schema.mdx b/docs/snippets/schemas/v3/index.schema.mdx index e7b73cf9..6d64cc14 100644 --- a/docs/snippets/schemas/v3/index.schema.mdx +++ b/docs/snippets/schemas/v3/index.schema.mdx @@ -1818,6 +1818,16 @@ "format": "url", "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$", "description": "Optional base URL." + }, + "reasoningEffort": { + "type": "string", + "description": "The reasoning effort to use with the model. Defaults to `medium`. See https://platform.openai.com/docs/guides/reasoning#get-started-with-reasonings", + "examples": [ + "minimal", + "low", + "medium", + "high" + ] } }, "required": [ @@ -2624,6 +2634,16 @@ "format": "url", "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$", "description": "Optional base URL." + }, + "reasoningEffort": { + "type": "string", + "description": "The reasoning effort to use with the model. Defaults to `medium`. See https://platform.openai.com/docs/guides/reasoning#get-started-with-reasonings", + "examples": [ + "minimal", + "low", + "medium", + "high" + ] } }, "required": [ diff --git a/docs/snippets/schemas/v3/languageModel.schema.mdx b/docs/snippets/schemas/v3/languageModel.schema.mdx index 92b05568..f23ea8b9 100644 --- a/docs/snippets/schemas/v3/languageModel.schema.mdx +++ b/docs/snippets/schemas/v3/languageModel.schema.mdx @@ -615,6 +615,16 @@ "format": "url", "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$", "description": "Optional base URL." + }, + "reasoningEffort": { + "type": "string", + "description": "The reasoning effort to use with the model. Defaults to `medium`. See https://platform.openai.com/docs/guides/reasoning#get-started-with-reasonings", + "examples": [ + "minimal", + "low", + "medium", + "high" + ] } }, "required": [ @@ -1421,6 +1431,16 @@ "format": "url", "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$", "description": "Optional base URL." + }, + "reasoningEffort": { + "type": "string", + "description": "The reasoning effort to use with the model. Defaults to `medium`. See https://platform.openai.com/docs/guides/reasoning#get-started-with-reasonings", + "examples": [ + "minimal", + "low", + "medium", + "high" + ] } }, "required": [ diff --git a/packages/schemas/src/v3/index.schema.ts b/packages/schemas/src/v3/index.schema.ts index fd334a8a..5b0bf21a 100644 --- a/packages/schemas/src/v3/index.schema.ts +++ b/packages/schemas/src/v3/index.schema.ts @@ -1817,6 +1817,16 @@ const schema = { "format": "url", "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$", "description": "Optional base URL." + }, + "reasoningEffort": { + "type": "string", + "description": "The reasoning effort to use with the model. Defaults to `medium`. See https://platform.openai.com/docs/guides/reasoning#get-started-with-reasonings", + "examples": [ + "minimal", + "low", + "medium", + "high" + ] } }, "required": [ @@ -2623,6 +2633,16 @@ const schema = { "format": "url", "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$", "description": "Optional base URL." + }, + "reasoningEffort": { + "type": "string", + "description": "The reasoning effort to use with the model. Defaults to `medium`. See https://platform.openai.com/docs/guides/reasoning#get-started-with-reasonings", + "examples": [ + "minimal", + "low", + "medium", + "high" + ] } }, "required": [ diff --git a/packages/schemas/src/v3/index.type.ts b/packages/schemas/src/v3/index.type.ts index e76d54eb..bad1219a 100644 --- a/packages/schemas/src/v3/index.type.ts +++ b/packages/schemas/src/v3/index.type.ts @@ -792,6 +792,10 @@ export interface OpenAILanguageModel { * Optional base URL. */ baseUrl?: string; + /** + * The reasoning effort to use with the model. Defaults to `medium`. See https://platform.openai.com/docs/guides/reasoning#get-started-with-reasonings + */ + reasoningEffort?: string; } export interface OpenAICompatibleLanguageModel { /** diff --git a/packages/schemas/src/v3/languageModel.schema.ts b/packages/schemas/src/v3/languageModel.schema.ts index 63937fdb..075f2777 100644 --- a/packages/schemas/src/v3/languageModel.schema.ts +++ b/packages/schemas/src/v3/languageModel.schema.ts @@ -614,6 +614,16 @@ const schema = { "format": "url", "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$", "description": "Optional base URL." + }, + "reasoningEffort": { + "type": "string", + "description": "The reasoning effort to use with the model. Defaults to `medium`. See https://platform.openai.com/docs/guides/reasoning#get-started-with-reasonings", + "examples": [ + "minimal", + "low", + "medium", + "high" + ] } }, "required": [ @@ -1420,6 +1430,16 @@ const schema = { "format": "url", "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$", "description": "Optional base URL." + }, + "reasoningEffort": { + "type": "string", + "description": "The reasoning effort to use with the model. Defaults to `medium`. See https://platform.openai.com/docs/guides/reasoning#get-started-with-reasonings", + "examples": [ + "minimal", + "low", + "medium", + "high" + ] } }, "required": [ diff --git a/packages/schemas/src/v3/languageModel.type.ts b/packages/schemas/src/v3/languageModel.type.ts index 9e99042f..31968460 100644 --- a/packages/schemas/src/v3/languageModel.type.ts +++ b/packages/schemas/src/v3/languageModel.type.ts @@ -363,6 +363,10 @@ export interface OpenAILanguageModel { * Optional base URL. */ baseUrl?: string; + /** + * The reasoning effort to use with the model. Defaults to `medium`. See https://platform.openai.com/docs/guides/reasoning#get-started-with-reasonings + */ + reasoningEffort?: string; } export interface OpenAICompatibleLanguageModel { /** diff --git a/packages/web/src/app/api/(server)/chat/route.ts b/packages/web/src/app/api/(server)/chat/route.ts index 834bdc63..ae789272 100644 --- a/packages/web/src/app/api/(server)/chat/route.ts +++ b/packages/web/src/app/api/(server)/chat/route.ts @@ -440,7 +440,7 @@ const getAISDKLanguageModelAndOptions = async (config: LanguageModel, orgId: num model: openai(modelId), providerOptions: { openai: { - reasoningEffort: 'high' + reasoningEffort: config.reasoningEffort ?? 'medium' } satisfies OpenAIResponsesProviderOptions, }, }; diff --git a/schemas/v3/languageModel.json b/schemas/v3/languageModel.json index 65807e91..2acf9f64 100644 --- a/schemas/v3/languageModel.json +++ b/schemas/v3/languageModel.json @@ -343,6 +343,16 @@ "format": "url", "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$", "description": "Optional base URL." + }, + "reasoningEffort": { + "type": "string", + "description": "The reasoning effort to use with the model. Defaults to `medium`. See https://platform.openai.com/docs/guides/reasoning#get-started-with-reasonings", + "examples": [ + "minimal", + "low", + "medium", + "high" + ] } }, "required": [