Fix Mistral API parameter naming issue

- Change maxTokens to max_tokens for Mistral API compatibility
- Extract maxTokens from options before spreading to avoid parameter conflicts
- Tested successfully with live API calls
This commit is contained in:
Augustin ROUX 2025-10-17 12:02:59 +02:00
parent d2894af925
commit 5b67cca5cb

View File

@ -50,6 +50,8 @@ Output format: JSON with fields {proposal, justification, confidence (0-1), depe
* Call Mistral AI API
*/
async function callMistralAPI(messages, options = {}) {
const { maxTokens, ...otherOptions } = options;
const response = await fetch(MISTRAL_API_URL, {
method: 'POST',
headers: {
@ -60,8 +62,8 @@ async function callMistralAPI(messages, options = {}) {
model: options.model || 'mistral-small-latest',
messages,
temperature: options.temperature || 0.7,
max_tokens: options.maxTokens || 2048,
...options
max_tokens: maxTokens || 2048,
...otherOptions
})
});