mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 20:30:51 +08:00
feat(routing): implement unified model routing with OAuth and API key providers
- Added a new routing package to manage provider registration and model resolution. - Introduced Router, Executor, and Provider interfaces to handle different provider types. - Implemented OAuthProvider and APIKeyProvider to support OAuth and API key authentication. - Enhanced DefaultModelMapper to include OAuth model alias handling and fallback mechanisms. - Updated context management in API handlers to preserve fallback models. - Added tests for routing logic and provider selection. - Enhanced Claude request conversion to handle reasoning content based on thinking mode.
This commit is contained in:
39
internal/routing/adapter.go
Normal file
39
internal/routing/adapter.go
Normal file
@@ -0,0 +1,39 @@
|
||||
// Package routing provides adapter to integrate with existing codebase.
|
||||
package routing
|
||||
|
||||
import (
|
||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
||||
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
||||
)
|
||||
|
||||
// Adapter bridges the new routing layer with existing auth manager.
|
||||
type Adapter struct {
|
||||
router *Router
|
||||
exec *Executor
|
||||
}
|
||||
|
||||
// NewAdapter creates a new adapter with the given configuration and auth manager.
|
||||
func NewAdapter(cfg *config.Config, authManager *coreauth.Manager) *Adapter {
|
||||
registry := NewRegistry()
|
||||
|
||||
// TODO: Register OAuth providers from authManager
|
||||
// TODO: Register API key providers from cfg
|
||||
|
||||
router := NewRouter(registry, cfg)
|
||||
exec := NewExecutor(router)
|
||||
|
||||
return &Adapter{
|
||||
router: router,
|
||||
exec: exec,
|
||||
}
|
||||
}
|
||||
|
||||
// Router returns the underlying router.
|
||||
func (a *Adapter) Router() *Router {
|
||||
return a.router
|
||||
}
|
||||
|
||||
// Executor returns the underlying executor.
|
||||
func (a *Adapter) Executor() *Executor {
|
||||
return a.exec
|
||||
}
|
||||
Reference in New Issue
Block a user