Skip to content

Commit a0cda99

Browse files
committed
Add model key parsing in callModelWithRetry for improved error handling
1 parent 2831dd9 commit a0cda99

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

cmd/generate/llm.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/briandowns/spinner"
1111
"github.com/github/gh-models/internal/azuremodels"
12+
"github.com/github/gh-models/internal/modelkey"
1213
)
1314

1415
// callModelWithRetry makes an API call with automatic retry on rate limiting
@@ -18,6 +19,12 @@ func (h *generateCommandHandler) callModelWithRetry(step string, req azuremodels
1819

1920
h.LogLLMRequest(step, req)
2021

22+
parsedModel, err := modelkey.ParseModelKey(req.Model)
23+
if err != nil {
24+
return "", fmt.Errorf("failed to parse model key: %w", err)
25+
}
26+
req.Model = parsedModel.String()
27+
2128
for attempt := 0; attempt <= maxRetries; attempt++ {
2229
sp := spinner.New(spinner.CharSets[14], 100*time.Millisecond, spinner.WithWriter(h.cfg.ErrOut))
2330
sp.Start()

0 commit comments

Comments
 (0)