Skip to content

Store OpenAI Responses streaming response in events format understood by UI - #1479

Merged
alexmojaki merged 2 commits into
mainfrom
alex/openai-streaming-response-events
Oct 9, 2025
Merged

alexmojaki merged 2 commits into
mainfrom
alex/openai-streaming-response-events

Conversation

@alexmojaki

Copy link
Copy Markdown
Contributor

No description provided.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 9, 2025 •

Copy link
Copy Markdown

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0ed904b
Status: ✅  Deploy successful!
Preview URL: https://baa61c30.logfire-docs.pages.dev
Branch Preview URL: https://alex-openai-streaming-respon.logfire-docs.pages.dev

View logs

@alexmojaki
alexmojaki requested a review from Copilot October 9, 2025 10:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR standardizes the OpenAI Responses API streaming response format to use an events structure that is understood by the UI, moving away from storing raw response data to a more consistent event-based format.

  • Replaces raw response_data with structured events for OpenAI streaming responses
  • Adds a new get_attributes method to StreamState for customizing logged attributes
  • Updates test expectations to reflect the new event-based format

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
logfire/_internal/integrations/llm_providers/types.py Adds get_attributes method to StreamState base class
logfire/_internal/integrations/llm_providers/openai.py Implements event-based response format and custom attribute handling
logfire/_internal/integrations/llm_providers/llm_provider.py Updates streaming response logging to use new attribute method
tests/otel_integrations/test_openai.py Updates test expectations for new event-based format
tests/otel_integrations/test_anthropic.py Reorders JSON schema properties (likely due to dictionary ordering changes)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@alexmojaki
alexmojaki merged commit 4c1abdf into main Oct 9, 2025
@alexmojaki
alexmojaki deleted the alex/openai-streaming-response-events branch October 9, 2025 10:36
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.

2 participants