,,,,,
This commit is contained in:
parent
8c16275c01
commit
50f43c063f
@ -331,67 +331,7 @@ class Telegram {
|
|||||||
|
|
||||||
} else if (req.reqMsg?.contains("검색") == true) {
|
} else if (req.reqMsg?.contains("검색") == true) {
|
||||||
var originalQuery = req.reqMsg
|
var originalQuery = req.reqMsg
|
||||||
val gSearch = "https://www.google.com/search?q=${originalQuery?.replace("오늘", SimpleDateFormat("yyyMMdd").format(Date()))}&tbs=qdr%3Am"
|
lama.generateResponse(originalQuery,msg.from?.id.toString())
|
||||||
println("gSearch >>> ${gSearch}")
|
|
||||||
WebClient.create().get()
|
|
||||||
.uri(gSearch)
|
|
||||||
.retrieve()
|
|
||||||
.bodyToMono(String::class.java).timeout(Duration.ofMinutes(20L)).block()?.let { gsResult ->
|
|
||||||
println("gsearch result ==> ${Gson().toJson(gsResult)}")
|
|
||||||
var additionalInfo = StringBuffer()
|
|
||||||
// gsResult.items?.forEach {
|
|
||||||
// additionalInfo.append("- 정보 출처 :").append(it.link).append("\n")
|
|
||||||
// try {
|
|
||||||
// Jsoup.connect(it.link).get().body().text().let {
|
|
||||||
// if (it.length > 1000) {
|
|
||||||
// additionalInfo.append("- 정보 내용 :").append(it.chunked(500).first()).append("\n")
|
|
||||||
// } else {
|
|
||||||
// additionalInfo.append("- 정보 내용 :").append(it).append("\n")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (e : Exception) {
|
|
||||||
// additionalInfo.append("- 정보 타이틀 : ").append(it.title).append("\n")
|
|
||||||
// additionalInfo.append("- 정보 요약 :").append(it.snippet).append("\n")
|
|
||||||
// println(it.link)
|
|
||||||
// e.printStackTrace()
|
|
||||||
// }
|
|
||||||
// additionalInfo.append("\n")
|
|
||||||
// }
|
|
||||||
println("additionalInfo >>> ${additionalInfo.toString()}")
|
|
||||||
req.reqMsg = "질문 : " + originalQuery + "\n\n추가정보:" + "\n${additionalInfo.toString()} 위의 질문과 추가 정보를 고려하여 답변해주세요."
|
|
||||||
|
|
||||||
val client = WebClient.create()
|
|
||||||
client.post()
|
|
||||||
.uri(lamaGenerated)
|
|
||||||
.body(BodyInserters.fromValue(Gson().toJson(req)))
|
|
||||||
.retrieve()
|
|
||||||
.bodyToMono(String::class.java).timeout(Duration.ofMinutes(20L)).block()?.let { result ->
|
|
||||||
println("generate Result ==> ${result}")
|
|
||||||
Gson().fromJson(result, BumlamaResp::class.java)?.let { sss ->
|
|
||||||
var toalmsg = "${originalQuery}의 대답이 도착했어요.\n" + "\n" + "${sss.response}"
|
|
||||||
println(Gson().toJson(sss))
|
|
||||||
if (toalmsg.length > 200) {
|
|
||||||
toalmsg.chunked(120).forEach {
|
|
||||||
val fullUrl =
|
|
||||||
"https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage?chat_id=${globalEvv.telegramMyId}&text=${it}"
|
|
||||||
WebClient.create().get()
|
|
||||||
.uri(fullUrl)
|
|
||||||
.retrieve()
|
|
||||||
.bodyToMono(String::class.java).block() ?: "FAIL"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
val fullUrl =
|
|
||||||
"https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage?chat_id=${globalEvv.telegramMyId}&text=${req.reqMsg}의 대답이 도착했어요.\n\n${sss.response}"
|
|
||||||
logService.log("fullUrl >>> ${fullUrl}")
|
|
||||||
WebClient.create().get()
|
|
||||||
.uri(fullUrl)
|
|
||||||
.retrieve()
|
|
||||||
.bodyToMono(String::class.java).block() ?: "FAIL"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
val client = WebClient.create()
|
val client = WebClient.create()
|
||||||
client.post()
|
client.post()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user