Skip to content

fix(py/openai): don't send a blank transcription prompt - #136

Merged
cabljac merged 2 commits into
mainfrom
fix/py-openai-stt-blank-prompt
Nov 17, 2026
Merged

cabljac merged 2 commits into
mainfrom
fix/py-openai-stt-blank-prompt

Conversation

@cabljac

@cabljac cabljac commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What's new

  • The OpenAI transcription model no longer sends a whitespace-only prompt, whether it comes from config.prompt or from message text. Non-blank prompts go out unchanged.
  • A blank config.prompt now falls back to the message text, as None already did. Before, the blank was sent.
  • _find_text is unchanged, so TTS input is not affected.
messages: [{"text": " "}, {"media": {...audio...}}]
POST /audio/transcriptions (multipart form fields)
before: model=gpt-4o-transcribe-diarize, file=..., prompt=" "
after:  model=gpt-4o-transcribe-diarize, file=...

Why

Transcribing audio from the Dev UI model playground with gpt-4o-transcribe-diarize fails every time:

400 - {'error': {'message': 'Prompt is not supported for diarization models', 'type': 'invalid_request_error', 'param': 'prompt', 'code': 'invalid_value'}}

The Dev UI sends a " " text part next to attached audio, and the plugin forwarded it as prompt. With gpt-4o-transcribe the blank prompt also made the model drop the second sentence in 3/3 runs.

Tests

  • packages/genkit-openai/tests/openai_generate_config_test.py: test_generate_openai_stt_omits_blank_prompt pins no prompt field for a " " text part, for config={'prompt': ' '}, and for whisper-1 with translate: True (/audio/translations). A real message prompt still goes out with a blank config prompt. Fails before the fix.
  • pytest packages/genkit-openai: 497 passed.
  • ruff check, ruff format, ty, pyrefly, pyright: all pass.
  • Live: gpt-4o-transcribe-diarize and gpt-4o-transcribe with [" ", audio] now return the full transcript.

Not in this PR

  • Dev UI. The Dev UI still sends the blank text part (genkit tools).
  • extra.prompt. A blank prompt passed via config={'extra': {'prompt': ' '}} is still forwarded, since extra is unchecked by design.
  • Later text parts. _find_text returns the first non-empty text part, so [" ", "real prompt", audio] sends no prompt (main sent " ").
  • feat(py/openai): refresh the OpenAI model catalog #128. Linked from feat(py/openai): refresh the OpenAI model catalog #128 (OpenAI catalog refresh), which keeps gpt-4o-transcribe-diarize listed as a transcription model.

The Dev UI sends a " " text part next to attached audio. The STT model
forwarded it as `prompt`, which diarization models reject with a 400 and
which made gpt-4o-transcribe drop speech. Skip whitespace-only prompts
from config or message text.
@cabljac
cabljac marked this pull request as ready for review November 17, 2026 15:48
@cabljac
cabljac merged commit 4edab58 into main Nov 17, 2026
20 of 21 checks passed
@cabljac
cabljac deleted the fix/py-openai-stt-blank-prompt branch November 17, 2026 16:09
@cabljac cabljac self-assigned this Nov 26, 2026
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