fix: remove unused minimax logic to resolve PROMPT_BASE typescript error
This commit is contained in:
@@ -449,56 +449,6 @@ export const analyzeWithOpenRouter = async (file: File, apiKey: string, model: s
|
|||||||
return cleanAndParseJson(content) as ReportData[];
|
return cleanAndParseJson(content) as ReportData[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const analyzeWithMinimax = async (file: File, apiKey: string, model: string = 'minimax-2.7'): Promise<ReportData[]> => {
|
|
||||||
if (!apiKey) {
|
|
||||||
throw new Error("A chave de API do MiniMax não foi fornecida.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const base64Data = await new Promise<string>((resolve) => {
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onloadend = () => resolve((reader.result as string).split(',')[1]);
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await fetch('https://api.minimaxi.com/v1/chat/completions', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Authorization': `Bearer ${apiKey}`,
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
model,
|
|
||||||
messages: [
|
|
||||||
{
|
|
||||||
role: 'user',
|
|
||||||
content: [
|
|
||||||
{ type: 'text', text: PROMPT_BASE + "\n\nRetorne apenas JSON válido sem formatação markdown." },
|
|
||||||
{
|
|
||||||
type: 'image_url',
|
|
||||||
image_url: { url: `data:${file.type};base64,${base64Data}` }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
temperature: 0.1
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
const error = await response.json().catch(() => ({}));
|
|
||||||
throw new Error(`Erro do MiniMax: ${error.error?.message || 'Erro desconhecido'}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
const content = data.choices[0]?.message?.content;
|
|
||||||
|
|
||||||
if (!content) {
|
|
||||||
throw new Error("Resposta vazia do MiniMax");
|
|
||||||
}
|
|
||||||
|
|
||||||
return cleanAndParseJson(content) as ReportData[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export const buildStandardWithAI = async (
|
export const buildStandardWithAI = async (
|
||||||
options: { provider: AIProvider; apiKey: string; model: string; endpoint?: string },
|
options: { provider: AIProvider; apiKey: string; model: string; endpoint?: string },
|
||||||
standardName: string,
|
standardName: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user