MCPcopy Create free account
hub / github.com/github/gh-aw / resolvePiBackend

Function resolvePiBackend

pkg/workflow/pi_engine.go:72–91  ·  view source on GitHub ↗

resolvePiBackend extracts the provider prefix from the engine model (if any) and maps it to the matching UniversalLLMBackend. A model without a slash (e.g. "claude-sonnet-4") defaults to the GitHub (Copilot) backend for backward compatibility. "github-copilot/" is accepted as an alias for "copilot

(workflowData *WorkflowData)

Source from the content-addressed store, hash-verified

70// "github-copilot/" is accepted as an alias for "copilot/" since that is the
71// provider name used by Pi CLI's built-in model registry.
72func resolvePiBackend(workflowData *WorkflowData) UniversalLLMBackend {
73 if workflowData == nil || workflowData.EngineConfig == nil || workflowData.EngineConfig.Model == "" {
74 return UniversalLLMBackendCopilot
75 }
76 model := workflowData.EngineConfig.Model
77 if !strings.Contains(model, "/") {
78 // No provider prefix — default to Copilot (backward compatibility).
79 return UniversalLLMBackendCopilot
80 }
81 // "github-copilot" is Pi CLI's internal name for GitHub Copilot. Accept it as
82 // an alias so workflows can use either "copilot/..." or "github-copilot/...".
83 backend, err := resolveBackendWithAliases(model, map[string]UniversalLLMBackend{
84 "github-copilot": UniversalLLMBackendCopilot,
85 })
86 if err != nil {
87 piLog.Printf("Could not resolve backend for Pi model %q, defaulting to copilot: %v", model, err)
88 return UniversalLLMBackendCopilot
89 }
90 return backend
91}
92
93// extractPiModelID returns the model ID portion of a provider/model string.
94// For "copilot/claude-sonnet-4" it returns "claude-sonnet-4".

Callers 3

GetExecutionStepsMethod · 0.85

Calls 2

PrintfMethod · 0.45

Tested by

no test coverage detected