mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 04:10:51 +08:00
- 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.
40 lines
975 B
Go
40 lines
975 B
Go
// 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
|
|
}
|