ai creates booking
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user