From e0643ce695166b7709d71c09fd610d895da60917 Mon Sep 17 00:00:00 2001 From: androidlover5842 Date: Sat, 31 Jan 2026 02:05:11 +0530 Subject: [PATCH] Centralize document prompts --- .../controller/DocumentPrompts.kt | 13 ++ .../controller/GuestDocuments.kt | 177 ++++++++++-------- 2 files changed, 109 insertions(+), 81 deletions(-) create mode 100644 src/main/kotlin/com/android/trisolarisserver/controller/DocumentPrompts.kt diff --git a/src/main/kotlin/com/android/trisolarisserver/controller/DocumentPrompts.kt b/src/main/kotlin/com/android/trisolarisserver/controller/DocumentPrompts.kt new file mode 100644 index 0000000..219a18d --- /dev/null +++ b/src/main/kotlin/com/android/trisolarisserver/controller/DocumentPrompts.kt @@ -0,0 +1,13 @@ +package com.android.trisolarisserver.controller + +object DocumentPrompts { + val NAME = "name" to "NAME? Reply only the name or NONE." + val DOB = "dob" to "DOB? Reply only date or NONE." + val ID_NUMBER = "idNumber" to "ID NUMBER? Reply only number or NONE." + val ADDRESS = "address" to "POSTAL ADDRESS ONLY (street/area/city/state). Ignore IDs, UUIDs, and codes. Reply only address or NONE." + val PIN_CODE = "pinCode" to "POSTAL PIN CODE? Reply only pin or NONE." + val CITY = "city" to "CITY? Reply only city or NONE." + val GENDER = "gender" to "GENDER? Reply only MALE/FEMALE/OTHER or NONE." + val NATIONALITY = "nationality" to "NATIONALITY? Reply only nationality or NONE." + val VEHICLE_NUMBER = "vehicleNumber" to "VEHICLE NUMBER? Reply only number or NONE." +} diff --git a/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt b/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt index c288405..724a70b 100644 --- a/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt +++ b/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt @@ -238,8 +238,8 @@ class GuestDocuments( val hasAddress = isYes(results["hasAddress"]) if (hasAddress) { val addressQuestions = linkedMapOf( - "pinCode" to "POSTAL ADDRESS PIN CODE (6 digit)? Reply only pin or NONE.", - "address" to "POSTAL ADDRESS ONLY (street/area/city/state). Ignore IDs, UUIDs, and codes. Reply only address or NONE." + DocumentPrompts.PIN_CODE, + DocumentPrompts.ADDRESS ) for ((key, question) in addressQuestions) { results[key] = llamaClient.ask(imageUrl, question) @@ -249,10 +249,10 @@ class GuestDocuments( val hasGender = isYes(results["hasGenderMentioned"]) if (hasDob && hasGender) { val aadharFrontQuestions = linkedMapOf( - "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.", - "gender" to "GENDER? Reply only MALE/FEMALE/OTHER or NONE." + DocumentPrompts.NAME, + DocumentPrompts.DOB, + DocumentPrompts.ID_NUMBER, + DocumentPrompts.GENDER ) for ((key, question) in aadharFrontQuestions) { results[key] = llamaClient.ask(imageUrl, question) @@ -260,17 +260,6 @@ class GuestDocuments( } } else { - val detectionQuestions = linkedMapOf( - "hasDrivingLicence" to "CONTAINS DRIVING LICENCE? Answer YES or NO only.", - "hasTransportDept" to "CONTAINS TRANSPORT DEPARTMENT? Answer YES or NO only.", - "hasElectionCommission" to "CONTAINS ELECTION COMMISSION OF INDIA? Answer YES or NO only.", - "hasIncomeTaxDept" to "CONTAINS INCOME TAX DEPARTMENT? Answer YES or NO only.", - "hasPassport" to "CONTAINS PASSPORT? Answer YES or NO only." - ) - for ((key, question) in detectionQuestions) { - results[key] = llamaClient.ask(imageUrl, question) - } - if (isYes(results["isVehiclePhoto"])) { val vehicleQuestions = linkedMapOf( "vehicleNumber" to "VEHICLE NUMBER PLATE? Reply only number or NONE." @@ -279,77 +268,103 @@ class GuestDocuments( 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) { - val drivingQuestions = linkedMapOf( - "name" to "NAME? Reply only the name or NONE.", - "dob" to "DOB? Reply only date or NONE.", - "idNumber" to "DL NUMBER? Reply only number or NONE.", - "address" to "POSTAL ADDRESS ONLY (street/area/city/state). Ignore IDs, UUIDs, and codes. 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." - ) + val drivingQuestions = linkedMapOf( + DocumentPrompts.NAME, + DocumentPrompts.DOB, + "idNumber" to "DL NUMBER? Reply only number or NONE.", + DocumentPrompts.ADDRESS, + DocumentPrompts.PIN_CODE, + DocumentPrompts.CITY, + DocumentPrompts.GENDER, + DocumentPrompts.NATIONALITY + ) for ((key, question) in drivingQuestions) { results[key] = llamaClient.ask(imageUrl, question) } - } else if (isYes(results["hasElectionCommission"])) { - val voterQuestions = linkedMapOf( - "name" to "NAME? Reply only the name or NONE.", - "dob" to "DOB? Reply only date or NONE.", - "idNumber" to "VOTER ID NUMBER? Reply only number or NONE.", - "address" to "POSTAL ADDRESS ONLY (street/area/city/state). Ignore IDs, UUIDs, and codes. 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 voterQuestions) { - results[key] = llamaClient.ask(imageUrl, question) - } - } else if (isYes(results["hasIncomeTaxDept"])) { - val panQuestions = linkedMapOf( - "name" to "NAME? Reply only the name or NONE.", - "dob" to "DOB? Reply only date or NONE.", - "idNumber" to "PAN NUMBER? Reply only number or NONE.", - "address" to "POSTAL ADDRESS ONLY (street/area/city/state). Ignore IDs, UUIDs, and codes. 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 panQuestions) { - results[key] = llamaClient.ask(imageUrl, question) - } - } else if (isYes(results["hasPassport"])) { - val passportQuestions = linkedMapOf( - "name" to "NAME? Reply only the name or NONE.", - "dob" to "DOB? Reply only date or NONE.", - "idNumber" to "PASSPORT NUMBER? Reply only number or NONE.", - "address" to "POSTAL ADDRESS ONLY (street/area/city/state). Ignore IDs, UUIDs, and codes. 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 passportQuestions) { - results[key] = llamaClient.ask(imageUrl, question) - } } else { - val generalQuestions = linkedMapOf( - "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 "POSTAL ADDRESS ONLY (street/area/city/state). Ignore IDs, UUIDs, and codes. Reply only address or NONE.", - "vehicleNumber" to "VEHICLE NUMBER? Reply only number 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." + results["hasElectionCommission"] = llamaClient.ask( + imageUrl, + "CONTAINS ELECTION COMMISSION OF INDIA? Answer YES or NO only." ) - for ((key, question) in generalQuestions) { - results[key] = llamaClient.ask(imageUrl, question) + 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["hasIncomeTaxDept"] = llamaClient.ask( + imageUrl, + "CONTAINS INCOME TAX DEPARTMENT? Answer YES or NO only." + ) + if (isYes(results["hasIncomeTaxDept"])) { + val panQuestions = linkedMapOf( + DocumentPrompts.NAME, + DocumentPrompts.DOB, + "idNumber" to "PAN NUMBER? Reply only number or NONE.", + DocumentPrompts.ADDRESS, + DocumentPrompts.PIN_CODE, + DocumentPrompts.CITY, + DocumentPrompts.GENDER, + DocumentPrompts.NATIONALITY + ) + for ((key, question) in panQuestions) { + results[key] = llamaClient.ask(imageUrl, question) + } + } else { + results["hasPassport"] = llamaClient.ask( + imageUrl, + "CONTAINS PASSPORT? Answer YES or NO only." + ) + 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) + } + } + } } } }