From b5aacfc8c63d21f1ebabf34860135d704fd6aa79 Mon Sep 17 00:00:00 2001 From: androidlover5842 Date: Sat, 31 Jan 2026 03:19:06 +0530 Subject: [PATCH] llama settings --- .../trisolarisserver/component/LlamaClient.kt | 22 +++++++++++++- .../controller/GuestDocuments.kt | 1 - .../resources/application-prod.properties | 2 +- src/main/resources/application.properties | 30 ++++--------------- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/main/kotlin/com/android/trisolarisserver/component/LlamaClient.kt b/src/main/kotlin/com/android/trisolarisserver/component/LlamaClient.kt index 2172c4f..5c003a3 100644 --- a/src/main/kotlin/com/android/trisolarisserver/component/LlamaClient.kt +++ b/src/main/kotlin/com/android/trisolarisserver/component/LlamaClient.kt @@ -13,7 +13,17 @@ class LlamaClient( private val restTemplate: RestTemplate, private val objectMapper: ObjectMapper, @Value("\${ai.llama.baseUrl}") - private val baseUrl: String + private val baseUrl: String, + @Value("\${ai.llama.temperature:0.7}") + private val temperature: Double, + @Value("\${ai.llama.topP:0.8}") + private val topP: Double, + @Value("\${ai.llama.minP:0.2}") + private val minP: Double, + @Value("\${ai.llama.repeatPenalty:1.0}") + private val repeatPenalty: Double, + @Value("\${ai.llama.topK:40}") + private val topK: Int ) { private val systemPrompt = "Look only at visible text. " + @@ -24,6 +34,11 @@ class LlamaClient( fun ask(imageUrl: String, question: String): String { val payload = mapOf( "model" to "qwen", + "temperature" to temperature, + "top_p" to topP, + "min_p" to minP, + "repeat_penalty" to repeatPenalty, + "top_k" to topK, "messages" to listOf( mapOf( "role" to "system", @@ -44,6 +59,11 @@ class LlamaClient( fun askText(content: String, question: String): String { val payload = mapOf( "model" to "qwen", + "temperature" to temperature, + "top_p" to topP, + "min_p" to minP, + "repeat_penalty" to repeatPenalty, + "top_k" to topK, "messages" to listOf( mapOf( "role" to "system", diff --git a/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt b/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt index 1836e5c..c47bd30 100644 --- a/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt +++ b/src/main/kotlin/com/android/trisolarisserver/controller/GuestDocuments.kt @@ -220,7 +220,6 @@ class GuestDocuments( "IS THIS A VEHICLE NUMBER PLATE PHOTO? Answer YES or NO only." ) - if (isYes(results["isVehiclePhoto"])) { results["vehicleNumber"] = llamaClient.ask( imageUrl, diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index f139546..bbd1dc9 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -1,4 +1,4 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/trisolaris ai.llama.baseUrl=http://localhost:8089/v1/chat/completions logging.level.com.android.trisolarisserver.controller.Auth=INFO -storage.documents.aiBaseUrl=http://127.0.0.1:18921 \ No newline at end of file +storage.documents.aiBaseUrl=http://127.0.0.1:18921 diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 66f2632..a4f2a25 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,25 +1,5 @@ -spring.application.name=TrisolarisServer -spring.datasource.username=android -spring.datasource.password=taddymydoggy! -spring.jpa.hibernate.ddl-auto=update -spring.jpa.open-in-view=false -spring.flyway.enabled=false -spring.flyway.locations=classpath:db/migration -storage.documents.root=/home/androidlover5842/docs -storage.documents.publicBaseUrl=https://api.hoteltrisolaris.in -storage.documents.tokenSecret=change-me -storage.documents.tokenTtlSeconds=300 -storage.emails.root=/home/androidlover5842/docs/emails -storage.emails.publicBaseUrl=https://api.hoteltrisolaris.in -storage.rooms.root=/home/androidlover5842/docs/rooms -storage.rooms.publicBaseUrl=https://api.hoteltrisolaris.in -mail.imap.host=localhost -mail.imap.port=993 -mail.imap.protocol=imaps -mail.imap.username= -mail.imap.password= -mail.imap.pollMs=60000 -mail.imap.enabled=false -server.port=18921 -spring.servlet.multipart.max-file-size=20MB -spring.servlet.multipart.max-request-size=20MB +ai.llama.temperature=0.7 +ai.llama.topP=0.8 +ai.llama.minP=0.2 +ai.llama.repeatPenalty=1.0 +ai.llama.topK=40