...
This commit is contained in:
parent
50f43c063f
commit
6770f6f32e
@ -5,7 +5,13 @@ package kr.lunaticbum.back.lun.service
|
||||
import com.google.gson.Gson
|
||||
import com.knuddels.jtokkit.api.IntArrayList
|
||||
import io.micrometer.observation.ObservationRegistry
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kr.lunaticbum.back.lun.configs.GlobalEnvironment
|
||||
import kr.lunaticbum.back.lun.controllers.BumlamaResp
|
||||
import kr.lunaticbum.back.lun.controllers.TelegramSendMsg
|
||||
import kr.lunaticbum.back.lun.controllers.lamaGenerated
|
||||
import kr.lunaticbum.back.lun.model.*
|
||||
import org.jsoup.Jsoup
|
||||
import org.springframework.ai.embedding.EmbeddingRequest
|
||||
@ -88,7 +94,7 @@ class Lama {
|
||||
it.originQuery = query
|
||||
val data = Gson().toJson(it)
|
||||
println(it.title)
|
||||
Jsoup.connect(it.url).get().body().text()?.let { text ->
|
||||
Jsoup.connect(it.url).get().html().let { text ->
|
||||
try {
|
||||
println("text >>>>> $text")
|
||||
it.pageData = chatClient.chat(OllamaApi.ChatRequest.Builder("phi4:14b").stream(false).format("json").messages(
|
||||
@ -214,6 +220,28 @@ class Lama {
|
||||
).build())
|
||||
}
|
||||
println(response.message.content)
|
||||
// val fullUrl = "https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage?chat_id=${globalEvv.telegramMyId}&text=${query}의 대답이 도착했어요.\n\n${response.message.content}"
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
var toalmsg = "${query}의 대답이 도착했어요.\n" + "${response.message.content}"
|
||||
val fullUrl = "https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage"
|
||||
toalmsg.chunked(2048).forEach { chunkedMsg ->
|
||||
println("fullUrl >>> ${fullUrl}")
|
||||
(targetId ?: globalEvv.telegramMyId)?.let {
|
||||
var tlgSend = TelegramSendMsg(it, chunkedMsg)
|
||||
WebClient
|
||||
.create()
|
||||
.post()
|
||||
.uri(fullUrl)
|
||||
.body(BodyInserters.fromValue(Gson().toJson(tlgSend)))
|
||||
.retrieve().bodyToMono(String::class.java).timeout(Duration.ofMinutes(20L))
|
||||
.block()?.let { result ->
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
println("On generateResponse :: END OF Answer")
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user