mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-05 08:10:14 +00:00
feat: add checkbox to control maximum context window for magistral-medium model
- Added useMaximumContextWindow field to provider settings schema - Implemented checkbox UI in Mistral provider settings with yellow warning - Updated context window logic to limit to 41k tokens when checkbox is unchecked - Added localization strings for the new feature This allows users to opt-in to using the full 128k context window for the magistral-medium-latest model, with a warning about potential performance degradation.
This commit is contained in:
parent
c479678d8e
commit
d9cac62f12
5 changed files with 49 additions and 4 deletions
|
|
@ -111,6 +111,9 @@ const baseProviderSettingsSchema = z.object({
|
|||
|
||||
// Model verbosity.
|
||||
verbosity: verbosityLevelsSchema.optional(),
|
||||
|
||||
// Context window settings.
|
||||
useMaximumContextWindow: z.boolean().optional(),
|
||||
})
|
||||
|
||||
// Several of the providers share common model config properties.
|
||||
|
|
|
|||
|
|
@ -7,10 +7,11 @@ export const mistralDefaultModelId: MistralModelId = "codestral-latest"
|
|||
|
||||
export const mistralModels = {
|
||||
"magistral-medium-latest": {
|
||||
maxTokens: 41_000,
|
||||
contextWindow: 41_000,
|
||||
maxTokens: 128_000,
|
||||
contextWindow: 128_000,
|
||||
supportsImages: false,
|
||||
supportsPromptCache: false,
|
||||
supportsReasoningBudget: true,
|
||||
inputPrice: 2.0,
|
||||
outputPrice: 5.0,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -95,7 +95,17 @@ export class MistralHandler extends BaseProvider implements SingleCompletionHand
|
|||
|
||||
override getModel() {
|
||||
const id = this.options.apiModelId ?? mistralDefaultModelId
|
||||
const info = mistralModels[id as MistralModelId] ?? mistralModels[mistralDefaultModelId]
|
||||
let info = mistralModels[id as MistralModelId] ?? mistralModels[mistralDefaultModelId]
|
||||
|
||||
// For magistral-medium-latest, optionally limit context window if useMaximumContextWindow is false
|
||||
if (id === "magistral-medium-latest" && !this.options.useMaximumContextWindow && info.contextWindow > 41000) {
|
||||
// Create a modified info object with reduced context window for better performance
|
||||
info = {
|
||||
...info,
|
||||
contextWindow: 41000,
|
||||
maxTokens: 41000,
|
||||
}
|
||||
}
|
||||
|
||||
// @TODO: Move this to the `getModelParams` function.
|
||||
const maxTokens = this.options.includeMaxTokens ? info.maxTokens : undefined
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import { useCallback } from "react"
|
||||
import { VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
|
||||
|
||||
import { type ProviderSettings, mistralDefaultModelId } from "@roo-code/types"
|
||||
import { type ProviderSettings, mistralDefaultModelId, mistralModels } from "@roo-code/types"
|
||||
|
||||
import type { RouterModels } from "@roo/api"
|
||||
|
||||
import { useAppTranslation } from "@src/i18n/TranslationContext"
|
||||
import { VSCodeButtonLink } from "@src/components/common/VSCodeButtonLink"
|
||||
import { Checkbox } from "@src/components/ui"
|
||||
|
||||
import { inputEventTransform } from "../transforms"
|
||||
|
||||
|
|
@ -30,6 +31,15 @@ export const Mistral = ({ apiConfiguration, setApiConfigurationField }: MistralP
|
|||
[setApiConfigurationField],
|
||||
)
|
||||
|
||||
// Check if the current model is magistral-medium-latest
|
||||
const isMagistralMedium =
|
||||
apiConfiguration?.apiModelId === "magistral-medium-latest" ||
|
||||
(!apiConfiguration?.apiModelId && mistralDefaultModelId === "magistral-medium-latest")
|
||||
|
||||
// Get the model info for magistral-medium-latest
|
||||
const magistralMediumModel = mistralModels["magistral-medium-latest"]
|
||||
const hasLargeContext = magistralMediumModel && magistralMediumModel.contextWindow >= 100000
|
||||
|
||||
return (
|
||||
<>
|
||||
<VSCodeTextField
|
||||
|
|
@ -48,6 +58,23 @@ export const Mistral = ({ apiConfiguration, setApiConfigurationField }: MistralP
|
|||
{t("settings:providers.getMistralApiKey")}
|
||||
</VSCodeButtonLink>
|
||||
)}
|
||||
{isMagistralMedium && hasLargeContext && (
|
||||
<div className="flex flex-col gap-2">
|
||||
<Checkbox
|
||||
checked={apiConfiguration?.useMaximumContextWindow || false}
|
||||
onChange={(checked: boolean) => setApiConfigurationField("useMaximumContextWindow", checked)}>
|
||||
{t("settings:providers.mistral.useMaximumContextWindow")}
|
||||
</Checkbox>
|
||||
{apiConfiguration?.useMaximumContextWindow && (
|
||||
<div className="flex items-start gap-2 p-2 rounded-md bg-[color-mix(in_srgb,var(--vscode-editorWarning-foreground)_20%,transparent)] border border-[var(--vscode-editorWarning-foreground)]">
|
||||
<span className="codicon codicon-warning text-[var(--vscode-editorWarning-foreground)] mt-0.5"></span>
|
||||
<div className="text-sm text-[var(--vscode-editorWarning-foreground)]">
|
||||
{t("settings:providers.mistral.contextWindowWarning")}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{(apiConfiguration?.apiModelId?.startsWith("codestral-") ||
|
||||
(!apiConfiguration?.apiModelId && mistralDefaultModelId.startsWith("codestral-"))) && (
|
||||
<>
|
||||
|
|
|
|||
|
|
@ -313,6 +313,10 @@
|
|||
"getMistralApiKey": "Get Mistral / Codestral API Key",
|
||||
"codestralBaseUrl": "Codestral Base URL (Optional)",
|
||||
"codestralBaseUrlDesc": "Set an alternative URL for the Codestral model.",
|
||||
"mistral": {
|
||||
"useMaximumContextWindow": "Use maximum context window (128k tokens)",
|
||||
"contextWindowWarning": "Using the full 128k context window may significantly degrade performance. Consider using a smaller context for better responsiveness unless you specifically need the extended context."
|
||||
},
|
||||
"xaiApiKey": "xAI API Key",
|
||||
"getXaiApiKey": "Get xAI API Key",
|
||||
"litellmApiKey": "LiteLLM API Key",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue