Carry OCR and missing-source warnings into analysis readiness
This commit is contained in:
+2
-2
@@ -13,11 +13,11 @@ export async function getAiConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function analyzeSpecText({ text, fileName, tender, chain, mode }) {
|
||||
export async function analyzeSpecText({ text, fileName, tender, chain, mode, extraction }) {
|
||||
const res = await fetch('/api/ai/analyze', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${getToken()}` },
|
||||
body: JSON.stringify({ text, fileName, tender, chain, mode }),
|
||||
body: JSON.stringify({ text, fileName, tender, chain, mode, extraction }),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!data.success) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/** Only extraction provenance crosses the AI boundary, never a client approval flag. */
|
||||
export function extractionReview(input) {
|
||||
const sources=(Array.isArray(input) ? input : input ? [input] : []).map(source=>({
|
||||
fileName:typeof source.fileName === 'string' ? source.fileName.slice(0,200) : '',
|
||||
ocr:source.ocr === true,
|
||||
pageCount:Number.isInteger(source.pageCount) && source.pageCount>0 ? source.pageCount : null,
|
||||
usedPages:Number.isInteger(source.usedPages) && source.usedPages>=0 ? source.usedPages : null,
|
||||
complete:source.complete !== false,
|
||||
}));
|
||||
const issues=[];
|
||||
for(const source of sources) {
|
||||
const name=source.fileName || 'Belge';
|
||||
if(source.ocr) issues.push(`${name}: OCR metni resmi belgeyle karşılaştırılmalı; karakter ve miktar hataları olabilir.`);
|
||||
if(!source.complete || (source.pageCount != null && source.usedPages != null && source.usedPages<source.pageCount))
|
||||
issues.push(`${name}: belgenin bütün sayfaları okunmadı.`);
|
||||
}
|
||||
return {sources,issues};
|
||||
}
|
||||
Reference in New Issue
Block a user