From 607346905c269e4aa6629c20d470a5820802200e Mon Sep 17 00:00:00 2001 From: androidlover5842 Date: Sat, 31 Jan 2026 02:19:23 +0530 Subject: [PATCH] no idea 0_0 --- .../controller/GuestDocuments.kt | 128 ++++++++---------- 1 file changed, 60 insertions(+), 68 deletions(-) diff --git a/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt b/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt index c712757..05c99b5 100644 --- a/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt +++ b/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt @@ -218,16 +218,16 @@ class GuestDocuments( ) - results["hasAadhar"] = llamaClient.ask(imageUrl, "CONTAINS AADHAAR? Answer YES or NO only.") - results["hasUidai"] = llamaClient.ask(imageUrl, "CONTAINS UIDAI? Answer YES or NO only.") - val hasAadhar = isYes(results["hasAadhar"]) || isYes(results["hasUidai"]) if (isYes(results["isVehiclePhoto"])) { results["vehicleNumber"] = llamaClient.ask( imageUrl, "VEHICLE NUMBER PLATE? Reply only number or NONE." ) } - else if (hasAadhar) { + results["hasAadhar"] = llamaClient.ask(imageUrl, "CONTAINS AADHAAR? Answer YES or NO only.") + results["hasUidai"] = llamaClient.ask(imageUrl, "CONTAINS UIDAI? Answer YES or NO only.") + val hasAadhar = isYes(results["hasAadhar"]) || isYes(results["hasUidai"]) + if (hasAadhar) { val aadharQuestions = linkedMapOf( "hasAddress" to "POSTAL ADDRESS PRESENT? Answer YES or NO only.", "hasDob" to "DOB? Reply YES or NO.", @@ -261,24 +261,16 @@ class GuestDocuments( } } else { - if (isYes(results["isVehiclePhoto"])) { - val vehicleQuestions = linkedMapOf( - "vehicleNumber" to "VEHICLE NUMBER PLATE? Reply only number or NONE." - ) - for ((key, question) in vehicleQuestions) { - results[key] = llamaClient.ask(imageUrl, question) - } - } else { - results["hasDrivingLicence"] = llamaClient.ask( - imageUrl, - "CONTAINS DRIVING LICENCE? Answer YES or NO only." - ) - results["hasTransportDept"] = llamaClient.ask( - imageUrl, - "CONTAINS TRANSPORT DEPARTMENT? Answer YES or NO only." - ) - val isDriving = isYes(results["hasDrivingLicence"]) || isYes(results["hasTransportDept"]) - if (isDriving) { + results["hasDrivingLicence"] = llamaClient.ask( + imageUrl, + "CONTAINS DRIVING LICENCE? Answer YES or NO only." + ) + results["hasTransportDept"] = llamaClient.ask( + imageUrl, + "CONTAINS TRANSPORT DEPARTMENT? Answer YES or NO only." + ) + val isDriving = isYes(results["hasDrivingLicence"]) || isYes(results["hasTransportDept"]) + if (isDriving) { val drivingQuestions = linkedMapOf( DocumentPrompts.NAME, DocumentPrompts.DOB, @@ -289,86 +281,86 @@ class GuestDocuments( DocumentPrompts.GENDER, DocumentPrompts.NATIONALITY ) - for ((key, question) in drivingQuestions) { + for ((key, question) in drivingQuestions) { + results[key] = llamaClient.ask(imageUrl, question) + } + } else { + results["hasElectionCommission"] = llamaClient.ask( + imageUrl, + "CONTAINS ELECTION COMMISSION OF INDIA? Answer YES or NO only." + ) + if (isYes(results["hasElectionCommission"])) { + val voterQuestions = linkedMapOf( + DocumentPrompts.NAME, + DocumentPrompts.DOB, + "idNumber" to "VOTER ID NUMBER? Reply only number or NONE.", + DocumentPrompts.ADDRESS, + DocumentPrompts.PIN_CODE, + DocumentPrompts.CITY, + DocumentPrompts.GENDER, + DocumentPrompts.NATIONALITY + ) + for ((key, question) in voterQuestions) { results[key] = llamaClient.ask(imageUrl, question) } } else { - results["hasElectionCommission"] = llamaClient.ask( + results["hasIncomeTaxDept"] = llamaClient.ask( imageUrl, - "CONTAINS ELECTION COMMISSION OF INDIA? Answer YES or NO only." + "CONTAINS INCOME TAX DEPARTMENT? Answer YES or NO only." ) - if (isYes(results["hasElectionCommission"])) { - val voterQuestions = linkedMapOf( + if (isYes(results["hasIncomeTaxDept"])) { + val panQuestions = linkedMapOf( DocumentPrompts.NAME, DocumentPrompts.DOB, - "idNumber" to "VOTER ID NUMBER? Reply only number or NONE.", + "idNumber" to "PAN NUMBER? Reply only number or NONE.", DocumentPrompts.ADDRESS, DocumentPrompts.PIN_CODE, DocumentPrompts.CITY, DocumentPrompts.GENDER, DocumentPrompts.NATIONALITY ) - for ((key, question) in voterQuestions) { + for ((key, question) in panQuestions) { results[key] = llamaClient.ask(imageUrl, question) } } else { - results["hasIncomeTaxDept"] = llamaClient.ask( + results["hasPassport"] = llamaClient.ask( imageUrl, - "CONTAINS INCOME TAX DEPARTMENT? Answer YES or NO only." + "CONTAINS PASSPORT? Answer YES or NO only." ) - if (isYes(results["hasIncomeTaxDept"])) { - val panQuestions = linkedMapOf( + if (isYes(results["hasPassport"])) { + val passportQuestions = linkedMapOf( DocumentPrompts.NAME, DocumentPrompts.DOB, - "idNumber" to "PAN NUMBER? Reply only number or NONE.", + "idNumber" to "PASSPORT NUMBER? Reply only number or NONE.", DocumentPrompts.ADDRESS, DocumentPrompts.PIN_CODE, DocumentPrompts.CITY, DocumentPrompts.GENDER, DocumentPrompts.NATIONALITY ) - for ((key, question) in panQuestions) { + for ((key, question) in passportQuestions) { results[key] = llamaClient.ask(imageUrl, question) } } else { - results["hasPassport"] = llamaClient.ask( - imageUrl, - "CONTAINS PASSPORT? Answer YES or NO only." + val generalQuestions = linkedMapOf( + DocumentPrompts.NAME, + DocumentPrompts.DOB, + DocumentPrompts.ID_NUMBER, + DocumentPrompts.ADDRESS, + DocumentPrompts.VEHICLE_NUMBER, + DocumentPrompts.PIN_CODE, + DocumentPrompts.CITY, + DocumentPrompts.GENDER, + DocumentPrompts.NATIONALITY ) - if (isYes(results["hasPassport"])) { - val passportQuestions = linkedMapOf( - DocumentPrompts.NAME, - DocumentPrompts.DOB, - "idNumber" to "PASSPORT NUMBER? Reply only number or NONE.", - DocumentPrompts.ADDRESS, - DocumentPrompts.PIN_CODE, - DocumentPrompts.CITY, - DocumentPrompts.GENDER, - DocumentPrompts.NATIONALITY - ) - for ((key, question) in passportQuestions) { - results[key] = llamaClient.ask(imageUrl, question) - } - } else { - val generalQuestions = linkedMapOf( - DocumentPrompts.NAME, - DocumentPrompts.DOB, - DocumentPrompts.ID_NUMBER, - DocumentPrompts.ADDRESS, - DocumentPrompts.VEHICLE_NUMBER, - DocumentPrompts.PIN_CODE, - DocumentPrompts.CITY, - DocumentPrompts.GENDER, - DocumentPrompts.NATIONALITY - ) - for ((key, question) in generalQuestions) { - results[key] = llamaClient.ask(imageUrl, question) - } + for ((key, question) in generalQuestions) { + results[key] = llamaClient.ask(imageUrl, question) } } } } } + } results["docType"] = when { isYes(results["hasCourt"]) || @@ -394,7 +386,7 @@ class GuestDocuments( document.extractedAt = OffsetDateTime.now() guestDocumentRepo.save(document) guestDocumentEvents.emit(propertyId, guestId) - } }catch (_: Exception) { + } catch (_: Exception) { // Keep upload successful even if AI extraction fails. } }