This commit is contained in:
Hamza-Ayed
2024-11-10 18:38:07 +02:00
parent c9ac8da2ec
commit e8c72d79a9
25 changed files with 1211 additions and 329 deletions

View File

@@ -626,6 +626,51 @@ class AI extends GetxController {
}
}
Future<void> allMethodForAINewCar(
String prompt, String linkPHP, String imagePath, String carID) async {
isLoading = true;
update();
try {
await ImageController().choosImageNewCAr(linkPHP, imagePath);
// if (imagePath == 'driver_license') {
// await ImageController().choosFaceFromDriverLicense(linkPHP, 'face');
// }
await Future.delayed(const Duration(seconds: 2));
var extractedString =
await CRUD().arabicTextExtractByVisionAndAI(imagePath: imagePath);
var json = jsonDecode(extractedString);
var textValues = CRUD().extractTextFromLines(json);
DocumentType detectedType = checkDocumentType(textValues);
String expectedDocument = getExpectedDocument(imagePath);
String detectedDocument = getDetectedDocument(detectedType);
bool isCorrectDocument = (detectedType == getExpectedType(imagePath));
if (!isCorrectDocument) {
MyDialog().getDialog('incorrect_document_title'.tr,
'${'expected'.tr}: $expectedDocument\n${'detected'.tr}: $detectedDocument',
() {
Get.back();
});
} else {
// Process the correct document
await Get.put(AI()).anthropicAI(textValues, prompt, imagePath);
}
} catch (e) {
MyDialog().getDialog('error'.tr, 'error_processing_document'.tr, () {
Get.back();
});
} finally {
isLoading = false;
update();
}
}
String getExpectedDocument(String imagePath) {
switch (imagePath) {
case 'car_front':