Fix Aadhaar question branching logic
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:
@@ -24,8 +24,6 @@ import org.springframework.transaction.annotation.Transactional
|
|||||||
import org.springframework.web.bind.annotation.*
|
import org.springframework.web.bind.annotation.*
|
||||||
import org.springframework.http.MediaType
|
import org.springframework.http.MediaType
|
||||||
import jakarta.servlet.http.HttpServletResponse
|
import jakarta.servlet.http.HttpServletResponse
|
||||||
import org.aspectj.weaver.patterns.TypePatternQuestions
|
|
||||||
import org.hibernate.validator.constraints.URL
|
|
||||||
import org.springframework.web.multipart.MultipartFile
|
import org.springframework.web.multipart.MultipartFile
|
||||||
import org.springframework.web.server.ResponseStatusException
|
import org.springframework.web.server.ResponseStatusException
|
||||||
import java.time.OffsetDateTime
|
import java.time.OffsetDateTime
|
||||||
@@ -33,11 +31,6 @@ import java.nio.file.Files
|
|||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import kotlin.collections.component1
|
|
||||||
import kotlin.collections.component2
|
|
||||||
import kotlin.collections.iterator
|
|
||||||
import kotlin.collections.set
|
|
||||||
import kotlin.text.set
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/properties/{propertyId}/guests/{guestId}/documents")
|
@RequestMapping("/properties/{propertyId}/guests/{guestId}/documents")
|
||||||
@@ -225,30 +218,30 @@ class GuestDocuments(
|
|||||||
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.",
|
||||||
"hasGender" to "GENDER PRESENT? Answer YES or NO only.",
|
|
||||||
"hasDob" to "DOB? Reply YES or NO.",
|
"hasDob" to "DOB? Reply YES or NO.",
|
||||||
"hasGender" to "GENDER MENTIONED? Reply YES or NO.",
|
"hasGenderMentioned" to "GENDER MENTIONED? Reply YES or NO."
|
||||||
)
|
)
|
||||||
for ((key, question) in aadharQuestions) {
|
for ((key, question) in aadharQuestions) {
|
||||||
results[key] = llamaClient.ask(imageUrl, question)
|
results[key] = llamaClient.ask(imageUrl, question)
|
||||||
}
|
}
|
||||||
val hashAddress=isYes("hasAddress")
|
val hasAddress = isYes(results["hasAddress"])
|
||||||
if (hashAddress){
|
if (hasAddress) {
|
||||||
val addressQuestions = linkedMapOf(
|
val addressQuestions = linkedMapOf(
|
||||||
"pinCode" to "POSTAL ADDRESS PIN CODE (6 digit)? Reply only pin or NONE.",
|
"pinCode" to "POSTAL ADDRESS PIN CODE (6 digit)? Reply only pin or NONE.",
|
||||||
"address" to "POSTAL ADDRESS? Reply only address or NONE.")
|
"address" to "POSTAL ADDRESS ONLY (street/area/city/state). Ignore IDs, UUIDs, and codes. Reply only address or NONE."
|
||||||
|
)
|
||||||
for ((key, question) in addressQuestions) {
|
for ((key, question) in addressQuestions) {
|
||||||
results[key] = llamaClient.ask(imageUrl, question)
|
results[key] = llamaClient.ask(imageUrl, question)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val hasDOB=isYes("hasDob")
|
val hasDob = isYes(results["hasDob"])
|
||||||
val hasGender=isYes("hasGender")
|
val hasGender = isYes(results["hasGenderMentioned"])
|
||||||
if (hasDOB && hasGender){
|
if (hasDob && hasGender) {
|
||||||
val aadharFrontQuestions = linkedMapOf(
|
val aadharFrontQuestions = linkedMapOf(
|
||||||
"name" to "NAME? Reply only the name or NONE.",
|
"name" to "NAME? Reply only the name or NONE.",
|
||||||
"dob" to "DOB? Reply only date or NONE.",
|
"dob" to "DOB? Reply only date or NONE.",
|
||||||
"idNumber" to "ID NUMBER? Reply only number or NONE.",
|
"idNumber" to "ID NUMBER? Reply only number or NONE.",
|
||||||
"gender" to "GENDER? Reply only MALE/FEMALE/OTHER or NONE.",
|
"gender" to "GENDER? Reply only MALE/FEMALE/OTHER or NONE."
|
||||||
)
|
)
|
||||||
for ((key, question) in aadharFrontQuestions) {
|
for ((key, question) in aadharFrontQuestions) {
|
||||||
results[key] = llamaClient.ask(imageUrl, question)
|
results[key] = llamaClient.ask(imageUrl, question)
|
||||||
@@ -379,4 +372,4 @@ private fun GuestDocument.toResponse(objectMapper: ObjectMapper): GuestDocumentR
|
|||||||
|
|
||||||
private fun isYes(value: String?): Boolean {
|
private fun isYes(value: String?): Boolean {
|
||||||
return value.orEmpty().contains("YES", ignoreCase = true)
|
return value.orEmpty().contains("YES", ignoreCase = true)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user