fix(audit): remover response_format para openrouter e melhorar placeholder

This commit is contained in:
2026-07-11 20:40:55 +00:00
parent 67d55b8142
commit 21c18afd02
2 changed files with 10 additions and 5 deletions
+1 -1
View File
@@ -161,7 +161,7 @@ export default function AuditPanel() {
<Input
value={config.baseUrl ?? ''}
onChange={(e) => setConfig((c) => ({ ...c, baseUrl: e.target.value || undefined }))}
placeholder="https://api.openai.com/v1"
placeholder={config.provider === 'openrouter' ? 'https://openrouter.ai/api/v1 (padrão)' : config.provider === 'ollama' ? 'http://localhost:11434 (padrão)' : 'https://api.openai.com/v1'}
/>
</div>
</div>
+9 -4
View File
@@ -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;