11/10/1
This commit is contained in:
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user