Skip to content

Commit e3261b1

Browse files
author
Test
committed
feat(model): add 'gt model set' command with recommended models
Added gt model set <model> command to set default model: - Shows recommended models per backend in --help - Updates config.yaml with chosen model - Validates model exists in catalog Documentation updates: - Added recommended models table to getting-started.md - groq/compound for tool calling - openrouter/auto for auto-routing - qwen2.5-coder:32b for local with tools Example: gt model set groq/compound
1 parent 3189b78 commit e3261b1

File tree

2 files changed

+106
-2
lines changed

2 files changed

+106
-2
lines changed

cmd/gptcode/model.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,88 @@ Examples:
245245
},
246246
}
247247

248+
var modelSetCmd = &cobra.Command{
249+
Use: "set <model-name>",
250+
Short: "Set default model for your backend",
251+
Long: `Set the default model for your configured backend.
252+
253+
This updates your ~/.gptcode/config.yaml with the specified model.
254+
The model must be available in the catalog for your backend.
255+
256+
Recommended models by backend:
257+
groq: groq/compound (128k context, tool calling)
258+
groq: llama-3.3-70b-versatile (128k context, fast)
259+
openrouter: openrouter/auto (auto-routing across models)
260+
ollama: qwen2.5-coder:32b (local, tool calling)
261+
ollama: llama3.3:70b (local, large context)
262+
263+
Examples:
264+
gptcode model set groq/compound
265+
gptcode model set llama-3.3-70b-versatile
266+
gptcode model set openrouter/auto`,
267+
Args: cobra.ExactArgs(1),
268+
RunE: func(cmd *cobra.Command, args []string) error {
269+
modelName := args[0]
270+
return setDefaultModel(modelName)
271+
},
272+
}
273+
274+
func setDefaultModel(modelName string) error {
275+
setup, err := config.LoadSetup()
276+
if err != nil {
277+
return fmt.Errorf("failed to load setup: %w", err)
278+
}
279+
280+
// Verify model exists in catalog
281+
catalogData, err := catalog.Load()
282+
if err != nil {
283+
fmt.Fprintf(os.Stderr, "[WARN] Could not load catalog: %v\n", err)
284+
fmt.Println("Proceeding anyway - model may not be validated")
285+
} else {
286+
found := false
287+
var allModels []catalog.ModelOutput
288+
allModels = append(allModels, catalogData.Groq.Models...)
289+
allModels = append(allModels, catalogData.OpenRouter.Models...)
290+
allModels = append(allModels, catalogData.Ollama.Models...)
291+
allModels = append(allModels, catalogData.OpenAI.Models...)
292+
allModels = append(allModels, catalogData.DeepSeek.Models...)
293+
294+
for _, m := range allModels {
295+
if m.ID == modelName || m.Name == modelName {
296+
found = true
297+
break
298+
}
299+
}
300+
301+
if !found {
302+
fmt.Fprintf(os.Stderr, "[WARN] Model '%s' not found in catalog\n", modelName)
303+
fmt.Println("Run 'gptcode model list' to see available models")
304+
fmt.Println("Proceeding anyway - model may work if backend supports it")
305+
}
306+
}
307+
308+
// Update config
309+
setup.Defaults.Model = modelName
310+
311+
// Also update backend-specific default if applicable
312+
backendName := setup.Defaults.Backend
313+
if backendConfig, ok := setup.Backend[backendName]; ok {
314+
backendConfig.DefaultModel = modelName
315+
setup.Backend[backendName] = backendConfig
316+
}
317+
318+
// Save config
319+
if err := config.SaveSetup(setup); err != nil {
320+
return fmt.Errorf("failed to save config: %w", err)
321+
}
322+
323+
fmt.Printf("✅ Default model set to: %s\n", modelName)
324+
fmt.Printf(" Backend: %s\n", backendName)
325+
fmt.Println("\nYou can now use 'gptcode do \"task\"' and it will use this model.")
326+
327+
return nil
328+
}
329+
248330
func updateSingleModel(modelName string) error {
249331
fmt.Printf("Updating model: %s\n", modelName)
250332

@@ -393,5 +475,6 @@ func init() {
393475
modelCmd.AddCommand(modelRecommendCmd)
394476
modelCmd.AddCommand(modelInstallCmd)
395477
modelCmd.AddCommand(modelUpdateCmd)
478+
modelCmd.AddCommand(modelSetCmd)
396479
rootCmd.AddCommand(modelCmd)
397480
}

docs/guides/getting-started.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,29 @@ gt do --supervised "refactor module"
5959

6060
- Model management:
6161
```bash
62-
gt model list
63-
gt model recommend editor
62+
gt model list # see all available models
63+
gt model recommend editor # get recommendation
64+
gt model set groq/compound # set default model
65+
```
66+
67+
## Recommended Models by Backend
68+
69+
> **Important**: Not all models support tool calling. Use these recommended models for best results:
70+
71+
| Backend | Model | Context | Best For |
72+
|---------|-------|---------|----------|
73+
| **Groq** | `groq/compound` | 128k | General use, tool calling ✅ |
74+
| **Groq** | `llama-3.3-70b-versatile` | 128k | Fast, large context |
75+
| **OpenRouter** | `openrouter/auto` | varies | Auto-routing, best model per task |
76+
| **Ollama** | `qwen2.5-coder:32b` | 32k | Local, tool calling ✅ |
77+
| **Ollama** | `llama3.3:70b` | 128k | Local, large context |
78+
79+
```bash
80+
# Set your default model
81+
gt model set groq/compound
82+
83+
# Or for local
84+
gt model set qwen2.5-coder:32b
6485
```
6586

6687
## Troubleshooting

0 commit comments

Comments
 (0)