Skip to content

Fix Deserialisation of AssistantStreamEventType.THREAD_MESSAGE_DELTA #426

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

av-runner
Copy link

Q A
Bug fix? yes
New feature? no
BC breaks? no
Related Issue Fix #421

Describe your change

Make the content in the Message Delta Data a list and add needed data models for the possible objects within the list.

What problem is this fixing?

The content in the MessageDeltaData data class, within the Assistant Stream Event was a MessageContent, however the response from OpenAI is a list that might contain 4 different types of objects. I have added the missing data models.

@osmanconger
Copy link

When can we expect this to be merged @aallam?

Copy link

@tashilapathum tashilapathum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this fix, deserialization would fail for this code:

AssistantStreamEventType.THREAD_MESSAGE_DELTA -> {
    val messageDelta = assistantStreamEvent.getData<MessageDelta>()
    val content = messageDelta.delta.content
}

with the error Expected JsonObject, but had JsonArray as the serialized body of com.aallam.openai.api.message.MessageContent at element: $.delta.content.

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 this pull request may close these issues.

Deserialisation of AssistantStreamEventType.THREAD_MESSAGE_DELTA fails
3 participants