Deploy Inicial do SteelCheck com Docker Build Automatizado

This commit is contained in:
2026-06-22 23:16:32 +00:00
parent f10e6e473b
commit e7f50b61bc
+35 -6
View File
@@ -22,13 +22,28 @@ const fileToGenerativePart = async (file: File) => {
};
const cleanAndParseJson = (jsonString: string): any => {
const cleanedString = jsonString
.replace(/^```json\s*/, '')
.replace(/```$/, '')
.trim();
let cleanedString = jsonString.trim();
// Tenta encontrar um bloco markdown com json
const jsonMatch = cleanedString.match(/```(?:json)?\s*([\s\S]*?)\s*```/i);
if (jsonMatch) {
cleanedString = jsonMatch[1].trim();
} else {
// Se não tiver crases, tenta encontrar o primeiro { e o último }
const startIndex = cleanedString.indexOf('{');
const endIndex = cleanedString.lastIndexOf('}');
if (startIndex !== -1 && endIndex !== -1) {
cleanedString = cleanedString.substring(startIndex, endIndex + 1);
}
}
try {
return JSON.parse(cleanedString);
const parsed = JSON.parse(cleanedString);
// Se o modelo aninhou os dados dentro de uma chave "report"
if (parsed.report && !parsed.identification) {
return parsed.report;
}
return parsed;
} catch (error) {
console.error("Failed to parse cleaned JSON:", jsonString);
throw new Error("A resposta da IA não estava no formato JSON esperado.");
@@ -141,7 +156,21 @@ Execute:
5. **Análise de Equivalência:** Liste materiais equivalentes de outras normas (EN, DIN, JIS, NBR, etc.).
6. **Grau de Confiança:** Forneça um % de confiança baseado na qualidade do documento.
Retorne APENAS o objeto JSON, sem formatação adicional.`;
Retorne APENAS o objeto JSON, sem formatação adicional, seguindo EXATAMENTE esta estrutura de chaves (em inglês):
{
"confidence": 95,
"identification": {
"product": "", "standards": "", "manufacturer": "", "certificateNumber": "", "certificateDate": "", "batches": "", "heats": "", "quantity": ""
},
"compliance": {
"status": "CONFORME ou NÃO CONFORME",
"mechanical": [ { "property": "", "norm": "", "certificate": "", "status": "OK ou FALHA" } ],
"chemical": [ { "element": "", "norm": "", "certificate": "", "status": "OK ou FALHA" } ],
"otherTests": [ { "test": "", "norm": "", "certificate": "", "status": "OK ou FALHA" } ]
},
"overPerformance": [ { "property": "", "value": "" } ],
"equivalents": [ { "system": "", "norm": "" } ]
}`;
export const analyzeWithGemini = async (file: File, apiKey: string, model: string = 'gemini-2.5-flash'): Promise<ReportData> => {
if (!apiKey) {