LLMOutput Fix: generate presigned URL for audio output in LLM call response#865
Conversation
📝 WalkthroughWalkthroughThe LLM call status endpoint now post-processes successful responses containing audio outputs. When an output has type ChangesAudio Output Signing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@backend/app/api/routes/llm.py`:
- Around line 154-172: The handler is mutating llm_call.content in place via the
output_payload alias, which can persist an expiring signed URL back into the DB;
instead, make a shallow/deep copy of llm_call.content into a new local variable
(e.g., output_payload_copy) before inspecting/modifying it, update
output_payload_copy["content"]["value"] and ["content"]["format"] when calling
get_cloud_storage(session, project_id) and storage.get_signed_url(...), and
return/send the copied payload rather than writing back to llm_call.content;
apply the same non-mutating copy approach for the similar code at the other
occurrence around line 179.
- Around line 168-170: The log message uses the wrong function-prefix; update
the logger.warning call that currently prefixes "[get_llm_call]" to use the
correct function name "[get_llm_call_status]" (and any similar log lines in
get_llm_call_status) so all log messages are prefixed with the actual function
name per guidelines; locate the logger.warning in get_llm_call_status and change
the square-bracket prefix accordingly while keeping the rest of the message and
error variable (e) intact.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e5a91970-52b8-4c62-8b5a-be1a4a93edbe
📒 Files selected for processing (1)
backend/app/api/routes/llm.py
|
@vprashrex test cases failing, please check. |
ISSUE: #866
Summary
GET
/llm/call/{job_id}was broken for all audio (TTS) jobs. When audio is uploaded to S3 during job execution, jobs.py stores format: "uri" in the DB as an internal marker for "this is an S3 path, generate a presigned URL before serving." The AudioContent pydantic model (used in LLMResponse) only accepts "base64" or "url", so deserialization always failed with a validation error.Fix:
llm_call.content is dict[str, Any] (raw JSONB from DB). Pydantic hasn't parsed it yet, and parsing is exactly what fails whenformat == "uri". The fix must happen on the raw dict before the model is constructed.Checklist
Before submitting a pull request, please ensure that you mark these task.
fastapi run --reload app/main.pyordocker compose upin the repository root and test.Notes
Please add here if any other information is required for the reviewer.