Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.4.0 breaks function calling with stream (chatCompletions) #231

Closed
paulotaylor opened this issue Aug 28, 2023 · 0 comments · Fixed by #232
Closed

Version 3.4.0 breaks function calling with stream (chatCompletions) #231

paulotaylor opened this issue Aug 28, 2023 · 0 comments · Fixed by #232

Comments

@paulotaylor
Copy link

Description

Version 3.4.0 breaks function calling with stream (chatCompletions)
Version 3.3.2 works fine

Steps to Reproduce

com.aallam.openai.api.exception.OpenAIHttpException: Field 'name' is required for type with serial name 'com.aallam.openai.api.chat.FunctionCall', but it was missing at path: $.choices[0].delta.function_call
at com.aallam.openai.client.internal.http.HttpTransport.handleException(HttpTransport.kt:52)
at com.aallam.openai.client.internal.http.HttpTransport.perform(HttpTransport.kt:34)
at com.aallam.openai.client.internal.http.HttpTransport$perform$2.invokeSuspend(Unknown Source:15)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@3dc0a39, Dispatchers.IO]
Caused by: kotlinx.serialization.MissingFieldException: Field 'name' is required for type with serial name 'com.aallam.openai.api.chat.FunctionCall', but it was missing at path: $.choices[0].delta.function_call
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:93)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
at kotlinx.serialization.encoding.AbstractDecoder.decodeNullableSerializableElement(AbstractDecoder.kt:79)
at com.aallam.openai.api.chat.ChatDelta$$serializer.deserialize(ChatDelta.kt:10)
at com.aallam.openai.api.chat.ChatDelta$$serializer.deserialize(ChatDelta.kt:10)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:70)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableElement(StreamingJsonDecoder.kt:165)
at com.aallam.openai.api.chat.ChatChunk$$serializer.deserialize(ChatChunk.kt:13)
at com.aallam.openai.api.chat.ChatChunk$$serializer.deserialize(ChatChunk.kt:13)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:70)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableElement(StreamingJsonDecoder.kt:165)
at kotlinx.serialization.encoding.CompositeDecoder$DefaultImpls.decodeSerializableElement$default(Decoding.kt:533)
at kotlinx.serialization.internal.CollectionLikeSerializer.readElement(CollectionSerializers.kt:80)
at kotlinx.serialization.internal.AbstractCollectionSerializer.readElement$default(CollectionSerializers.kt:51)
at kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:36)
at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:70)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
2023-08-29 00:32:10.979 31910-32341 AndroidRuntime
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableElement(StreamingJsonDecoder.kt:165)
at com.aallam.openai.api.chat.ChatCompletionChunk$$serializer.deserialize(ChatCompletionChunk.kt:14)
at com.aallam.openai.api.chat.ChatCompletionChunk$$serializer.deserialize(ChatCompletionChunk.kt:14)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:70)
at kotlinx.serialization.json.Json.decodeFromString(Json.kt:107)
at com.aallam.openai.client.internal.api.ChatApi$chatCompletions$1$1.invokeSuspend(ChatApi.kt:56)
at com.aallam.openai.client.internal.api.ChatApi$chatCompletions$1$1.invoke(Unknown Source:8)
at com.aallam.openai.client.internal.api.ChatApi$chatCompletions$1$1.invoke(Unknown Source:4)
at io.ktor.client.statement.HttpStatement.execute(HttpStatement.kt:50)
at io.ktor.client.statement.HttpStatement$execute$1.invokeSuspend(Unknown Source:15)
... 8 more
Caused by: kotlinx.serialization.MissingFieldException: Field 'name' is required for type with serial name 'com.aallam.openai.api.chat.FunctionCall', but it was missing
at kotlinx.serialization.internal.PluginExceptionsKt.throwMissingFieldException(PluginExceptions.kt:20)
at com.aallam.openai.api.chat.FunctionCall.(FunctionCall.kt:11)
at com.aallam.openai.api.chat.FunctionCall$$serializer.deserialize(FunctionCall.kt:11)
at com.aallam.openai.api.chat.FunctionCall$$serializer.deserialize(FunctionCall.kt:11)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:70)
... 40 more

Environment

  • openai-kotlin version: 3.4.0
  • Kotlin version: 1.9.10
  • OS: Android 13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant