on main help sign in
refactor: simply code
dcf03dbAndrey Nering
internal/config/load.go+7−9
@@ -219,15 +219,19 @@ func (c *Config) configureProviders(env env.Env, resolver VariableResolver, know
219 switch p.ID {
219 switch p.ID {
220 // Handle specific providers that require additional configuration
220 // Handle specific providers that require additional configuration
221 case catwalk.InferenceProviderVertexAI:
221 case catwalk.InferenceProviderVertexAI:
222− if !hasVertexCredentials(env) {
222+ var (
223+ project = env.Get("VERTEXAI_PROJECT")
224+ location = env.Get("VERTEXAI_LOCATION")
225+ )
226+ if project == "" || location == "" {
223 if configExists {
227 if configExists {
224 slog.Warn("Skipping Vertex AI provider due to missing credentials")
228 slog.Warn("Skipping Vertex AI provider due to missing credentials")
225 c.Providers.Del(string(p.ID))
229 c.Providers.Del(string(p.ID))
226 }
230 }
227 continue
231 continue
228 }
232 }
229− prepared.ExtraParams["project"] = env.Get("VERTEXAI_PROJECT")
233+ prepared.ExtraParams["project"] = project
230− prepared.ExtraParams["location"] = env.Get("VERTEXAI_LOCATION")
234+ prepared.ExtraParams["location"] = location
231 case catwalk.InferenceProviderAzure:
235 case catwalk.InferenceProviderAzure:
232 endpoint, err := resolver.ResolveValue(p.APIEndpoint)
236 endpoint, err := resolver.ResolveValue(p.APIEndpoint)
233 if err != nil || endpoint == "" {
237 if err != nil || endpoint == "" {
@@ -677,12 +681,6 @@ func loadFromBytes(configs [][]byte) (*Config, error) {
677 return &config, nil
681 return &config, nil
678}
682}
679
683
680−func hasVertexCredentials(env env.Env) bool {
681− hasProject := env.Get("VERTEXAI_PROJECT") != ""
682− hasLocation := env.Get("VERTEXAI_LOCATION") != ""
683− return hasProject && hasLocation
684−}
685−
686func hasAWSCredentials(env env.Env) bool {
684func hasAWSCredentials(env env.Env) bool {
687 if env.Get("AWS_BEARER_TOKEN_BEDROCK") != "" {
685 if env.Get("AWS_BEARER_TOKEN_BEDROCK") != "" {
688 return true
686 return true