mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2026-01-19 16:33:40 +00:00
feat: support many-to-one auth provider mapping
This commit enhances the AI provider configuration system to support multiple configurations per provider while maintaining backward compatibility. Key changes: - Add GetConfigName() to IAIConfig interface to support named configurations - Update AIProvider struct to handle multiple configurations via Configs array - Implement configuration fallback logic in AIProvider methods - Add support for default configuration selection - Update mock configuration in tests to implement new interface methods The changes allow providers to have multiple named configurations while preserving existing functionality for single-configuration setups. This enables more flexible provider configuration management and better integration with various AI backends. Breaking Changes: None Backward Compatible: Yes Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
This commit is contained in:
@@ -78,7 +78,17 @@ type IAIConfig interface {
|
||||
GetTemperature() float32
|
||||
GetTopP() float32
|
||||
GetMaxTokens() int
|
||||
GetConfigName() string // Added to support multiple configurations
|
||||
GetConfigName() string
|
||||
GetPassword() string
|
||||
GetBaseURL() string
|
||||
GetProxyEndpoint() string
|
||||
GetEndpointName() string
|
||||
GetEngine() string
|
||||
GetProviderId() string
|
||||
GetCompartmentId() string
|
||||
GetOrganizationId() string
|
||||
GetCustomHeaders() []http.Header
|
||||
GetTopK() int32
|
||||
}
|
||||
|
||||
func NewClient(provider string) IAI {
|
||||
|
||||
@@ -76,6 +76,10 @@ func (m *mockConfig) GetProviderRegion() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *mockConfig) GetConfigName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func TestOpenAIClient_CustomHeaders(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
assert.Equal(t, "Value1", r.Header.Get("X-Custom-Header-1"))
|
||||
|
||||
Reference in New Issue
Block a user