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:
AlexsJones
2025-05-06 11:59:09 +01:00
parent a1a405a380
commit a98de9a821
2 changed files with 15 additions and 1 deletions

View File

@@ -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 {

View File

@@ -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"))