Add isYes helper for AI results
All checks were successful
build-and-deploy / build-deploy (push) Successful in 32s

This commit is contained in:
androidlover5842
2026-01-31 01:11:58 +05:30
parent 51c5b2cfdb
commit 3d1bf64790

View File

@@ -214,8 +214,7 @@ class GuestDocuments(
val results = linkedMapOf<String, String>()
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)
val hasAadhar = isYes(results["hasAadhar"]) || isYes(results["hasUidai"])
if (hasAadhar) {
val aadharQuestions = linkedMapOf(
"hasAddress" to "ADDRESS PRESENT? Answer YES or NO only.",
@@ -262,22 +261,22 @@ class GuestDocuments(
}
results["docType"] = when {
results["hasCourt"].orEmpty().contains("YES", ignoreCase = true) ||
results["hasHighCourt"].orEmpty().contains("YES", ignoreCase = true) ||
results["hasSupremeCourt"].orEmpty().contains("YES", ignoreCase = true) ||
results["hasJudiciary"].orEmpty().contains("YES", ignoreCase = true) -> "COURT_ID"
results["hasPolice"].orEmpty().contains("YES", ignoreCase = true) -> "POLICE_ID"
results["hasPassport"].orEmpty().contains("YES", ignoreCase = true) -> "PASSPORT"
results["hasTransportDept"].orEmpty().contains("YES", ignoreCase = true) ||
results["hasDrivingLicence"].orEmpty().contains("YES", ignoreCase = true) -> "TRANSPORT"
results["hasIncomeTaxDept"].orEmpty().contains("YES", ignoreCase = true) -> "PAN"
results["hasElectionCommission"].orEmpty().contains("YES", ignoreCase = true) -> "VOTER_ID"
results["hasAadhar"].orEmpty().contains("YES", ignoreCase = true) ||
results["hasUidai"].orEmpty().contains("YES", ignoreCase = true) -> {
if (results["hasAddress"].orEmpty().contains("YES", ignoreCase = true)) "AADHAR_BACK" else "AADHAR_FRONT"
isYes(results["hasCourt"]) ||
isYes(results["hasHighCourt"]) ||
isYes(results["hasSupremeCourt"]) ||
isYes(results["hasJudiciary"]) -> "COURT_ID"
isYes(results["hasPolice"]) -> "POLICE_ID"
isYes(results["hasPassport"]) -> "PASSPORT"
isYes(results["hasTransportDept"]) ||
isYes(results["hasDrivingLicence"]) -> "TRANSPORT"
isYes(results["hasIncomeTaxDept"]) -> "PAN"
isYes(results["hasElectionCommission"]) -> "VOTER_ID"
isYes(results["hasAadhar"]) ||
isYes(results["hasUidai"]) -> {
if (isYes(results["hasAddress"])) "AADHAR_BACK" else "AADHAR_FRONT"
}
results["vehicleNumber"].orEmpty().isNotBlank() && !results["vehicleNumber"]!!.contains("NONE", true) -> "VEHICLE"
results["isVehiclePhoto"].orEmpty().contains("YES", ignoreCase = true) -> "VEHICLE_PHOTO"
isYes(results["isVehiclePhoto"]) -> "VEHICLE_PHOTO"
else -> "UNKNOWN"
}
@@ -354,3 +353,7 @@ private fun GuestDocument.toResponse(objectMapper: ObjectMapper): GuestDocumentR
extractedAt = extractedAt?.toString()
)
}
private fun isYes(value: String?): Boolean {
return value.orEmpty().contains("YES", ignoreCase = true)
}