mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
feat(openai): add setting to disable native tool calling for models that do not support it
- Add openAiDisableNativeTools setting to provider-settings schema - Modify OpenAiHandler.getModel() to respect the new setting - Expand DeepSeek reasoner detection to include deepseek-r1 pattern - Add UI checkbox in OpenAI Compatible settings - Add translations for the new setting in all 18 supported locales This addresses the issue where DeepSeek-R1 and similar models return 400 errors when native function calling (tools) is included in the request. Users can now explicitly disable native tools via a setting, giving them control when model name detection is insufficient (e.g., custom models or proxies). Closes #10368
This commit is contained in:
parent
add06a2e7b
commit
ac0c694dff
21 changed files with 60 additions and 0 deletions
|
|
@ -244,6 +244,7 @@ const openAiSchema = baseProviderSettingsSchema.extend({
|
|||
openAiApiKey: z.string().optional(),
|
||||
openAiLegacyFormat: z.boolean().optional(),
|
||||
openAiR1FormatEnabled: z.boolean().optional(),
|
||||
openAiDisableNativeTools: z.boolean().optional(),
|
||||
openAiModelId: z.string().optional(),
|
||||
openAiCustomModelInfo: modelInfoSchema.nullish(),
|
||||
openAiUseAzure: z.boolean().optional(),
|
||||
|
|
|
|||
|
|
@ -292,12 +292,23 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
|
|||
|
||||
override getModel() {
|
||||
const id = this.options.openAiModelId ?? ""
|
||||
const enabledR1Format = this.options.openAiR1FormatEnabled ?? false
|
||||
const disableNativeTools = this.options.openAiDisableNativeTools ?? false
|
||||
|
||||
// Detect DeepSeek reasoner models that don't support native tool calling
|
||||
const isDeepSeekReasoner =
|
||||
id.includes("deepseek-reasoner") || id.includes("deepseek-r1") || enabledR1Format
|
||||
|
||||
// Ensure OpenAI-compatible models default to supporting native tool calling.
|
||||
// This is required for [`Task.attemptApiRequest()`](src/core/task/Task.ts:3817) to
|
||||
// include tool definitions in the request.
|
||||
// However, disable native tools for DeepSeek reasoner models or when explicitly disabled
|
||||
// by the user, as these models don't support function calling and will return 400 errors.
|
||||
const info: ModelInfo = {
|
||||
...NATIVE_TOOL_DEFAULTS,
|
||||
...(this.options.openAiCustomModelInfo ?? openAiModelInfoSaneDefaults),
|
||||
// Override: Disable native tools if user setting is enabled or model is a DeepSeek reasoner
|
||||
...((disableNativeTools || isDeepSeekReasoner) && { supportsNativeTools: false }),
|
||||
}
|
||||
const params = getModelParams({ format: "openai", modelId: id, model: info, settings: this.options })
|
||||
return { id, info, ...params }
|
||||
|
|
|
|||
|
|
@ -155,6 +155,18 @@ export const OpenAICompatible = ({
|
|||
onChange={handleInputChange("openAiR1FormatEnabled", noTransform)}
|
||||
openAiR1FormatEnabled={apiConfiguration?.openAiR1FormatEnabled ?? false}
|
||||
/>
|
||||
<div>
|
||||
<div className="flex items-center gap-1">
|
||||
<Checkbox
|
||||
checked={apiConfiguration?.openAiDisableNativeTools ?? false}
|
||||
onChange={handleInputChange("openAiDisableNativeTools", noTransform)}>
|
||||
<span className="font-medium">{t("settings:modelInfo.disableNativeTools")}</span>
|
||||
</Checkbox>
|
||||
</div>
|
||||
<p className="text-vscode-descriptionForeground text-sm mt-0 ml-6">
|
||||
{t("settings:modelInfo.disableNativeToolsTips")}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<Checkbox
|
||||
checked={openAiLegacyFormatSelected}
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/ca/settings.json
generated
2
webview-ui/src/i18n/locales/ca/settings.json
generated
|
|
@ -860,6 +860,8 @@
|
|||
"enableStreaming": "Habilitar streaming",
|
||||
"enableR1Format": "Activar els paràmetres del model R1",
|
||||
"enableR1FormatTips": "S'ha d'activat quan s'utilitzen models R1 com el QWQ per evitar errors 400",
|
||||
"disableNativeTools": "Desactivar les crides a eines natives",
|
||||
"disableNativeToolsTips": "Activeu aquesta opció si el vostre model no admet les crides a funcions (ús d'eines). Quan estigui desactivat, Roo utilitzarà definicions d'eines basades en XML. Requerit per a DeepSeek-R1 i models similars.",
|
||||
"useAzure": "Utilitzar Azure",
|
||||
"azureApiVersion": "Establir versió de l'API d'Azure",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/de/settings.json
generated
2
webview-ui/src/i18n/locales/de/settings.json
generated
|
|
@ -860,6 +860,8 @@
|
|||
"enableStreaming": "Streaming aktivieren",
|
||||
"enableR1Format": "R1-Modellparameter aktivieren",
|
||||
"enableR1FormatTips": "Muss bei Verwendung von R1-Modellen wie QWQ aktiviert werden, um 400er-Fehler zu vermeiden",
|
||||
"disableNativeTools": "Native Tool-Aufrufe deaktivieren",
|
||||
"disableNativeToolsTips": "Aktivieren Sie diese Option, wenn Ihr Modell keine Funktionsaufrufe (Tool-Nutzung) unterstützt. Bei Deaktivierung verwendet Roo XML-basierte Tool-Definitionen. Erforderlich für DeepSeek-R1 und ähnliche Modelle.",
|
||||
"useAzure": "Azure verwenden",
|
||||
"azureApiVersion": "Azure API-Version festlegen",
|
||||
"gemini": {
|
||||
|
|
|
|||
|
|
@ -869,6 +869,8 @@
|
|||
"enableStreaming": "Enable streaming",
|
||||
"enableR1Format": "Enable R1 model parameters",
|
||||
"enableR1FormatTips": "Must be enabled when using R1 models such as QWQ to prevent 400 errors",
|
||||
"disableNativeTools": "Disable native tool calling",
|
||||
"disableNativeToolsTips": "Enable this if your model does not support function calling (tool use). When disabled, Roo will use XML-based tool definitions instead. Required for DeepSeek-R1 and similar models.",
|
||||
"useAzure": "Use Azure",
|
||||
"azureApiVersion": "Set Azure API version",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/es/settings.json
generated
2
webview-ui/src/i18n/locales/es/settings.json
generated
|
|
@ -860,6 +860,8 @@
|
|||
"enableStreaming": "Habilitar streaming",
|
||||
"enableR1Format": "Habilitar parámetros del modelo R1",
|
||||
"enableR1FormatTips": "Debe habilitarse al utilizar modelos R1 como QWQ, para evitar el error 400",
|
||||
"disableNativeTools": "Deshabilitar llamadas de herramientas nativas",
|
||||
"disableNativeToolsTips": "Habilite esta opción si su modelo no admite llamadas de función (uso de herramientas). Cuando está deshabilitado, Roo usará definiciones de herramientas basadas en XML. Requerido para DeepSeek-R1 y modelos similares.",
|
||||
"useAzure": "Usar Azure",
|
||||
"azureApiVersion": "Establecer versión de API de Azure",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/fr/settings.json
generated
2
webview-ui/src/i18n/locales/fr/settings.json
generated
|
|
@ -860,6 +860,8 @@
|
|||
"enableStreaming": "Activer le streaming",
|
||||
"enableR1Format": "Activer les paramètres du modèle R1",
|
||||
"enableR1FormatTips": "Doit être activé lors de l'utilisation de modèles R1 tels que QWQ, pour éviter l'erreur 400",
|
||||
"disableNativeTools": "Désactiver les appels d'outils natifs",
|
||||
"disableNativeToolsTips": "Activez cette option si votre modèle ne prend pas en charge les appels de fonction (utilisation d'outils). Lorsque désactivé, Roo utilisera des définitions d'outils basées sur XML. Requis pour DeepSeek-R1 et les modèles similaires.",
|
||||
"useAzure": "Utiliser Azure",
|
||||
"azureApiVersion": "Définir la version de l'API Azure",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/hi/settings.json
generated
2
webview-ui/src/i18n/locales/hi/settings.json
generated
|
|
@ -861,6 +861,8 @@
|
|||
"enableStreaming": "स्ट्रीमिंग सक्षम करें",
|
||||
"enableR1Format": "R1 मॉडल पैरामीटर सक्षम करें",
|
||||
"enableR1FormatTips": "QWQ जैसी R1 मॉडलों का उपयोग करते समय इसे सक्षम करना आवश्यक है, ताकि 400 त्रुटि से बचा जा सके",
|
||||
"disableNativeTools": "मूल टूल कॉल अक्षम करें",
|
||||
"disableNativeToolsTips": "यदि आपका मॉडल फ़ंक्शन कॉलिंग (टूल उपयोग) का समर्थन नहीं करता है तो इस विकल्प को सक्षम करें। अक्षम होने पर, Roo XML-आधारित टूल परिभाषाओं का उपयोग करेगा। DeepSeek-R1 और इसी तरह के मॉडलों के लिए आवश्यक।",
|
||||
"useAzure": "Azure का उपयोग करें",
|
||||
"azureApiVersion": "Azure API संस्करण सेट करें",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/id/settings.json
generated
2
webview-ui/src/i18n/locales/id/settings.json
generated
|
|
@ -890,6 +890,8 @@
|
|||
"enableStreaming": "Aktifkan streaming",
|
||||
"enableR1Format": "Aktifkan parameter model R1",
|
||||
"enableR1FormatTips": "Harus diaktifkan saat menggunakan model R1 seperti QWQ untuk mencegah error 400",
|
||||
"disableNativeTools": "Nonaktifkan panggilan alat native",
|
||||
"disableNativeToolsTips": "Aktifkan opsi ini jika model Anda tidak mendukung panggilan fungsi (penggunaan alat). Ketika dinonaktifkan, Roo akan menggunakan definisi alat berbasis XML. Diperlukan untuk DeepSeek-R1 dan model serupa.",
|
||||
"useAzure": "Gunakan Azure",
|
||||
"azureApiVersion": "Atur versi API Azure",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/it/settings.json
generated
2
webview-ui/src/i18n/locales/it/settings.json
generated
|
|
@ -861,6 +861,8 @@
|
|||
"enableStreaming": "Abilita streaming",
|
||||
"enableR1Format": "Abilita i parametri del modello R1",
|
||||
"enableR1FormatTips": "Deve essere abilitato quando si utilizzano modelli R1 come QWQ, per evitare l'errore 400",
|
||||
"disableNativeTools": "Disabilita chiamate strumenti nativi",
|
||||
"disableNativeToolsTips": "Abilita questa opzione se il tuo modello non supporta le chiamate di funzione (uso strumenti). Quando disabilitato, Roo utilizzerà definizioni di strumenti basate su XML. Richiesto per DeepSeek-R1 e modelli simili.",
|
||||
"useAzure": "Usa Azure",
|
||||
"azureApiVersion": "Imposta versione API Azure",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/ja/settings.json
generated
2
webview-ui/src/i18n/locales/ja/settings.json
generated
|
|
@ -861,6 +861,8 @@
|
|||
"enableStreaming": "ストリーミングを有効化",
|
||||
"enableR1Format": "R1モデルパラメータを有効にする",
|
||||
"enableR1FormatTips": "QWQなどのR1モデルを使用する際には、有効にする必要があります。400エラーを防ぐために",
|
||||
"disableNativeTools": "ネイティブツール呼び出しを無効化",
|
||||
"disableNativeToolsTips": "モデルが関数呼び出し(ツール使用)をサポートしていない場合は、これを有効にしてください。無効にすると、RooはXMLベースのツール定義を使用します。DeepSeek-R1や類似のモデルに必要です。",
|
||||
"useAzure": "Azureを使用",
|
||||
"azureApiVersion": "Azure APIバージョンを設定",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/ko/settings.json
generated
2
webview-ui/src/i18n/locales/ko/settings.json
generated
|
|
@ -861,6 +861,8 @@
|
|||
"enableStreaming": "스트리밍 활성화",
|
||||
"enableR1Format": "R1 모델 매개변수 활성화",
|
||||
"enableR1FormatTips": "QWQ와 같은 R1 모델을 사용할 때 활성화해야 하며, 400 오류를 방지합니다",
|
||||
"disableNativeTools": "네이티브 도구 호출 비활성화",
|
||||
"disableNativeToolsTips": "모델이 함수 호출(도구 사용)을 지원하지 않는 경우 이 옵션을 활성화하세요. 비활성화하면 Roo가 XML 기반 도구 정의를 사용합니다. DeepSeek-R1 및 유사 모델에 필요합니다.",
|
||||
"useAzure": "Azure 사용",
|
||||
"azureApiVersion": "Azure API 버전 설정",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/nl/settings.json
generated
2
webview-ui/src/i18n/locales/nl/settings.json
generated
|
|
@ -861,6 +861,8 @@
|
|||
"enableStreaming": "Streaming inschakelen",
|
||||
"enableR1Format": "R1-modelparameters inschakelen",
|
||||
"enableR1FormatTips": "Moet ingeschakeld zijn bij gebruik van R1-modellen zoals QWQ om 400-fouten te voorkomen",
|
||||
"disableNativeTools": "Schakel native tool-aanroepen uit",
|
||||
"disableNativeToolsTips": "Schakel deze optie in als uw model geen functie-aanroepen (tool-gebruik) ondersteunt. Wanneer uitgeschakeld, gebruikt Roo XML-gebaseerde tool-definities. Vereist voor DeepSeek-R1 en vergelijkbare modellen.",
|
||||
"useAzure": "Azure gebruiken",
|
||||
"azureApiVersion": "Azure API-versie instellen",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/pl/settings.json
generated
2
webview-ui/src/i18n/locales/pl/settings.json
generated
|
|
@ -861,6 +861,8 @@
|
|||
"enableStreaming": "Włącz strumieniowanie",
|
||||
"enableR1Format": "Włącz parametry modelu R1",
|
||||
"enableR1FormatTips": "Należy włączyć podczas korzystania z modeli R1, takich jak QWQ, aby uniknąć błędu 400",
|
||||
"disableNativeTools": "Wyłącz natywne wywołania narzędzi",
|
||||
"disableNativeToolsTips": "Włącz tę opcję, jeśli Twój model nie obsługuje wywołań funkcji (użycie narzędzi). Po wyłączeniu Roo będzie używać definicji narzędzi opartych na XML. Wymagane dla DeepSeek-R1 i podobnych modeli.",
|
||||
"useAzure": "Użyj Azure",
|
||||
"azureApiVersion": "Ustaw wersję API Azure",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/pt-BR/settings.json
generated
2
webview-ui/src/i18n/locales/pt-BR/settings.json
generated
|
|
@ -861,6 +861,8 @@
|
|||
"enableStreaming": "Ativar streaming",
|
||||
"enableR1Format": "Ativar parâmetros do modelo R1",
|
||||
"enableR1FormatTips": "Deve ser ativado ao usar modelos R1 como QWQ, para evitar erro 400",
|
||||
"disableNativeTools": "Desativar chamadas de ferramentas nativas",
|
||||
"disableNativeToolsTips": "Ative esta opção se seu modelo não suportar chamadas de função (uso de ferramentas). Quando desativado, Roo usará definições de ferramentas baseadas em XML. Necessário para DeepSeek-R1 e modelos similares.",
|
||||
"useAzure": "Usar Azure",
|
||||
"azureApiVersion": "Definir versão da API Azure",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/ru/settings.json
generated
2
webview-ui/src/i18n/locales/ru/settings.json
generated
|
|
@ -861,6 +861,8 @@
|
|||
"enableStreaming": "Включить потоковую передачу",
|
||||
"enableR1Format": "Включить параметры модели R1",
|
||||
"enableR1FormatTips": "Необходимо включить при использовании моделей R1 (например, QWQ), чтобы избежать ошибок 400",
|
||||
"disableNativeTools": "Отключить нативные вызовы инструментов",
|
||||
"disableNativeToolsTips": "Включите эту опцию, если ваша модель не поддерживает вызовы функций (использование инструментов). При отключении Roo будет использовать XML-определения инструментов. Требуется для DeepSeek-R1 и подобных моделей.",
|
||||
"useAzure": "Использовать Azure",
|
||||
"azureApiVersion": "Установить версию API Azure",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/tr/settings.json
generated
2
webview-ui/src/i18n/locales/tr/settings.json
generated
|
|
@ -861,6 +861,8 @@
|
|||
"enableStreaming": "Akışı etkinleştir",
|
||||
"enableR1Format": "R1 model parametrelerini etkinleştir",
|
||||
"enableR1FormatTips": "QWQ gibi R1 modelleri kullanıldığında etkinleştirilmelidir, 400 hatası alınmaması için",
|
||||
"disableNativeTools": "Yerel araç çağrılarını devre dışı bırak",
|
||||
"disableNativeToolsTips": "Modeliniz fonksiyon çağrılarını (araç kullanımı) desteklemiyorsa bu seçeneği etkinleştirin. Devre dışı bırakıldığında, Roo XML tabanlı araç tanımları kullanacaktır. DeepSeek-R1 ve benzeri modeller için gereklidir.",
|
||||
"useAzure": "Azure kullan",
|
||||
"azureApiVersion": "Azure API sürümünü ayarla",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/vi/settings.json
generated
2
webview-ui/src/i18n/locales/vi/settings.json
generated
|
|
@ -861,6 +861,8 @@
|
|||
"enableStreaming": "Bật streaming",
|
||||
"enableR1Format": "Kích hoạt tham số mô hình R1",
|
||||
"enableR1FormatTips": "Cần kích hoạt khi sử dụng các mô hình R1 như QWQ, để tránh lỗi 400",
|
||||
"disableNativeTools": "Tắt gọi công cụ gốc",
|
||||
"disableNativeToolsTips": "Bật tùy chọn này nếu mô hình của bạn không hỗ trợ gọi hàm (sử dụng công cụ). Khi tắt, Roo sẽ sử dụng định nghĩa công cụ dựa trên XML. Cần thiết cho DeepSeek-R1 và các mô hình tương tự.",
|
||||
"useAzure": "Sử dụng Azure",
|
||||
"azureApiVersion": "Đặt phiên bản API Azure",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/zh-CN/settings.json
generated
2
webview-ui/src/i18n/locales/zh-CN/settings.json
generated
|
|
@ -861,6 +861,8 @@
|
|||
"enableStreaming": "启用流式传输",
|
||||
"enableR1Format": "启用 R1 模型参数",
|
||||
"enableR1FormatTips": "使用 QWQ 等 R1 系列模型时必须启用,避免出现 400 错误",
|
||||
"disableNativeTools": "禁用原生工具调用",
|
||||
"disableNativeToolsTips": "如果您的模型不支持函数调用(工具使用),请启用此选项。禁用后,Roo 将使用基于 XML 的工具定义。DeepSeek-R1 及类似模型需要启用此选项。",
|
||||
"useAzure": "使用 Azure 服务",
|
||||
"azureApiVersion": "设置 Azure API 版本",
|
||||
"gemini": {
|
||||
|
|
|
|||
2
webview-ui/src/i18n/locales/zh-TW/settings.json
generated
2
webview-ui/src/i18n/locales/zh-TW/settings.json
generated
|
|
@ -861,6 +861,8 @@
|
|||
"enableStreaming": "啟用串流輸出",
|
||||
"enableR1Format": "啟用 R1 模型參數",
|
||||
"enableR1FormatTips": "使用 QWQ 等 R1 模型時必須啟用,以避免發生 400 錯誤",
|
||||
"disableNativeTools": "停用原生工具呼叫",
|
||||
"disableNativeToolsTips": "如果您的模型不支援函數呼叫(工具使用),請啟用此選項。停用後,Roo 將使用基於 XML 的工具定義。DeepSeek-R1 及類似模型需要啟用此選項。",
|
||||
"useAzure": "使用 Azure",
|
||||
"azureApiVersion": "設定 Azure API 版本",
|
||||
"gemini": {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue