guest docs: improve question logic

This commit is contained in:
androidlover5842
2026-01-31 01:52:28 +05:30
parent 45862dc7f3
commit d4a9a06725

View File

@@ -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,6 +271,14 @@ class GuestDocuments(
results[key] = llamaClient.ask(imageUrl, question)
}
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 {
val isDriving = isYes(results["hasDrivingLicence"]) || isYes(results["hasTransportDept"])
if (isDriving) {
val drivingQuestions = linkedMapOf(
@@ -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.
}
}