Skip to content

feat: ship chats.stream_chat() with SSE support#12

Closed
rodnnnney wants to merge 1 commit into
mainfrom
rod/python-stream-chat-sse
Closed

feat: ship chats.stream_chat() with SSE support#12
rodnnnney wants to merge 1 commit into
mainfrom
rod/python-stream-chat-sse

Conversation

@rodnnnney

Copy link
Copy Markdown
Collaborator

Summary

stream_chat had the same gap as the TypeScript SDK: the overlay mapped it, the docs documented it, but Speakeasy silently skipped the operation during codegen — the registry spec labels the stream response application/x-ndjson, and JSONL/NDJSON stream generation (jsonlResponses) is gated to Speakeasy's enterprise tier. SSE generation works on the current tier.

The endpoint is served by demo2's platform v2 handler (TextQLLabs/demo2#13014), which emits Server-Sent Events of {result: Cell} / {error: Status} envelopes.

Changes

  • Overlay: maps the operation to chats.streamChat (name-mapping mirrored from the TS SDK) and normalizes the stream response to the SSE envelope contract — robust against any current registry snapshot; becomes a harmless no-op once demo2 publishes the SSE spec at the source.
  • Regenerated SDK: ships chats.stream_chat() / stream_chat_async() returning EventStream[StreamChatEvent] with typed data.result: Cell / data.error: Status.

Usage

res = textql.chats.stream_chat(chat_id=chat_id, body={"latest_complete_cell_id": cell_id})
with res as event_stream:
    for event in event_stream:
        if event.data.result:
            ...  # next cell

Cross-repo context

Merge order: this can merge independently (the overlay normalizes the old spec), but the endpoint only speaks SSE once the demo2 PR deploys — until then the generated method targets the new contract.

The registry spec labels the stream endpoint application/x-ndjson, which
Speakeasy skips during codegen (jsonlResponses is enterprise-tier) - the
method was documented but never generated. The endpoint is served by demo2's
platform v2 SSE handler emitting {result: Cell} / {error: Status} envelopes.

Map the operation to chats.streamChat and normalize the response to the SSE
envelope contract; regenerate. stream_chat() / stream_chat_async() now return
EventStream[StreamChatEvent]. The overlay normalization becomes a harmless
no-op once demo2 (TextQLLabs/demo2#13014) publishes the SSE spec at the
source.
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.

1 participant