From 51c5b2cfdb157c93d3e7e0e0693288eec4ac110c Mon Sep 17 00:00:00 2001 From: androidlover5842 Date: Sat, 31 Jan 2026 01:10:14 +0530 Subject: [PATCH] Branch AI questions based on Aadhaar detection --- .../controller/GuestDocuments.kt | 76 ++++++++++++------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt b/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt index cce17ce..6729452 100644 --- a/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt +++ b/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt @@ -211,36 +211,54 @@ class GuestDocuments( val imageUrl = "${aiBaseUrl}/properties/$propertyId/guests/$guestId/documents/${document.id}/file?token=$token" - val questions = linkedMapOf( - "hasAadhar" to "CONTAINS AADHAAR? Answer YES or NO only.", - "hasUidai" to "CONTAINS UIDAI? Answer YES or NO only.", - "hasTransportDept" to "CONTAINS TRANSPORT DEPARTMENT? Answer YES or NO only.", - "hasIncomeTaxDept" to "CONTAINS INCOME TAX DEPARTMENT? Answer YES or NO only.", - "hasElectionCommission" to "CONTAINS ELECTION COMMISSION OF INDIA? Answer YES or NO only.", - "hasDrivingLicence" to "CONTAINS DRIVING LICENCE? Answer YES or NO only.", - "hasPassport" to "CONTAINS PASSPORT? Answer YES or NO only.", - "hasPolice" to "CONTAINS POLICE? Answer YES or NO only.", - "hasCourt" to "CONTAINS COURT? Answer YES or NO only.", - "hasHighCourt" to "CONTAINS HIGH COURT? Answer YES or NO only.", - "hasSupremeCourt" to "CONTAINS SUPREME COURT? Answer YES or NO only.", - "hasJudiciary" to "CONTAINS JUDICIARY? Answer YES or NO only.", - "hasAddress" to "ADDRESS PRESENT? Answer YES or NO only.", - "hasGender" to "GENDER PRESENT? Answer YES or NO only.", - "hasNationality" to "NATIONALITY PRESENT? Answer YES or NO only.", - "name" to "NAME? Reply only the name or NONE.", - "dob" to "DOB? Reply only date or NONE.", - "idNumber" to "ID NUMBER? Reply only number or NONE.", - "address" to "ADDRESS? Reply only address or NONE.", - "vehicleNumber" to "VEHICLE NUMBER? Reply only number or NONE.", - "isVehiclePhoto" to "IS THIS A VEHICLE PHOTO? Answer YES or NO only.", - "pinCode" to "PIN CODE? Reply only pin or NONE.", - "city" to "CITY? Reply only city or NONE.", - "gender" to "GENDER? Reply only MALE/FEMALE/OTHER or NONE.", - "nationality" to "NATIONALITY? Reply only nationality or NONE." - ) val results = linkedMapOf() - for ((key, question) in questions) { - results[key] = llamaClient.ask(imageUrl, question) + 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 = results["hasAadhar"].orEmpty().contains("YES", true) || + results["hasUidai"].orEmpty().contains("YES", true) + if (hasAadhar) { + val aadharQuestions = linkedMapOf( + "hasAddress" to "ADDRESS PRESENT? Answer YES or NO only.", + "hasGender" to "GENDER PRESENT? Answer YES or NO only.", + "name" to "NAME? Reply only the name or NONE.", + "dob" to "DOB? Reply only date or NONE.", + "idNumber" to "ID NUMBER? Reply only number or NONE.", + "address" to "ADDRESS? Reply only address or NONE.", + "pinCode" to "PIN CODE? Reply only pin or NONE.", + "city" to "CITY? Reply only city or NONE.", + "gender" to "GENDER? Reply only MALE/FEMALE/OTHER or NONE.", + "nationality" to "NATIONALITY? Reply only nationality or NONE." + ) + for ((key, question) in aadharQuestions) { + results[key] = llamaClient.ask(imageUrl, question) + } + } else { + val generalQuestions = linkedMapOf( + "hasTransportDept" to "CONTAINS TRANSPORT DEPARTMENT? Answer YES or NO only.", + "hasIncomeTaxDept" to "CONTAINS INCOME TAX DEPARTMENT? Answer YES or NO only.", + "hasElectionCommission" to "CONTAINS ELECTION COMMISSION OF INDIA? Answer YES or NO only.", + "hasDrivingLicence" to "CONTAINS DRIVING LICENCE? Answer YES or NO only.", + "hasPassport" to "CONTAINS PASSPORT? Answer YES or NO only.", + "hasPolice" to "CONTAINS POLICE? Answer YES or NO only.", + "hasCourt" to "CONTAINS COURT? Answer YES or NO only.", + "hasHighCourt" to "CONTAINS HIGH COURT? Answer YES or NO only.", + "hasSupremeCourt" to "CONTAINS SUPREME COURT? Answer YES or NO only.", + "hasJudiciary" to "CONTAINS JUDICIARY? Answer YES or NO only.", + "hasNationality" to "NATIONALITY PRESENT? Answer YES or NO only.", + "name" to "NAME? Reply only the name or NONE.", + "dob" to "DOB? Reply only date or NONE.", + "idNumber" to "ID NUMBER? Reply only number or NONE.", + "address" to "ADDRESS? Reply only address or NONE.", + "vehicleNumber" to "VEHICLE NUMBER? Reply only number or NONE.", + "isVehiclePhoto" to "IS THIS A VEHICLE PHOTO? Answer YES or NO only.", + "pinCode" to "PIN CODE? Reply only pin or NONE.", + "city" to "CITY? Reply only city or NONE.", + "gender" to "GENDER? Reply only MALE/FEMALE/OTHER or NONE.", + "nationality" to "NATIONALITY? Reply only nationality or NONE." + ) + for ((key, question) in generalQuestions) { + results[key] = llamaClient.ask(imageUrl, question) + } } results["docType"] = when {