Skip to content

feat(openai): capture audio transcript deltas in streaming chat completions - #1831

Open
arnab812 wants to merge 2 commits into
langfuse:mainfrom
arnab812:feature/capture-audio-transcripts
Open

feat(openai): capture audio transcript deltas in streaming chat completions#1831
arnab812 wants to merge 2 commits into
langfuse:mainfrom
arnab812:feature/capture-audio-transcripts

Conversation

@arnab812

@arnab812 arnab812 commented Aug 23, 2026

Copy link
Copy Markdown
  • Update _extract_streamed_openai_response to inspect delta.audio for streaming chunks
  • Extract and concatenate transcript tokens into completion["content"]
  • Ensure text output is captured in Langfuse dashboard traces when using audio modalities

What does this PR do?

When streaming chat completions with audio modality enabled (modalities=["text", "audio"]), OpenAI returns spoken transcript chunks inside chunk.choices[0].delta.audio["transcript"] instead of chunk.choices[0].delta.content. Currently, this leaves the extracted completion content empty in Langfuse traces. This PR updates _extract_streamed_openai_response() to capture and concatenate transcript deltas into completion["content"].

Fixes #

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • Documentation update
  • Tooling, CI, or repo maintenance

Verification

List the main commands you ran: pytest tests/unit/test_openai.py

Checklist

  • I self-reviewed the diff using code_review.md.
  • I added or updated tests for behavior changes.
  • I updated docs, examples, or .env.template if needed.
  • I did not hand-edit generated files; if generated files changed, I used the upstream regeneration path.
  • I did not commit secrets or credentials.

Greptile Summary

Adds support for collecting transcript fragments from streaming OpenAI audio deltas so Langfuse observations retain the spoken response text.

  • Reads delta.audio.transcript from dictionary and object-backed audio deltas.
  • Concatenates transcript fragments into the existing completion content accumulator.
  • Does not add automated coverage for the new streaming response shape.

Confidence Score: 4/5

The PR appears safe to merge, with the non-blocking concern that the new streamed audio-transcript path lacks regression coverage.

The extraction change is narrowly scoped and no concrete runtime defect was established, but dictionary/object handling and multi-chunk transcript accumulation are not exercised by existing tests.

Files Needing Attention: langfuse/openai.py

Prompt To Fix All With AI
### Issue 1
langfuse/openai.py:804-805
**Streaming transcript path untested**

The new object/dictionary normalization and multi-chunk transcript concatenation have no automated coverage, so regressions can silently restore empty or malformed Langfuse trace output.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "feat(openai): capture audio transcript d..." | Re-trigger Greptile

Context used:

…etions

- Update _extract_streamed_openai_response to inspect delta.audio for streaming chunks
- Extract and concatenate transcript tokens into completion["content"]
- Ensure text output is captured in Langfuse dashboard traces when using audio modalities

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@CLAassistant

CLAassistant commented Aug 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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