-
Notifications
You must be signed in to change notification settings - Fork 1
Avoid redundant canonical chat request cloning #659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughRefactors TranslationService.to_domain_request to use explicit type-guard branches for canonical and chat requests, preserving behavior. Adds a unit test asserting that canonical requests are returned by identity. No public API changes or other logic modifications. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant TS as TranslationService
Caller->>TS: to_domain_request(request, provider)
alt request is Canonical
note right of TS: Return same instance (identity)
TS-->>Caller: CanonicalChatRequest (same object)
else request is ChatRequest
note right of TS: Convert to canonical
TS-->>Caller: CanonicalChatRequest (new object)
else other/unchanged paths
note right of TS: Existing handling unchanged
TS-->>Caller: Result per existing logic
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (2)**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧬 Code graph analysis (1)tests/unit/core/services/test_translation_service.py (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (2)
Comment |
|
This optimization is already present in the current dev branch at lines 136-137 in |
Summary
TranslationService.to_domain_requestinstead of cloning themTesting
python -m pytest -o addopts= tests/unit/core/services/test_translation_service.py::test_to_domain_request_returns_same_instance_for_canonical_requestpython -m pytest -o addopts=(fails: missing optional dev dependencies such as pytest-asyncio, respx, pytest-httpx)https://chatgpt.com/codex/tasks/task_e_68ec27b5f5f08333be56cce2d6aca430
Summary by CodeRabbit
No user-facing changes; existing translation behavior remains the same.