guest docs: improve question logic
This commit is contained in:
@@ -212,6 +212,17 @@ class GuestDocuments(
|
||||
"${aiBaseUrl}/properties/$propertyId/guests/$guestId/documents/${document.id}/file?token=$token"
|
||||
|
||||
val results = linkedMapOf<String, String>()
|
||||
results["isVehiclePhoto"] = llamaClient.ask(
|
||||
imageUrl,
|
||||
"IS THIS A VEHICLE NUMBER PLATE PHOTO? Answer YES or NO only."
|
||||
)
|
||||
if (isYes(results["isVehiclePhoto"])) {
|
||||
results["vehicleNumber"] = llamaClient.ask(
|
||||
imageUrl,
|
||||
"VEHICLE NUMBER PLATE? Reply only number or NONE."
|
||||
)
|
||||
}
|
||||
|
||||
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"])
|
||||
@@ -260,80 +271,88 @@ class GuestDocuments(
|
||||
results[key] = llamaClient.ask(imageUrl, question)
|
||||
}
|
||||
|
||||
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."
|
||||
if (isYes(results["isVehiclePhoto"])) {
|
||||
val vehicleQuestions = linkedMapOf(
|
||||
"vehicleNumber" to "VEHICLE NUMBER PLATE? Reply only number or NONE."
|
||||
)
|
||||
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) {
|
||||
for ((key, question) in vehicleQuestions) {
|
||||
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."
|
||||
)
|
||||
for ((key, question) in generalQuestions) {
|
||||
results[key] = llamaClient.ask(imageUrl, question)
|
||||
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."
|
||||
)
|
||||
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."
|
||||
)
|
||||
for ((key, question) in generalQuestions) {
|
||||
results[key] = llamaClient.ask(imageUrl, question)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
results["docType"] = when {
|
||||
isYes(results["hasCourt"]) ||
|
||||
@@ -359,7 +378,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.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user