mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
commit
7eada8bb6d
2 changed files with 24 additions and 3 deletions
|
|
@ -35,7 +35,7 @@ export class MistralHandler implements ApiHandler {
|
|||
}
|
||||
|
||||
private getBaseUrl(): string {
|
||||
const modelId = this.options.apiModelId
|
||||
const modelId = this.options.apiModelId ?? mistralDefaultModelId
|
||||
if (modelId?.startsWith("codestral-")) {
|
||||
return this.options.mistralCodestralUrl || "https://codestral.mistral.ai"
|
||||
}
|
||||
|
|
@ -86,4 +86,25 @@ export class MistralHandler implements ApiHandler {
|
|||
info: mistralModels[mistralDefaultModelId],
|
||||
}
|
||||
}
|
||||
|
||||
async completePrompt(prompt: string): Promise<string> {
|
||||
try {
|
||||
const response = await this.client.chat.complete({
|
||||
model: this.options.apiModelId || mistralDefaultModelId,
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
temperature: this.options.modelTemperature ?? MISTRAL_DEFAULT_TEMPERATURE,
|
||||
})
|
||||
|
||||
const content = response.choices?.[0]?.message.content
|
||||
if (Array.isArray(content)) {
|
||||
return content.map((c) => (c.type === "text" ? c.text : "")).join("")
|
||||
}
|
||||
return content || ""
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(`Mistral completion error: ${error.message}`)
|
||||
}
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -314,7 +314,6 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage, fromWelcomeView }: A
|
|||
placeholder="Enter API Key...">
|
||||
<span style={{ fontWeight: 500 }}>Mistral API Key</span>
|
||||
</VSCodeTextField>
|
||||
|
||||
<p
|
||||
style={{
|
||||
fontSize: "12px",
|
||||
|
|
@ -335,7 +334,8 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage, fromWelcomeView }: A
|
|||
)}
|
||||
</p>
|
||||
|
||||
{apiConfiguration?.apiModelId?.startsWith("codestral-") && (
|
||||
{(apiConfiguration?.apiModelId?.startsWith("codestral-") ||
|
||||
(!apiConfiguration?.apiModelId && mistralDefaultModelId.startsWith("codestral-"))) && (
|
||||
<div>
|
||||
<VSCodeTextField
|
||||
value={apiConfiguration?.mistralCodestralUrl || ""}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue