mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: add NVIDIA API compatibility for minimax-M2 model
- Added _isNvidiaApi() method to detect NVIDIA API endpoints - Excluded stream_options parameter for NVIDIA endpoints (similar to Grok XAI) - Fixes issue #8998 where NVIDIA API returns body errors with stream_options
This commit is contained in:
parent
5c738de7ce
commit
0878604b4e
1 changed files with 11 additions and 2 deletions
|
|
@ -156,13 +156,14 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
|
|||
}
|
||||
|
||||
const isGrokXAI = this._isGrokXAI(this.options.openAiBaseUrl)
|
||||
const isNvidiaApi = this._isNvidiaApi(this.options.openAiBaseUrl)
|
||||
|
||||
const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming = {
|
||||
model: modelId,
|
||||
temperature: this.options.modelTemperature ?? (deepseekReasoner ? DEEP_SEEK_DEFAULT_TEMPERATURE : 0),
|
||||
messages: convertedMessages,
|
||||
stream: true as const,
|
||||
...(isGrokXAI ? {} : { stream_options: { include_usage: true } }),
|
||||
...(isGrokXAI || isNvidiaApi ? {} : { stream_options: { include_usage: true } }),
|
||||
...(reasoning && reasoning),
|
||||
}
|
||||
|
||||
|
|
@ -317,6 +318,8 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
|
|||
if (this.options.openAiStreamingEnabled ?? true) {
|
||||
const isGrokXAI = this._isGrokXAI(this.options.openAiBaseUrl)
|
||||
|
||||
const isNvidiaApi = this._isNvidiaApi(this.options.openAiBaseUrl)
|
||||
|
||||
const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming = {
|
||||
model: modelId,
|
||||
messages: [
|
||||
|
|
@ -327,7 +330,7 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
|
|||
...convertToOpenAiMessages(messages),
|
||||
],
|
||||
stream: true,
|
||||
...(isGrokXAI ? {} : { stream_options: { include_usage: true } }),
|
||||
...(isGrokXAI || isNvidiaApi ? {} : { stream_options: { include_usage: true } }),
|
||||
reasoning_effort: modelInfo.reasoningEffort as "low" | "medium" | "high" | undefined,
|
||||
temperature: undefined,
|
||||
}
|
||||
|
|
@ -423,6 +426,12 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
|
|||
return urlHost.endsWith(".services.ai.azure.com")
|
||||
}
|
||||
|
||||
private _isNvidiaApi(baseUrl?: string): boolean {
|
||||
const urlHost = this._getUrlHost(baseUrl)
|
||||
// NVIDIA API endpoints typically use integrate.api.nvidia.com or build.nvidia.com
|
||||
return urlHost.includes("nvidia.com")
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds max_completion_tokens to the request body if needed based on provider configuration
|
||||
* Note: max_tokens is deprecated in favor of max_completion_tokens as per OpenAI documentation
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue