ai creates booking

This commit is contained in:
androidlover5842
2026-01-24 19:22:37 +05:30
parent b8c9f8dac4
commit ac79d6d1c0
18 changed files with 559 additions and 12 deletions

View File

@@ -15,10 +15,20 @@ class LlamaClient(
@Value("\${ai.llama.baseUrl}")
private val baseUrl: String
) {
private val systemPrompt =
"Look only at visible text. " +
"Return the exact text you can read verbatim. " +
"If the text is unclear, partial, or inferred, return NOT CLEARLY VISIBLE. " +
"Do not guess. Do not explain."
fun ask(imageUrl: String, question: String): String {
val payload = mapOf(
"model" to "qwen",
"messages" to listOf(
mapOf(
"role" to "system",
"content" to systemPrompt
),
mapOf(
"role" to "user",
"content" to listOf(
@@ -36,4 +46,27 @@ class LlamaClient(
val node = objectMapper.readTree(body)
return node.path("choices").path(0).path("message").path("content").asText()
}
fun askText(content: String, question: String): String {
val payload = mapOf(
"model" to "qwen",
"messages" to listOf(
mapOf(
"role" to "system",
"content" to systemPrompt
),
mapOf(
"role" to "user",
"content" to "${question}\n\nEMAIL:\n${content}"
)
)
)
val headers = HttpHeaders()
headers.contentType = MediaType.APPLICATION_JSON
val entity = HttpEntity(payload, headers)
val response = restTemplate.postForEntity(baseUrl, entity, String::class.java)
val body = response.body ?: return ""
val node = objectMapper.readTree(body)
return node.path("choices").path(0).path("message").path("content").asText()
}
}