Validate and compose provider endpoints
This commit is contained in:
@@ -57,14 +57,19 @@ func (r *Runner) resolveProfileSelection(
|
||||
}, nil
|
||||
}
|
||||
|
||||
func validateResolvedExecutionTarget(target domain.ExecutionTarget) error {
|
||||
if strings.TrimSpace(target.Endpoint) == "" {
|
||||
return errors.New("execution endpoint is required")
|
||||
func normalizeResolvedExecutionTarget(target domain.ExecutionTarget) (domain.ExecutionTarget, error) {
|
||||
endpoint, err := domain.NormalizeOpenAICompatibleBaseEndpoint(target.Endpoint)
|
||||
if err != nil {
|
||||
return domain.ExecutionTarget{}, fmt.Errorf("execution endpoint: %w", err)
|
||||
}
|
||||
target.Endpoint = endpoint
|
||||
if strings.TrimSpace(target.Model) == "" {
|
||||
return errors.New("execution model is required")
|
||||
return domain.ExecutionTarget{}, errors.New("execution model is required")
|
||||
}
|
||||
return domain.ValidateExecutionTargetSettings(target)
|
||||
if err := domain.ValidateExecutionTargetSettings(target); err != nil {
|
||||
return domain.ExecutionTarget{}, err
|
||||
}
|
||||
return target, nil
|
||||
}
|
||||
|
||||
// InspectProfile resolves one explicit profile without prompt or execution work.
|
||||
@@ -87,7 +92,8 @@ func (r *Runner) InspectProfile(
|
||||
return nil, err
|
||||
}
|
||||
target, _ := resolveExecutionTarget(selection.backend, selection.profile, nil)
|
||||
if err := validateResolvedExecutionTarget(target); err != nil {
|
||||
target, err = normalizeResolvedExecutionTarget(target)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w: %w", ErrProfileLoad, err)
|
||||
}
|
||||
target.APIKey = ""
|
||||
|
||||
Reference in New Issue
Block a user