Skip to content

Assistant (v2) streaming returns an empty stream in v0.11.2 #103

Closed
@joostbr

Description

@joostbr

tag 0.11.2:

When using the Assistant API (v2) in streaming mode, it seems to always return an empty stream.

Digging into the code revealed this :

com.openai.core.handlers.SseHandler.kt line 42:
if (message.event == null) {
...
yield message;
...
}

Because of this test the SSE streams related to streaming Assistant (v2) runs return nothing because every entry in the stream is decorated by an 'event' tag.
It does work for 'completions' however since they are plain 'data' objects without an event-tag attached to it.

Not sure why 'event' needs to be null to return (yield) the message in the stream

Example code snippet below, it never prints the "Got something" line, for whatever message content that has been passed to the thread.

// streaming
        try (StreamResponse<AssistantStreamEvent> responseStream = client.beta().threads().runs().createStreaming(BetaThreadRunCreateParams.builder()
                .assistantId(assistant.id())
                .threadId(thread.id())
                .build())) {

            responseStream.stream().forEach(x->System.out.println("Got something "+x));

        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions