Skip to content

Commit

Permalink
feat: add optional environment variable configuration to model providers
Browse files Browse the repository at this point in the history
Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Dec 20, 2024
1 parent 4856ebb commit 5e13c50
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions apiclient/types/modelprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
5 changes: 5 additions & 0 deletions apiclient/types/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions pkg/api/handlers/modelprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"] != "" {
Expand All @@ -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
Expand All @@ -253,5 +257,6 @@ func convertModelProviderToolRef(toolRef v1.ToolReference, cred map[string]strin
ModelsBackPopulated: modelsPopulated,
RequiredConfigurationParameters: requiredEnvVars,
MissingConfigurationParameters: missingEnvVars,
OptionalConfigurationParameters: optionalEnvVars,
}
}
14 changes: 14 additions & 0 deletions pkg/storage/openapi/generated/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5e13c50

Please sign in to comment.