(prompt: string)
| 194 | } |
| 195 | |
| 196 | async completePrompt(prompt: string): Promise<string> { |
| 197 | const { id: model, temperature } = this.getModel() |
| 198 | |
| 199 | try { |
| 200 | const response = await this.client.chat.complete({ |
| 201 | model, |
| 202 | messages: [{ role: "user", content: prompt }], |
| 203 | temperature, |
| 204 | }) |
| 205 | |
| 206 | const content = response.choices?.[0]?.message.content |
| 207 | |
| 208 | if (Array.isArray(content)) { |
| 209 | // Only return text content, filter out thinking content for non-streaming |
| 210 | return (content as ContentChunkWithThinking[]) |
| 211 | .filter((c) => c.type === "text" && c.text) |
| 212 | .map((c) => c.text || "") |
| 213 | .join("") |
| 214 | } |
| 215 | |
| 216 | return content || "" |
| 217 | } catch (error) { |
| 218 | const errorMessage = error instanceof Error ? error.message : String(error) |
| 219 | const apiError = new ApiProviderError(errorMessage, this.providerName, model, "completePrompt") |
| 220 | TelemetryService.instance.captureException(apiError) |
| 221 | throw new Error(`Mistral completion error: ${errorMessage}`) |
| 222 | } |
| 223 | } |
| 224 | } |
nothing calls this directly
no test coverage detected