Update: 2026-05-07 02:01:59

This commit is contained in:
Hamza-Ayed
2026-05-07 02:01:59 +03:00
parent e5b70a01ef
commit 57ac6047b8
4 changed files with 143 additions and 37 deletions

View File

@@ -30,7 +30,7 @@ class AI
"contents" => [
[
"parts" => [
["text" => $prompt],
["text" => $prompt . " If the image is not an invoice, is blank, or is completely unreadable, return ONLY: {\"error\": \"invalid_invoice\"}. DO NOT guess or invent data."],
[
"inline_data" => [
"mime_type" => $mimeType,
@@ -65,6 +65,11 @@ class AI
if (!$textResponse) return null;
return json_decode($textResponse, true);
$data = json_decode($textResponse, true);
if (isset($data['error']) && $data['error'] === 'invalid_invoice') {
return null;
}
return $data;
}
}