feat(providers): add TokenRouter provider integration and tests (v1.2… - #19
Conversation
📝 WalkthroughWalkthroughTokenRouter is added as an OpenAI-compatible provider. The change adds configuration, catalog registration, request-profile behavior, admin metadata, documentation, version ChangesTokenRouter integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Settings
participant PROVIDER_CATALOG
participant OpenAIChatProvider
participant TokenRouterAPI
Settings->>PROVIDER_CATALOG: Resolve tokenrouter settings and endpoint
PROVIDER_CATALOG->>OpenAIChatProvider: Create configured provider
OpenAIChatProvider->>OpenAIChatProvider: Apply tokenrouter profile and request mapping
OpenAIChatProvider->>TokenRouterAPI: Send OpenAI-compatible request
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/codefa/providers/openai_chat/profiles.py (1)
347-360: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winVerify TokenRouter’s request and response contract.
This profile emits
reasoning_effortvalues from_LOW_MEDIUM_HIGH, uses"none"to disable reasoning, appliesANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS, and selectsReasoningReplayMode.REASONING_CONTENT. The supplied tests only inspect locally built request dictionaries. They do not prove that TokenRouter accepts these fields or returns the expected reasoning field for the selected model. Confirm the live contract and add a recorded request/response fixture if no existing coverage provides this guarantee. TokenRouter publicly describes the gateway as OpenAI-compatible, but that does not establish these provider-specific fields. (tokenrouter.com)🤖 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/codefa/providers/openai_chat/profiles.py` around lines 347 - 360, Verify the TokenRouter contract for the profile’s reasoning_effort values, disabled value, max-token default, and REASONING_CONTENT response mapping. Update the "tokenrouter" OpenAIChatProfile only if the live API contract differs, and add a recorded request/response fixture covering the selected model when existing tests do not validate these fields end to end.
🤖 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.
Nitpick comments:
In `@src/codefa/providers/openai_chat/profiles.py`:
- Around line 347-360: Verify the TokenRouter contract for the profile’s
reasoning_effort values, disabled value, max-token default, and
REASONING_CONTENT response mapping. Update the "tokenrouter" OpenAIChatProfile
only if the live API contract differs, and add a recorded request/response
fixture covering the selected model when existing tests do not validate these
fields end to end.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a1f34ece-a391-4e19-8c69-3506758391e9
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (10)
.env.exampleREADME.mdpyproject.tomlsrc/codefa/api/admin_static/admin.jssrc/codefa/config/provider_catalog.pysrc/codefa/config/settings.pysrc/codefa/providers/openai_chat/profiles.pytests/contracts/test_provider_catalog_order.pytests/providers/test_provider_runtime.pytests/providers/test_tokenrouter.py
….51)
Summary by CodeRabbit
New Features
Documentation
Chores