fix: désactiver thinking mode DeepSeek pour fiabiliser le tool calling
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 23s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Antigravity
2026-05-05 21:37:55 +00:00
parent ab914f0587
commit 08a49a04ce
2 changed files with 25 additions and 0 deletions

View File

@@ -26,6 +26,19 @@ export class CustomOpenAIProvider implements AIProvider {
const headers = new Headers(options?.headers);
headers.set('HTTP-Referer', 'https://localhost:3000');
headers.set('X-Title', 'Memento AI');
// Disable DeepSeek extended thinking for reliable tool/function calling
if (options?.body) {
try {
const body = JSON.parse(options.body as string)
if (
typeof body.model === 'string' &&
(body.model.includes('deepseek') || body.model.includes('thinking') || body.model.includes('reasoner'))
) {
body.thinking = { type: 'disabled' }
}
return fetch(url, { ...options, headers, body: JSON.stringify(body) })
} catch { /* ignore parse errors */ }
}
return fetch(url, { ...options, headers });
}
});

View File

@@ -9,9 +9,21 @@ export class DeepSeekProvider implements AIProvider {
constructor(apiKey: string, modelName: string = 'deepseek-chat', embeddingModelName: string = 'deepseek-embedding') {
// Create OpenAI-compatible client for DeepSeek
// Disable extended thinking to ensure reliable tool/function calling
const deepseek = createOpenAI({
baseURL: 'https://api.deepseek.com/v1',
apiKey: apiKey,
fetch: async (url, options) => {
if (options?.body) {
try {
const body = JSON.parse(options.body as string)
// Disable thinking mode — tool calling is unreliable with it enabled
body.thinking = { type: 'disabled' }
return fetch(url, { ...options, body: JSON.stringify(body) })
} catch { /* ignore parse errors */ }
}
return fetch(url, options)
},
});
this.model = deepseek.chat(modelName);