Просмотр исходного кода

Merge pull request #1022 from d-oit/mistral

API Provider: Mistral
Matt Rubens 10 месяцев назад
Родитель
Сommit
bc3af52e25
2 измененных файлов с 17 добавлено и 13 удалено
  1. 8 2
      src/api/providers/mistral.ts
  2. 9 11
      webview-ui/src/components/settings/ApiOptions.tsx

+ 8 - 2
src/api/providers/mistral.ts

@@ -25,7 +25,12 @@ export class MistralHandler implements ApiHandler {
 			throw new Error("Mistral API key is required")
 		}
 
-		this.options = options
+		// Set default model ID if not provided
+		this.options = {
+			...options,
+			apiModelId: options.apiModelId || mistralDefaultModelId,
+		}
+
 		const baseUrl = this.getBaseUrl()
 		console.debug(`[Roo Code] MistralHandler using baseUrl: ${baseUrl}`)
 		this.client = new Mistral({
@@ -36,6 +41,7 @@ export class MistralHandler implements ApiHandler {
 
 	private getBaseUrl(): string {
 		const modelId = this.options.apiModelId ?? mistralDefaultModelId
+		console.debug(`[Roo Code] MistralHandler using modelId: ${modelId}`)
 		if (modelId?.startsWith("codestral-")) {
 			return this.options.mistralCodestralUrl || "https://codestral.mistral.ai"
 		}
@@ -45,7 +51,7 @@ export class MistralHandler implements ApiHandler {
 	async *createMessage(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): ApiStream {
 		const response = await this.client.chat.stream({
 			model: this.options.apiModelId || mistralDefaultModelId,
-			messages: convertToMistralMessages(messages),
+			messages: [{ role: "system", content: systemPrompt }, ...convertToMistralMessages(messages)],
 			maxTokens: this.options.includeMaxTokens ? this.getModel().info.maxTokens : undefined,
 			temperature: this.options.modelTemperature ?? MISTRAL_DEFAULT_TEMPERATURE,
 		})

+ 9 - 11
webview-ui/src/components/settings/ApiOptions.tsx

@@ -321,17 +321,15 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage, fromWelcomeView }: A
 							color: "var(--vscode-descriptionForeground)",
 						}}>
 						This key is stored locally and only used to make API requests from this extension.
-						{!apiConfiguration?.mistralApiKey && (
-							<VSCodeLink
-								href="https://console.mistral.ai/"
-								style={{
-									display: "inline",
-									fontSize: "inherit",
-								}}>
-								You can get a La Plateforme (api.mistral.ai) / Codestral (codestral.mistral.ai) API key
-								by signing up here.
-							</VSCodeLink>
-						)}
+						<VSCodeLink
+							href="https://console.mistral.ai/"
+							style={{
+								display: "inline",
+								fontSize: "inherit",
+							}}>
+							You can get a La Plateforme (api.mistral.ai) or Codestral (codestral.mistral.ai) API key by
+							signing up here.
+						</VSCodeLink>
 					</p>
 
 					{(apiConfiguration?.apiModelId?.startsWith("codestral-") ||