Resolve authentication diagnostics by provider
This commit is contained in:
@@ -110,6 +110,8 @@ func (r *Runner) resolveSmokeTestTarget(ctx context.Context, req domain.SmokeTes
|
||||
} else {
|
||||
settings := defaults.ExecutionTargetDefault()
|
||||
settings.BackendID = selection.backend.ID
|
||||
settings.Provider = selection.backend.Provider
|
||||
settings.ZeroCost = selection.backend.ZeroCost
|
||||
settings.Endpoint = selection.backend.Endpoint
|
||||
settings.APIKeyEnv = selection.backend.APIKeyEnv
|
||||
if len(selection.backend.ExtraParams) > 0 {
|
||||
@@ -132,7 +134,7 @@ func (r *Runner) resolveSmokeTestTarget(ctx context.Context, req domain.SmokeTes
|
||||
if promptInspection != nil {
|
||||
selection.target.PromptID = promptInspection.PromptID
|
||||
}
|
||||
selection.target.Endpoint, err = resolveSmokeTestEndpoint(req.Kind, selection.target.EffectiveSettings.Endpoint, selection.backend.SmokeTests)
|
||||
selection.target.Endpoint, err = resolveSmokeTestEndpoint(req.Kind, selection.target.EffectiveSettings.Endpoint, selection.backend)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w: diagnostic endpoint: %w", ErrInvalidRequest, err)
|
||||
}
|
||||
@@ -165,22 +167,15 @@ func isInferenceSmokeTest(kind domain.SmokeTestKind) bool {
|
||||
return kind == domain.SmokeTestTextInference || kind == domain.SmokeTestStructuredOutput
|
||||
}
|
||||
|
||||
func resolveSmokeTestEndpoint(kind domain.SmokeTestKind, baseEndpoint string, smokeTests *domain.BackendSmokeTestConfig) (string, error) {
|
||||
func resolveSmokeTestEndpoint(kind domain.SmokeTestKind, baseEndpoint string, backend domain.Backend) (string, error) {
|
||||
smokeTests := backend.SmokeTests
|
||||
switch kind {
|
||||
case domain.SmokeTestReachability:
|
||||
if smokeTests != nil && smokeTests.Reachability != nil && smokeTests.Reachability.Endpoint != nil {
|
||||
return *smokeTests.Reachability.Endpoint, nil
|
||||
}
|
||||
case domain.SmokeTestAuthentication:
|
||||
if smokeTests != nil && smokeTests.Authentication != nil {
|
||||
authentication := smokeTests.Authentication
|
||||
if authentication.Endpoint != nil {
|
||||
return *authentication.Endpoint, nil
|
||||
}
|
||||
if authentication.Kind != nil && *authentication.Kind == "openrouter_key" {
|
||||
return llm.OpenRouterKeyEndpoint(baseEndpoint)
|
||||
}
|
||||
}
|
||||
return llm.AuthenticationEndpoint(llm.AuthenticationAdapter(backend.Provider, smokeTests), baseEndpoint, smokeTests)
|
||||
}
|
||||
return baseEndpoint, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user