From 20b80cd566ff56b207bc0d0d235abbb15df103bd Mon Sep 17 00:00:00 2001 From: Christian Maschmann Date: Tue, 23 Jan 2024 10:08:48 +0100 Subject: [PATCH] use the Unconfined Dispatcher for LLM-service-calls --- .../kotlin/io/holunda/connector/common/LLMServiceClient.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 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 61dfd3c..1dc54af 100644 --- a/core/src/main/kotlin/io/holunda/connector/common/LLMServiceClient.kt +++ b/core/src/main/kotlin/io/holunda/connector/common/LLMServiceClient.kt @@ -40,19 +40,19 @@ object LLMServiceClient { inline fun run(task: String, request: T): JsonNode = runBlocking { val response: String = try { - async { + async(Dispatchers.Unconfined) { client.post("${llmServiceUrl}/$task") { contentType(ContentType.Application.Json) setBody(jsonMapper.writeValueAsString(request)) }.body() as String }.await() } catch (e: Exception) { - throw LLMClientException() + throw LLMClientException(e) } jsonMapper.readTree(response) } - class LLMClientException: RuntimeException("LLM request failed") + class LLMClientException(e: Exception) : RuntimeException("LLM request failed", e) }