Add isYes helper for AI results
All checks were successful
build-and-deploy / build-deploy (push) Successful in 32s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 32s
This commit is contained in:
@@ -214,8 +214,7 @@ class GuestDocuments(
|
|||||||
val results = linkedMapOf<String, String>()
|
val results = linkedMapOf<String, String>()
|
||||||
results["hasAadhar"] = llamaClient.ask(imageUrl, "CONTAINS AADHAAR? Answer YES or NO only.")
|
results["hasAadhar"] = llamaClient.ask(imageUrl, "CONTAINS AADHAAR? Answer YES or NO only.")
|
||||||
results["hasUidai"] = llamaClient.ask(imageUrl, "CONTAINS UIDAI? 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) ||
|
val hasAadhar = isYes(results["hasAadhar"]) || isYes(results["hasUidai"])
|
||||||
results["hasUidai"].orEmpty().contains("YES", true)
|
|
||||||
if (hasAadhar) {
|
if (hasAadhar) {
|
||||||
val aadharQuestions = linkedMapOf(
|
val aadharQuestions = linkedMapOf(
|
||||||
"hasAddress" to "ADDRESS PRESENT? Answer YES or NO only.",
|
"hasAddress" to "ADDRESS PRESENT? Answer YES or NO only.",
|
||||||
@@ -262,22 +261,22 @@ class GuestDocuments(
|
|||||||
}
|
}
|
||||||
|
|
||||||
results["docType"] = when {
|
results["docType"] = when {
|
||||||
results["hasCourt"].orEmpty().contains("YES", ignoreCase = true) ||
|
isYes(results["hasCourt"]) ||
|
||||||
results["hasHighCourt"].orEmpty().contains("YES", ignoreCase = true) ||
|
isYes(results["hasHighCourt"]) ||
|
||||||
results["hasSupremeCourt"].orEmpty().contains("YES", ignoreCase = true) ||
|
isYes(results["hasSupremeCourt"]) ||
|
||||||
results["hasJudiciary"].orEmpty().contains("YES", ignoreCase = true) -> "COURT_ID"
|
isYes(results["hasJudiciary"]) -> "COURT_ID"
|
||||||
results["hasPolice"].orEmpty().contains("YES", ignoreCase = true) -> "POLICE_ID"
|
isYes(results["hasPolice"]) -> "POLICE_ID"
|
||||||
results["hasPassport"].orEmpty().contains("YES", ignoreCase = true) -> "PASSPORT"
|
isYes(results["hasPassport"]) -> "PASSPORT"
|
||||||
results["hasTransportDept"].orEmpty().contains("YES", ignoreCase = true) ||
|
isYes(results["hasTransportDept"]) ||
|
||||||
results["hasDrivingLicence"].orEmpty().contains("YES", ignoreCase = true) -> "TRANSPORT"
|
isYes(results["hasDrivingLicence"]) -> "TRANSPORT"
|
||||||
results["hasIncomeTaxDept"].orEmpty().contains("YES", ignoreCase = true) -> "PAN"
|
isYes(results["hasIncomeTaxDept"]) -> "PAN"
|
||||||
results["hasElectionCommission"].orEmpty().contains("YES", ignoreCase = true) -> "VOTER_ID"
|
isYes(results["hasElectionCommission"]) -> "VOTER_ID"
|
||||||
results["hasAadhar"].orEmpty().contains("YES", ignoreCase = true) ||
|
isYes(results["hasAadhar"]) ||
|
||||||
results["hasUidai"].orEmpty().contains("YES", ignoreCase = true) -> {
|
isYes(results["hasUidai"]) -> {
|
||||||
if (results["hasAddress"].orEmpty().contains("YES", ignoreCase = true)) "AADHAR_BACK" else "AADHAR_FRONT"
|
if (isYes(results["hasAddress"])) "AADHAR_BACK" else "AADHAR_FRONT"
|
||||||
}
|
}
|
||||||
results["vehicleNumber"].orEmpty().isNotBlank() && !results["vehicleNumber"]!!.contains("NONE", true) -> "VEHICLE"
|
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"
|
else -> "UNKNOWN"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,3 +353,7 @@ private fun GuestDocument.toResponse(objectMapper: ObjectMapper): GuestDocumentR
|
|||||||
extractedAt = extractedAt?.toString()
|
extractedAt = extractedAt?.toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isYes(value: String?): Boolean {
|
||||||
|
return value.orEmpty().contains("YES", ignoreCase = true)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user