|
1 | 1 | import axios from 'axios'; |
2 | | -import { Mistral } from '@mistralai/mistralai'; |
3 | 2 | import { OpenAI } from 'openai'; |
4 | 3 | import { GenerateCommitMessageErrorEnum } from '../generateCommitMessageFromGitDiff'; |
| 4 | +import { removeContentTags } from '../utils/removeContentTags'; |
5 | 5 | import { tokenCount } from '../utils/tokenCount'; |
6 | 6 | import { AiEngine, AiEngineConfig } from './Engine'; |
7 | | -import { |
8 | | - AssistantMessage as MistralAssistantMessage, |
9 | | - SystemMessage as MistralSystemMessage, |
10 | | - ToolMessage as MistralToolMessage, |
11 | | - UserMessage as MistralUserMessage |
12 | | -} from '@mistralai/mistralai/models/components'; |
13 | 7 |
|
| 8 | +// Using any for Mistral types to avoid type declaration issues |
14 | 9 | export interface MistralAiConfig extends AiEngineConfig {} |
15 | | -export type MistralCompletionMessageParam = Array< |
16 | | -| (MistralSystemMessage & { role: "system" }) |
17 | | -| (MistralUserMessage & { role: "user" }) |
18 | | -| (MistralAssistantMessage & { role: "assistant" }) |
19 | | -| (MistralToolMessage & { role: "tool" }) |
20 | | -> |
| 10 | +export type MistralCompletionMessageParam = Array<any>; |
| 11 | + |
| 12 | +// Import Mistral dynamically to avoid TS errors |
| 13 | +// eslint-disable-next-line @typescript-eslint/no-var-requires |
| 14 | +const Mistral = require('@mistralai/mistralai').Mistral; |
21 | 15 |
|
22 | 16 | export class MistralAiEngine implements AiEngine { |
23 | 17 | config: MistralAiConfig; |
24 | | - client: Mistral; |
| 18 | + client: any; // Using any type for Mistral client to avoid TS errors |
25 | 19 |
|
26 | 20 | constructor(config: MistralAiConfig) { |
27 | 21 | this.config = config; |
@@ -64,7 +58,8 @@ export class MistralAiEngine implements AiEngine { |
64 | 58 | if (!message || !message.content) |
65 | 59 | throw Error('No completion choice available.') |
66 | 60 |
|
67 | | - return message.content as string; |
| 61 | + let content = message.content as string; |
| 62 | + return removeContentTags(content, 'think'); |
68 | 63 | } catch (error) { |
69 | 64 | const err = error as Error; |
70 | 65 | if ( |
|
0 commit comments