-
Notifications
You must be signed in to change notification settings - Fork 232
feat: add provider registry for flexible provider registration #1432
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
base: main
Are you sure you want to change the base?
Conversation
Add ProviderRegistry to allow custom provider registration as a fallback when built-in providers are not available. This enables users to register their own provider implementations without modifying the core codebase. - Add ProviderRegistry type with thread-safe Register/Get/IsRegistered methods - Add ProviderRegistry() accessor with lazy initialization using sync.Once - Add createProvider() wrapper that tries built-in first, then registry - Update prepareProvider and hot reload to use createProvider Closes maximhq#1400
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds a thread-safe ProviderRegistry and lazy registry initialization to Bifrost. Provider creation now tries built-in constructors first and falls back to registry-registered constructors via a new createProvider path; provider registry is lazily initialized and exposed via Bifrost.ProviderRegistry(). Changes
Sequence DiagramsequenceDiagram
participant App as Application
participant Bifrost
participant Base as createBaseProvider
participant Registry as ProviderRegistry
participant Constructor as ProviderConstructor
App->>Bifrost: createProvider(providerKey, config)
activate Bifrost
Bifrost->>Base: attempt createBaseProvider(providerKey, config)
activate Base
Base-->>Bifrost: provider or error
deactivate Base
alt built-in created
Bifrost-->>App: return Provider
else fallback to registry
Bifrost->>Registry: ProviderRegistry().Get(providerKey)
activate Registry
Registry-->>Bifrost: ProviderConstructor or nil
deactivate Registry
alt constructor found
Bifrost->>Constructor: constructor(config, logger)
activate Constructor
Constructor-->>Bifrost: Provider instance / error
deactivate Constructor
Bifrost-->>App: return Provider or error
else constructor missing
Bifrost-->>App: return error (unsupported provider)
end
end
deactivate Bifrost
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 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 |
|
@akshaydeo Hello, can you check if this feature change is appropriate? |
|
@eric642 I actually like the idea, I just need to understand some implications. One important area is how we manage requests / LLM execution across providers. We use an actor pattern: an actor is initialized at boot, then it accepts requests and responds via channels, with concurrency controlled by the configured limits. That said, this concept could be extended to dynamically create actors in response to incoming messages. I’ll do a thorough deep dive on the implications and update here. |
|
@akshaydeo,I roughly understand what you mean, but I think this advanced feature is not needed in 99% of development scenarios. The main reason is that the parameters of large model api are very complex, and there are differences in APIs among various manufacturers (whether they are compatible with the OpenAI format or not). Usually, when developing AI app, developers need to confirm the parameters and the list of supported models, and there are rarely cases where models need to be dynamically selected according to requests.
|
|
umm, its not about dynamically selecting models infact we never select models dynamically. This is about pre-warming the connections and workers for processing incoming LLM calls. For that we use actor pattern. Edit: Lines 3272 to 3339 in 6b0c188
|
|
@akshaydeo, Oh oh, I get it. It would indeed be better if it can be created dynamically. |
|
@akshaydeo hello,Is this submission useful? Or are there other plans? |
Summary
Add ProviderRegistry to allow custom provider registration as a fallback when built-in providers are not available. This enables users to register their own provider implementations without modifying the core codebase.
Changes
Type of change
Feature
Affected areas
Core (Go)
Breaking changes
No
If yes, describe impact and migration instructions.
Related issues
Closes #1400