feat(groqcloud): add audio transcription and translation actions - #256
Conversation
Summary by CodeRabbit
WalkthroughGroqCloud now exposes audio transcription and translation actions. The actions validate audio sources, supported models, transcript options, timestamps, and structured outputs. Executors accept public URLs or base64 audio, build multipart requests, enforce size and source constraints, and preserve JSON handling for existing requests. Tests cover request construction, validation failures, timestamp encoding, model differences, and filename requirements. Sequence Diagram(s)sequenceDiagram
participant Client
participant GroqCloudExecutor
participant GroqCloudAPI
Client->>GroqCloudExecutor: submit transcription or translation input
GroqCloudExecutor->>GroqCloudExecutor: validate audio and build multipart form
GroqCloudExecutor->>GroqCloudAPI: POST audio request
GroqCloudAPI-->>GroqCloudExecutor: return transcript payload
GroqCloudExecutor-->>Client: return transcript payload
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/providers/groqcloud/actions.ts`:
- Around line 135-149: Update audioFileSchema’s anyOf validation to enforce
exclusive audio sources: require url while rejecting content_base64 in the URL
branch, and require content_base64 plus name while rejecting url in the
inline-content branch. Keep the schema aligned with the executor’s existing
mutual-exclusion behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: dabc2e75-06fe-4230-8e90-2996c0ebf1f9
📒 Files selected for processing (3)
src/providers/groqcloud/actions.tssrc/providers/groqcloud/executors.test.tssrc/providers/groqcloud/executors.ts
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/providers/groqcloud/executors.ts (1)
220-226: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick winCheck
file.content_base64length before decoding.
base64Bytesdecodes withBuffer.from(normalized, "base64")before validation, and the 25 MiB limit is only applied after decoding completes. Add an encoded-length check that includes the helper’s normalization and padding rules beforebase64Bytes, then keep the decoded-byte check for exact enforcement.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/providers/groqcloud/executors.ts` around lines 220 - 226, Update the attachment validation flow around base64Bytes to validate the normalized, padded file.content_base64 encoded length against the 25 MiB limit before decoding, matching base64Bytes’s normalization and padding rules. Preserve the existing base64Bytes call and decoded bytes.byteLength check so the limit remains exactly enforced after decoding.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/providers/groqcloud/executors.ts`:
- Around line 220-226: Update the attachment validation flow around base64Bytes
to validate the normalized, padded file.content_base64 encoded length against
the 25 MiB limit before decoding, matching base64Bytes’s normalization and
padding rules. Preserve the existing base64Bytes call and decoded
bytes.byteLength check so the limit remains exactly enforced after decoding.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 94bc44af-9914-4c72-9856-f3828a1cffc5
📒 Files selected for processing (3)
src/providers/groqcloud/actions.tssrc/providers/groqcloud/executors.test.tssrc/providers/groqcloud/executors.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/providers/groqcloud/actions.ts
The
groqcloudprovider currently exposes chat completions and model listing only, so Groq's speech-to-text endpoints are unreachable — the provider has no proxy fallback either.create_audio_transcriptionPOST /audio/transcriptionscreate_audio_translationPOST /audio/translationsAudio is supplied inline as base64, or as a public URL that GroqCloud fetches itself through its native
urlfield. Caller URLs are checked withassertPublicHttpUrlbefore being forwarded. The size cap applies to inline uploads; GroqCloud enforces its own limit on URLs it fetches.Translation is restricted to
whisper-large-v3. Requestingwhisper-large-v3-turbothere returnsThe model 'whisper-large-v3-turbo' does not support 'translate', so the restriction is in the schema rather than surfacing as a runtime error.Exercised against the live API with a real key: inline base64 upload, forwarded URL,
verbose_jsonwith word-leveltimestamp_granularities[],language/prompt/temperaturepassthrough, and both endpoints.