Skip to content

Commit

Permalink
add additional logging
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-maschmann committed Jan 23, 2024
1 parent 20b80cd commit 655d641
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ import io.ktor.client.request.*
import io.ktor.http.*
import io.ktor.serialization.jackson.*
import kotlinx.coroutines.*
import mu.KLogging

object LLMServiceClient {

val logger = KLogging().logger

var llmServiceUrl = System.getenv("LLM_SERVICE_URL") ?: "http://localhost:9999"

val client = HttpClient {
Expand All @@ -39,8 +42,10 @@ object LLMServiceClient {
val jsonMapper = jacksonObjectMapper()

inline fun <reified T : Any> run(task: String, request: T): JsonNode = runBlocking {
logger.info("Entered run() in LLMServiceClient")
val response: String = try {
async(Dispatchers.Unconfined) {
logger.info("About to post request")
client.post("${llmServiceUrl}/$task") {
contentType(ContentType.Application.Json)
setBody(jsonMapper.writeValueAsString(request))
Expand All @@ -49,6 +54,7 @@ object LLMServiceClient {
} catch (e: Exception) {
throw LLMClientException(e)
}
logger.info("Response received")

jsonMapper.readTree(response)
}
Expand Down

0 comments on commit 655d641

Please sign in to comment.