Skip to content

Commit

Permalink
chore: логирование ответа
Browse files Browse the repository at this point in the history
  • Loading branch information
Djaler committed Oct 6, 2023
1 parent 834b9d2 commit d741232
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import com.github.djaler.evilbot.config.yandex.YandexApiProperties
import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
import org.apache.logging.log4j.LogManager
import org.springframework.context.annotation.Conditional
import org.springframework.stereotype.Component

Expand All @@ -19,20 +21,30 @@ class YandexGptClient(
private val httpClient: HttpClient,
private val yandexApiProperties: YandexApiProperties
) {
companion object {
private val log = LogManager.getLogger()
}

suspend fun generateLinkThesis(link: String, sessionId: String? = null): ThesisResult {
return httpClient.post {
val response = httpClient.post {
url("https://300.ya.ru/api/generation")

contentType(ContentType.Application.Json)
setBody(mapOf(
"article_url" to link,
"session_id" to sessionId
))
setBody(
mapOf(
"article_url" to link,
"session_id" to sessionId
)
)

headers {
append(HttpHeaders.Authorization, "OAuth ${yandexApiProperties.token}")
}
}.body()
}

log.info("yandex gpt response: ${response.bodyAsText()}")

return response.body()
}
}

Expand Down

0 comments on commit d741232

Please sign in to comment.