From 5e13c50d749b95ee195f5c9659fbcc32a86c99af Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Fri, 20 Dec 2024 08:05:21 -0500 Subject: [PATCH] feat: add optional environment variable configuration to model providers Signed-off-by: Donnie Adams --- apiclient/types/modelprovider.go | 1 + apiclient/types/zz_generated.deepcopy.go | 5 +++++ pkg/api/handlers/modelprovider.go | 9 +++++++-- pkg/storage/openapi/generated/openapi_generated.go | 14 ++++++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/apiclient/types/modelprovider.go b/apiclient/types/modelprovider.go index d93e4ea51..ec4b655d6 100644 --- a/apiclient/types/modelprovider.go +++ b/apiclient/types/modelprovider.go @@ -17,6 +17,7 @@ type ModelProviderStatus struct { ModelsBackPopulated *bool `json:"modelsBackPopulated,omitempty"` RequiredConfigurationParameters []string `json:"requiredConfigurationParameters,omitempty"` MissingConfigurationParameters []string `json:"missingConfigurationParameters,omitempty"` + OptionalConfigurationParameters []string `json:"optionalConfigurationParameters,omitempty"` } type ModelProviderList List[ModelProvider] diff --git a/apiclient/types/zz_generated.deepcopy.go b/apiclient/types/zz_generated.deepcopy.go index 9dcb05b55..4503fc416 100644 --- a/apiclient/types/zz_generated.deepcopy.go +++ b/apiclient/types/zz_generated.deepcopy.go @@ -913,6 +913,11 @@ func (in *ModelProviderStatus) DeepCopyInto(out *ModelProviderStatus) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.OptionalConfigurationParameters != nil { + in, out := &in.OptionalConfigurationParameters, &out.OptionalConfigurationParameters + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ModelProviderStatus. diff --git a/pkg/api/handlers/modelprovider.go b/pkg/api/handlers/modelprovider.go index 717ec3d26..11b7d0657 100644 --- a/pkg/api/handlers/modelprovider.go +++ b/pkg/api/handlers/modelprovider.go @@ -223,8 +223,8 @@ func convertToolReferenceToModelProvider(ref v1.ToolReference, credEnvVars map[s func convertModelProviderToolRef(toolRef v1.ToolReference, cred map[string]string) *types.ModelProviderStatus { var ( - requiredEnvVars, missingEnvVars []string - icon string + requiredEnvVars, missingEnvVars, optionalEnvVars []string + icon string ) if toolRef.Status.Tool != nil { if toolRef.Status.Tool.Metadata["envVars"] != "" { @@ -238,6 +238,10 @@ func convertModelProviderToolRef(toolRef v1.ToolReference, cred map[string]strin } icon = toolRef.Status.Tool.Metadata["icon"] + + if optionalEnvVarMetadata := toolRef.Status.Tool.Metadata["optionalEnvVars"]; optionalEnvVarMetadata != "" { + optionalEnvVars = strings.Split(optionalEnvVarMetadata, ",") + } } var modelsPopulated *bool @@ -253,5 +257,6 @@ func convertModelProviderToolRef(toolRef v1.ToolReference, cred map[string]strin ModelsBackPopulated: modelsPopulated, RequiredConfigurationParameters: requiredEnvVars, MissingConfigurationParameters: missingEnvVars, + OptionalConfigurationParameters: optionalEnvVars, } } diff --git a/pkg/storage/openapi/generated/openapi_generated.go b/pkg/storage/openapi/generated/openapi_generated.go index e3fbf7951..c6e98663f 100644 --- a/pkg/storage/openapi/generated/openapi_generated.go +++ b/pkg/storage/openapi/generated/openapi_generated.go @@ -2010,6 +2010,20 @@ func schema_obot_platform_obot_apiclient_types_ModelProviderStatus(ref common.Re }, }, }, + "optionalConfigurationParameters": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, }, Required: []string{"configured"}, },