Custom Providers (YAML-based provider configuration)#117
Conversation
- New `reloaded-code-provider-config` crate: parse provider/model definitions from YAML, merge multiple sources, validate fields, convert to catalog types - Add `Modality::from_label()` for label-to-flag parsing - Allow OpenAI-compatible providers without credential env vars (keyless endpoints like local Ollama) - Add custom providers guide, example config, and docs updates
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR introduces a new Possibly related PRs:
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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: 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 `@src/reloaded-code-provider-config/src/loader.rs`:
- Around line 156-160: The validation currently checks config.api_url before
validating config.api_type, which can surface MissingField(api_url) and hide
UnrecognizedApiType; change the order so you first validate api_type by calling
api_type_from_str(config.api_type.as_deref().unwrap_or(DEFAULT_API_TYPE)) and
handle/return UnrecognizedApiType if invalid, and only after a valid
ProviderType is known enforce that config.api_url.is_some() for
non-ProviderType::Ollama cases; apply the same reorder/fix for the other
occurrence covering the block around the api_url check at the later location
(the 194–202 block).
- Around line 274-285: The enumerate index is cast to u16 without checking, so
ProviderIdx::new(idx as u16) will silently truncate indices >65535 and corrupt
the intermediate ProviderModelSource entries; fix by validating idx before
casting (e.g., ensure idx <= u16::MAX and return an error if not) or use a
try_from/checked conversion when constructing ProviderIdx in the loop that
creates ProviderSource/ProviderIdx, and apply the same guard at the other
occurrences noted (src/reloaded-code-core/src/models/catalog/mod.rs:326 and
mod.rs:481) so no truncated ProviderIdx values are produced prior to
ModelCatalog::build().
🪄 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
Run ID: 1fcb2d37-18bc-4f27-a007-93c88dbf309a
⛔ Files ignored due to path filters (1)
src/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (18)
PR.mddocs/mkdocs.ymldocs/src/examples.mddocs/src/guides/custom-providers.mddocs/src/index.mddocs/src/models-catalog.mdsrc/Cargo.tomlsrc/reloaded-code-core/src/models/catalog/public/modality.rssrc/reloaded-code-provider-config/Cargo.tomlsrc/reloaded-code-provider-config/examples/config-loader.rssrc/reloaded-code-provider-config/examples/providers.yamlsrc/reloaded-code-provider-config/src/api_type.rssrc/reloaded-code-provider-config/src/config.rssrc/reloaded-code-provider-config/src/error.rssrc/reloaded-code-provider-config/src/lib.rssrc/reloaded-code-provider-config/src/loader.rssrc/reloaded-code-serdesai/src/agent_runtime/provider_bridge/mod.rssrc/reloaded-code-serdesai/src/agent_runtime/provider_bridge/tests.rs
Invalid api_type resolved to Unknown (≠ Ollama), causing the api_url check to fire with MissingField(api_url) instead of the more helpful UnrecognizedApiType. Reorder: validate api_type first, then gate the api_url requirement on the resolved ProviderType.
- Add `ProviderConfigError::TooManyProviders` variant for recoverable error when provider count exceeds u16::MAX + 1 (65,536) - Change `to_catalog_sources` return type to `Result`, replacing panic-prone `assert!` with early validation - Fix doctest in `with_default_paths`: add missing import and wrap in Result-returning function
Custom Providers (YAML-based provider configuration)
Summary
Add
reloaded-code-provider-configcrate for defining custom LLM providers via YAML files - no Rust code required. Also fixes OpenAI-compatible providers to work without credentials when no env vars are listed (e.g., local Ollama).Changes
New crate:
reloaded-code-provider-configProviderConfigLoadercollects YAML files and programmatic entries, merges them (later source wins), validates, and produces catalog sourcesProviderConfigandModelConfigapi_typestrings toProviderTypevariantsConventional config paths (opt-in via
with_default_paths()):~/.config/reloaded-code/providers.yaml(user-global).reloaded/providers.yaml(project-local)Core changes
Modality::from_label()- Parses"text","image","audio","video"intoModalitybitflagsDocumentation
docs/src/guides/custom-providers.mdYAML schema
Supported
api_type:openai,openai-compatible,openai-responses,anthropic,google,groq,mistral,ollama,bedrock,azure,openrouter,huggingface,cohere.Test coverage