尝试连接 智谱 ChatGLM时报错
报错信息:
io.ktor.serialization.JsonConvertException: Illegal input: Fields [code, param] are required for type with serial name 'com.aallam.openai.api.exception.OpenAIErrorDetails', but they were missing at path: $.error
at io.ktor.serialization.kotlinx.KotlinxSerializationConverter.deserialize(KotlinxSerializationConverter.kt:90) ~[ktor-serialization-kotlinx-jvm-2.3.2.jar:2.3.2]
at io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1$2.emit(Emitters.kt:224) ~[ktor-serialization-jvm-2.3.2.jar:2.3.2]
at kotlinx.coroutines.flow.FlowKtBuildersKt$asFlow$$inlined$unsafeFlow$3.collect(SafeCollector.common.kt:116) ~[kotlinx-coroutines-core-jvm-1.7.3.jar:na]
at io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1.collect(SafeCollector.common.kt:113) ~[ktor-serialization-jvm-2.3.2.jar:2.3.2]
at kotlinx.coroutines.flow.FlowKtReduceKt.firstOrNull(Reduce.kt:243) ~[kotlinx-coroutines-core-jvm-1.7.3.jar:na]
at kotlinx.coroutines.flow.FlowKt.firstOrNull(Unknown Source) ~[kotlinx-coroutines-core-jvm-1.7.3.jar:na]
at io.ktor.serialization.ContentConverterKt.deserialize(ContentConverter.kt:123) ~[ktor-serialization-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.plugins.contentnegotiation.ContentNegotiation.convertResponse$ktor_client_content_negotiation(ContentNegotiation.kt:230) ~[ktor-client-content-negotiation-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.plugins.contentnegotiation.ContentNegotiation$Plugin$install$2.invokeSuspend(ContentNegotiation.kt:262) ~[ktor-client-content-negotiation-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.plugins.contentnegotiation.ContentNegotiation$Plugin$install$2.invoke(ContentNegotiation.kt) ~[ktor-client-content-negotiation-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.plugins.contentnegotiation.ContentNegotiation$Plugin$install$2.invoke(ContentNegotiation.kt) ~[ktor-client-content-negotiation-jvm-2.3.2.jar:2.3.2]
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:120) ~[ktor-utils-jvm-2.3.2.jar:2.3.2]
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:78) ~[ktor-utils-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.HttpClient$4.invokeSuspend(HttpClient.kt:177) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.HttpClient$4.invoke(HttpClient.kt) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.HttpClient$4.invoke(HttpClient.kt) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2]
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:120) ~[ktor-utils-jvm-2.3.2.jar:2.3.2]
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:78) ~[ktor-utils-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.plugins.logging.Logging$setupResponseLogging$2.invokeSuspend(Logging.kt:201) ~[ktor-client-logging-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.plugins.logging.Logging$setupResponseLogging$2.invoke(Logging.kt) ~[ktor-client-logging-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.plugins.logging.Logging$setupResponseLogging$2.invoke(Logging.kt) ~[ktor-client-logging-jvm-2.3.2.jar:2.3.2]
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:120) ~[ktor-utils-jvm-2.3.2.jar:2.3.2]
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:78) ~[ktor-utils-jvm-2.3.2.jar:2.3.2]
at io.ktor.util.pipeline.SuspendFunctionGun.proceedWith(SuspendFunctionGun.kt:88) ~[ktor-utils-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.plugins.HttpCallValidator$Companion$install$2.invokeSuspend(HttpCallValidator.kt:142) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.plugins.HttpCallValidator$Companion$install$2.invoke(HttpCallValidator.kt) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.plugins.HttpCallValidator$Companion$install$2.invoke(HttpCallValidator.kt) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2]
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:120) ~[ktor-utils-jvm-2.3.2.jar:2.3.2]
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:78) ~[ktor-utils-jvm-2.3.2.jar:2.3.2]
at io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:98) ~[ktor-utils-jvm-2.3.2.jar:2.3.2]
at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77) ~[ktor-utils-jvm-2.3.2.jar:2.3.2]
at io.ktor.client.call.HttpClientCall.bodyNullable(HttpClientCall.kt:88) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2]
代码:
val config = OpenAIConfig(
token = "sk-asdfgweradfgadf",
timeout = Timeout(connect = 60.seconds, socket = 60.seconds),
host = OpenAIHost(url)
)
val openAI = OpenAI(config)
val chatCompletionRequest = ChatCompletionRequest(
maxTokens = 2000,
model = "chatglm_pro",
messages = "你好",
temperature = 0.0,
)
val completion: ChatCompletion = openAI.chatCompletion(chatCompletionRequest)
尝试连接 智谱 ChatGLM时报错 报错信息: io.ktor.serialization.JsonConvertException: Illegal input: Fields [code, param] are required for type with serial name 'com.aallam.openai.api.exception.OpenAIErrorDetails', but they were missing at path: $.error at io.ktor.serialization.kotlinx.KotlinxSerializationConverter.deserialize(KotlinxSerializationConverter.kt:90) ~[ktor-serialization-kotlinx-jvm-2.3.2.jar:2.3.2] at io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1$2.emit(Emitters.kt:224) ~[ktor-serialization-jvm-2.3.2.jar:2.3.2] at kotlinx.coroutines.flow.FlowKtBuildersKt$asFlow$$inlined$unsafeFlow$3.collect(SafeCollector.common.kt:116) ~[kotlinx-coroutines-core-jvm-1.7.3.jar:na] at io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1.collect(SafeCollector.common.kt:113) ~[ktor-serialization-jvm-2.3.2.jar:2.3.2] at kotlinx.coroutines.flow.FlowKtReduceKt.firstOrNull(Reduce.kt:243) ~[kotlinx-coroutines-core-jvm-1.7.3.jar:na] at kotlinx.coroutines.flow.FlowKt.firstOrNull(Unknown Source) ~[kotlinx-coroutines-core-jvm-1.7.3.jar:na] at io.ktor.serialization.ContentConverterKt.deserialize(ContentConverter.kt:123) ~[ktor-serialization-jvm-2.3.2.jar:2.3.2] at io.ktor.client.plugins.contentnegotiation.ContentNegotiation.convertResponse$ktor_client_content_negotiation(ContentNegotiation.kt:230) ~[ktor-client-content-negotiation-jvm-2.3.2.jar:2.3.2] at io.ktor.client.plugins.contentnegotiation.ContentNegotiation$Plugin$install$2.invokeSuspend(ContentNegotiation.kt:262) ~[ktor-client-content-negotiation-jvm-2.3.2.jar:2.3.2] at io.ktor.client.plugins.contentnegotiation.ContentNegotiation$Plugin$install$2.invoke(ContentNegotiation.kt) ~[ktor-client-content-negotiation-jvm-2.3.2.jar:2.3.2] at io.ktor.client.plugins.contentnegotiation.ContentNegotiation$Plugin$install$2.invoke(ContentNegotiation.kt) ~[ktor-client-content-negotiation-jvm-2.3.2.jar:2.3.2] at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:120) ~[ktor-utils-jvm-2.3.2.jar:2.3.2] at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:78) ~[ktor-utils-jvm-2.3.2.jar:2.3.2] at io.ktor.client.HttpClient$4.invokeSuspend(HttpClient.kt:177) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2] at io.ktor.client.HttpClient$4.invoke(HttpClient.kt) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2] at io.ktor.client.HttpClient$4.invoke(HttpClient.kt) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2] at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:120) ~[ktor-utils-jvm-2.3.2.jar:2.3.2] at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:78) ~[ktor-utils-jvm-2.3.2.jar:2.3.2] at io.ktor.client.plugins.logging.Logging$setupResponseLogging$2.invokeSuspend(Logging.kt:201) ~[ktor-client-logging-jvm-2.3.2.jar:2.3.2] at io.ktor.client.plugins.logging.Logging$setupResponseLogging$2.invoke(Logging.kt) ~[ktor-client-logging-jvm-2.3.2.jar:2.3.2] at io.ktor.client.plugins.logging.Logging$setupResponseLogging$2.invoke(Logging.kt) ~[ktor-client-logging-jvm-2.3.2.jar:2.3.2] at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:120) ~[ktor-utils-jvm-2.3.2.jar:2.3.2] at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:78) ~[ktor-utils-jvm-2.3.2.jar:2.3.2] at io.ktor.util.pipeline.SuspendFunctionGun.proceedWith(SuspendFunctionGun.kt:88) ~[ktor-utils-jvm-2.3.2.jar:2.3.2] at io.ktor.client.plugins.HttpCallValidator$Companion$install$2.invokeSuspend(HttpCallValidator.kt:142) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2] at io.ktor.client.plugins.HttpCallValidator$Companion$install$2.invoke(HttpCallValidator.kt) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2] at io.ktor.client.plugins.HttpCallValidator$Companion$install$2.invoke(HttpCallValidator.kt) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2] at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:120) ~[ktor-utils-jvm-2.3.2.jar:2.3.2] at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:78) ~[ktor-utils-jvm-2.3.2.jar:2.3.2] at io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:98) ~[ktor-utils-jvm-2.3.2.jar:2.3.2] at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77) ~[ktor-utils-jvm-2.3.2.jar:2.3.2] at io.ktor.client.call.HttpClientCall.bodyNullable(HttpClientCall.kt:88) ~[ktor-client-core-jvm-2.3.2.jar:2.3.2]
代码: