From 591435cf1c6e5b0f832682bbbc69064859cf7d24 Mon Sep 17 00:00:00 2001 From: songyibing <695026335@qq.com> Date: Fri, 5 Jan 2024 17:02:28 +0800 Subject: [PATCH] response.body().string() can only call string() once. --- .../unitmesh/devti/llms/custom/JSONBodyResponseCallback.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/cc/unitmesh/devti/llms/custom/JSONBodyResponseCallback.kt b/src/main/kotlin/cc/unitmesh/devti/llms/custom/JSONBodyResponseCallback.kt index a0bda3531a..55a761226f 100644 --- a/src/main/kotlin/cc/unitmesh/devti/llms/custom/JSONBodyResponseCallback.kt +++ b/src/main/kotlin/cc/unitmesh/devti/llms/custom/JSONBodyResponseCallback.kt @@ -16,8 +16,9 @@ class JSONBodyResponseCallback(private val responseFormat: String,private val ca } override fun onResponse(call: Call, response: Response) { - println("got response ${response.body?.string()}") - val responseContent: String = JsonPath.parse(response.body?.string())?.read(responseFormat) ?: "" + val responseBody: String? = response.body?.string() + println("got response $responseBody") + val responseContent: String = JsonPath.parse(responseBody)?.read(responseFormat) ?: "" runBlocking() { callback(responseContent)