From b19a6f82747b8f0fead8caff0227fca20b4e527d Mon Sep 17 00:00:00 2001 From: Christian Maschmann Date: Fri, 19 Jan 2024 12:56:25 +0100 Subject: [PATCH] try async calls to http-client --- .../io/holunda/connector/common/LLMServiceClient.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/main/kotlin/io/holunda/connector/common/LLMServiceClient.kt b/core/src/main/kotlin/io/holunda/connector/common/LLMServiceClient.kt index ef0f262..835da1e 100644 --- a/core/src/main/kotlin/io/holunda/connector/common/LLMServiceClient.kt +++ b/core/src/main/kotlin/io/holunda/connector/common/LLMServiceClient.kt @@ -40,10 +40,12 @@ object LLMServiceClient { inline fun run(task: String, request: T): JsonNode = runBlocking { val response: String = try { - client.post("${llmServiceUrl}/$task") { - contentType(ContentType.Application.Json) - setBody(jsonMapper.writeValueAsString(request)) - }.body() + async { + client.post("${llmServiceUrl}/$task") { + contentType(ContentType.Application.Json) + setBody(jsonMapper.writeValueAsString(request)) + } + }.await().body() } catch (e: Exception) { throw LLMClientException() }