feat(sdk): allow transcribe() without api_key for whisper and parakeet - #13087
feat(sdk): allow transcribe() without api_key for whisper and parakeet#13087Aj2280 wants to merge 1 commit into
Conversation
In `sdks/python/omi/transcribe.py`, `transcribe()` required a positional `api_key` argument even when using engines (like Whisper and Parakeet) that do not use or require an API key. Make `api_key: Optional[str] = None` and enforce key validation only when Deepgram is selected. Fixes BasedHardware#13042
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 5/5
- In
sdks/python/tests/test_transcribe_wrapper.py,test_whisper_does_not_require_api_keyderives the expected runner from the mocked call itself, so an incorrect value forwarded bytranscribe()would still pass the test; define the expected runner independently and assert against it.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="sdks/python/tests/test_transcribe_wrapper.py">
<violation number="1" location="sdks/python/tests/test_transcribe_wrapper.py:57">
P3: The runner assertion in `test_whisper_does_not_require_api_key` is tautological: it builds the expected value from `mock_create.call_args[1]["runner"]`, so it passes no matter what `transcribe()` forwards. Capture the runner in a variable and assert it is forwarded unchanged so the test actually detects a regression.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| await transcribe(queue, engine="whisper", runner=lambda b: "hello") | ||
| mock_create.assert_called_once_with( | ||
| SttEngine.WHISPER.value, | ||
| runner=mock_create.call_args[1]["runner"] |
There was a problem hiding this comment.
P3: The runner assertion in test_whisper_does_not_require_api_key is tautological: it builds the expected value from mock_create.call_args[1]["runner"], so it passes no matter what transcribe() forwards. Capture the runner in a variable and assert it is forwarded unchanged so the test actually detects a regression.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At sdks/python/tests/test_transcribe_wrapper.py, line 57:
<comment>The runner assertion in `test_whisper_does_not_require_api_key` is tautological: it builds the expected value from `mock_create.call_args[1]["runner"]`, so it passes no matter what `transcribe()` forwards. Capture the runner in a variable and assert it is forwarded unchanged so the test actually detects a regression.</comment>
<file context>
@@ -0,0 +1,91 @@
+ await transcribe(queue, engine="whisper", runner=lambda b: "hello")
+ mock_create.assert_called_once_with(
+ SttEngine.WHISPER.value,
+ runner=mock_create.call_args[1]["runner"]
+ )
+
</file context>
|
Thanks @Aj2280 — this is a tidy, well-scoped fix for #13042, and it's verified end to end. sdks/python/omi/transcribe.py
sdks/python/tests/test_transcribe_wrapper.py
No secrets, dependency, workflow, or network-surface changes; nothing security-sensitive. This is automated AI-maintainer feedback on behalf of the Omi maintainers. by AI on behalf of David — merge call and the callable-binding API choice left to the maintainers; no urgent action needed. |
kodjima33
left a comment
There was a problem hiding this comment.
feat(sdk): makes api_key optional for whisper/parakeet engines — titled and shaped as a feature/API enhancement, not a bug fix. Approve only per confidence gate.
Summary
In
sdks/python/omi/transcribe.py, the public wrapper functiontranscribe()previously declaredapi_key: stras a required positional argument, even though the Whisper and Parakeet engines do not accept or require an API key. This forced callers using Whisper or Parakeet to provide a dummy API key string, e.g.await transcribe(queue, "dummy", engine="whisper").This PR makes
api_keyoptional (api_key: Optional[str] = None) intranscribe()and validates that a key is provided only when the Deepgram engine is active. Existing calls passing Deepgram keys positionally or by keyword continue to work unchanged.Fixes #13042
Changes
sdks/python/omi/transcribe.py:api_key: Optional[str] = None.on_transcriptwhen no API key is needed.ValueError("Deepgram api_key is required")only whenengine == SttEngine.DEEPGRAM.value.sdks/python/tests/test_transcribe_wrapper.py:on_transcript.Verification
PYTHONPATH=sdks/python sdks/python/venv/bin/pytest sdks/python/tests/test_transcribe_wrapper.py -v: 6/6 passed.PYTHONPATH=sdks/python sdks/python/venv/bin/pytest sdks/python/tests/: 13/13 passed.scripts/pr-preflight.Failure-Class: none