fix(audit): remover response_format para openrouter e melhorar placeholder
This commit is contained in:
@@ -147,23 +147,28 @@ async function callOpenRouter(
|
||||
): Promise<string> {
|
||||
onProgress?.('Enviando para OpenRouter...');
|
||||
const url = config.baseUrl ?? 'https://openrouter.ai/api/v1/chat/completions';
|
||||
const body: OpenAIRequest = {
|
||||
const body = {
|
||||
model: config.model,
|
||||
messages: [
|
||||
{ role: 'system', content: systemPrompt },
|
||||
{ role: 'user', content: userPrompt },
|
||||
{ role: 'system' as const, content: systemPrompt },
|
||||
{ role: 'user' as const, content: userPrompt },
|
||||
],
|
||||
temperature: 0,
|
||||
response_format: { type: 'json_object' },
|
||||
};
|
||||
const response = await fetchWithTimeout(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${config.apiKey}`,
|
||||
'HTTP-Referer': 'https://brainwind.app',
|
||||
'X-Title': 'BrainWind NBR 6123',
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
}, 180000);
|
||||
if (!response.ok) {
|
||||
const errText = await response.text();
|
||||
throw new Error(`OpenRouter HTTP ${response.status}: ${errText}`);
|
||||
}
|
||||
const data = await response.json() as { choices?: { message?: { content?: string } }[]; error?: { message?: string } };
|
||||
if (data.error) throw new Error(`OpenRouter error: ${data.error.message}`);
|
||||
const content = data.choices?.[0]?.message?.content;
|
||||
|
||||
Reference in New Issue
Block a user