Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

working on new import/import --update commands for adding/updating custom models

Dane Schneider32bdef82860c
diff --cc app/cli/cmd/models.go
index 2b84291b,0a480951..050eb3ee
--- a/app/cli/cmd/models.go
+++ b/app/cli/cmd/models.go
@@@ -25,23 -19,13 +25,25 @@@ import
var customModelsOnly bool
+var allProperties bool
+var genTemplatePath string
++var updateModels bool
+
func init() {
RootCmd.AddCommand(modelsCmd)
+
+ modelsCmd.Flags().BoolVarP(&allProperties, "all", "a", false, "Show all properties")
+
modelsCmd.AddCommand(listAvailableModelsCmd)
- modelsCmd.AddCommand(createCustomModelCmd)
+ modelsCmd.AddCommand(addCustomModelCmd)
+ modelsCmd.AddCommand(updateCustomModelCmd)
+ modelsCmd.AddCommand(importCustomModelCmd)
modelsCmd.AddCommand(deleteCustomModelCmd)
modelsCmd.AddCommand(defaultModelsCmd)
+ importCustomModelCmd.Flags().StringVarP(&genTemplatePath, "generate", "g", "", "Generate a template JSON file")
++ importCustomModelCmd.Flags().BoolVarP(&updateModels, "update", "u", false, "Update existing models")
+
listAvailableModelsCmd.Flags().BoolVarP(&customModelsOnly, "custom", "c", false, "List custom models only")
}
@@@ -93,170 -63,223 +95,225 @@@ var deleteCustomModelCmd = &cobra.Comma
Run: deleteCustomModel,
}
-func createCustomModel(cmd *cobra.Command, args []string) {
+func importCustomModels(cmd *cobra.Command, args []string) {
auth.MustResolveAuthWithOrg()
- model := &shared.AvailableModel{
- BaseModelConfig: shared.BaseModelConfig{
- ModelCompatibility: shared.ModelCompatibility{},
- },
- }
+ var jsonFile string
- genTemplate := genTemplatePath != ""
+
- if len(args) == 0 && !genTemplate {
- fmt.Println(color.New(color.Bold, color.FgHiCyan).Sprint("To add custom models, providers, or model packs πŸ‘‡") + `
- 1. Generate a template JSON file
- 2. Update it in an IDE or editor
- 3. Load the template and finish import`)
- fmt.Println()
++ if len(args) == 1 {
++ jsonFile = args[0]
++ } else if updateModels {
++ term.StartSpinner("")
- fmt.Println("ℹ️ You can also " + color.New(color.Bold, color.FgHiCyan).Sprint("update") + " existing custom models, providers, or model packs with the same JSON file")
- fmt.Println()
- opts := shared.AllModelProviders
- if auth.Current.IsCloud {
- // remove custom provider if we're in cloud
- filtered := []string{}
- for _, provider := range opts {
- if provider != string(shared.ModelProviderCustom) {
- filtered = append(filtered, provider)
++ errCh := make(chan *shared.ApiError, 3)
++ var modelsInput *shared.ModelsInput
++
++ go func() {
++ models, apiErr := api.Client.ListCustomModels()
++ if apiErr != nil {
++ errCh <- apiErr
++ }
++ modelsInput.CustomModels = models
++ errCh <- nil
++ }()
++
++ go func() {
++ providers, apiErr := api.Client.ListCustomProviders()
++ if apiErr != nil {
++ errCh <- apiErr
++ }
++ modelsInput.CustomProviders = providers
++ errCh <- nil
++ }()
++
++ go func() {
++ modelPacks, apiErr := api.Client.ListModelPacks()
++ if apiErr != nil {
++ errCh <- apiErr
+ }
- }
- opts = filtered
- }
- provider, err := term.SelectFromList("Select provider:", opts)
+
- if err != nil {
- term.OutputErrorAndExit("Error selecting provider: %v", err)
- return
- }
- model.Provider = shared.ModelProvider(provider)
++ schemas := make([]*shared.ModelPackSchema, len(modelPacks))
++ for i, modelPack := range modelPacks {
++ schemas[i] = modelPack.ToModelPackSchema()
++ }
+
- if model.Provider == shared.ModelProviderCustom {
- if auth.Current.IsCloud {
- term.OutputErrorAndExit("Custom model providers are not supported on Plandex Cloud")
- return
++ modelsInput.CustomModelPacks = schemas
++ errCh <- nil
++ }()
++
++ term.StopSpinner()
++
++ for i := 0; i < 3; i++ {
++ err := <-errCh
++ if err != nil {
++ term.OutputErrorAndExit("Error fetching custom models: %v", err.Msg)
++ return
++ }
+ }
- customProvider, err := term.GetRequiredUserStringInput("Custom provider:")
+
- const createTemplate = "Generate template"
- const loadTemplate = "Load template"
- const cancel = "Cancel"
- opts := []string{createTemplate, loadTemplate, cancel}
- selected, err := term.SelectFromList("What do you want to do?", opts)
++ // Generate temp file with current state
++ tmpFile, err := os.CreateTemp("", "plandex-models-update-*.json")
if err != nil {
- term.OutputErrorAndExit("Error selecting option: %v", err)
- term.OutputErrorAndExit("Error reading custom provider: %v", err)
++ term.OutputErrorAndExit("Error creating temp file: %v", err)
return
}
- model.CustomProvider = &customProvider
- }
-
- fmt.Println("For model name, be sure to enter the exact, case-sensitive name of the model as it appears in the provider's API docs. Ex: 'gpt-4o', 'deepseek/deepseek-chat'")
- modelName, err := term.GetRequiredUserStringInput("Model name:")
- if err != nil {
- term.OutputErrorAndExit("Error reading model name: %v", err)
- return
- }
- model.ModelName = shared.ModelName(modelName)
- if selected == cancel {
- fmt.Println("For model id, set a unique identifier for the model if you have multiple models with the same name and provider but different settings (otherwise, just press enter to use the model name)")
- modelId, err := term.GetRequiredUserStringInputWithDefault("Model id:", modelName)
- if err != nil {
- term.OutputErrorAndExit("Error reading model id: %v", err)
- return
- }
- model.ModelId = shared.ModelId(modelId)
++ jsonFile = tmpFile.Name()
++ tmpFile.Close()
+
- fmt.Println("Add a human friendly description if you want to.")
- description, err := term.GetUserStringInput("Description (optional):")
- if err != nil {
- term.OutputErrorAndExit("Error reading description: %v", err)
- return
- }
- model.Description = description
++ jsonData, err := json.MarshalIndent(modelsInput, "", " ")
++ if err != nil {
++ term.OutputErrorAndExit("Error marshalling models: %v", err)
+ return
+ }
- if selected == createTemplate {
- genTemplate = true
- } else if selected == loadTemplate {
- jsonFile, err = term.GetRequiredUserStringInput("Template path:")
- if err != nil {
- term.OutputErrorAndExit("Error getting template file path: %v", err)
- return
- }
- if model.Provider == shared.ModelProviderCustom {
- baseUrl, err := term.GetRequiredUserStringInput("Base URL:")
++ err = os.WriteFile(jsonFile, jsonData, 0644)
+ if err != nil {
- term.OutputErrorAndExit("Error reading base URL: %v", err)
++ term.OutputErrorAndExit("Error writing file: %v", err)
+ return
}
+
- baseUrl = strings.TrimSuffix(baseUrl, "/")
++ fmt.Printf("βœ… Created file with current configuration: %s\n",
++ color.New(color.Bold, term.ColorHiGreen).Sprint(jsonFile))
++ fmt.Println()
+
- model.BaseUrl = baseUrl
} else {
- jsonFile = args[0]
- model.BaseUrl = shared.BaseUrlByProvider[model.Provider]
-- }
++ // Case 3: Create new models (default flow)
++ fmt.Println(color.New(color.Bold, color.FgHiCyan).Sprint("Creating template for custom models..."))
++ fmt.Println()
- if genTemplate {
- var path string
- if genTemplatePath != "" {
- path = genTemplatePath
- // Check if file already exists
- if _, err := os.Stat(path); err == nil {
- term.OutputErrorAndExit("Template file already exists: %s", path)
- return
- } else if !os.IsNotExist(err) {
- term.OutputErrorAndExit("Error checking template file: %v", err)
- return
- }
- apiKeyDefault := shared.ApiKeyByProvider[model.Provider]
- var apiKeyEnvVar string
- if model.Provider == shared.ModelProviderCustom {
- if apiKeyDefault == "" {
- apiKeyEnvVar, err = term.GetRequiredUserStringInput("API key environment variable:")
-- } else {
- tmpDir := os.TempDir()
- // Generate a unique temporary file if no path is specified
- tmpFile, err := os.CreateTemp(tmpDir, "plandex-models-*.json")
- if err != nil {
- term.OutputErrorAndExit("Error creating template file: %v", err)
- return
- }
- path = tmpFile.Name()
- tmpFile.Close()
- apiKeyEnvVar, err = term.GetUserStringInputWithDefault("API key environment variable:", apiKeyDefault)
++ // Generate temp file with examples
++ tmpFile, err := os.CreateTemp("", "plandex-models-*.json")
++ if err != nil {
++ term.OutputErrorAndExit("Error creating template file: %v", err)
++ return
}
- } else {
- apiKeyEnvVar = apiKeyDefault
- }
- if err != nil {
- term.OutputErrorAndExit("Error reading API key environment variable: %v", err)
- return
- }
- model.ApiKeyEnvVar = apiKeyEnvVar
++ jsonFile = tmpFile.Name()
++ tmpFile.Close()
+
- fmt.Println("Max Tokens is the total maximum context size of the model.")
+ jsonData, err := json.MarshalIndent(getExampleTemplate(), "", " ")
+ if err != nil {
- term.OutputErrorAndExit("Error marshalling custom model: %v", err)
++ term.OutputErrorAndExit("Error marshalling template: %v", err)
+ return
+ }
- err = os.WriteFile(path, jsonData, 0644)
- maxTokensStr, err := term.GetRequiredUserStringInput("Max Tokens:")
- if err != nil {
- term.OutputErrorAndExit("Error reading max tokens: %v", err)
- return
- }
- maxTokens, err := strconv.Atoi(maxTokensStr)
- if err != nil {
- term.OutputErrorAndExit("Invalid number for max tokens: %v", err)
- return
++ err = os.WriteFile(jsonFile, jsonData, 0644)
+ if err != nil {
+ term.OutputErrorAndExit("Error writing template file: %v", err)
+ return
+ }
+
- fmt.Printf("βœ… Created template %s\n", color.New(color.Bold, term.ColorHiGreen).Sprint(path))
-
++ fmt.Printf("βœ… Created template: %s\n",
++ color.New(color.Bold, term.ColorHiGreen).Sprint(jsonFile))
+ fmt.Println()
+ }
- model.MaxTokens = maxTokens
- selectedEditor := maybePromptAndOpen(path)
-
- pf := "\\"
- if !term.IsRepl {
- pf = "plandex "
- }
- manualImport := `β€’ Run ` + color.New(color.Bold, color.BgCyan, color.FgHiWhite).Sprintf(" %smodels import ", pf) + ` again and select ` + color.New(color.Bold, color.FgHiCyan).Sprint("Load template") + `
- β€’ Run ` + color.New(color.Bold, color.BgCyan, color.FgHiWhite).Sprintf(" %smodels import %s ", pf, path)
- fmt.Println("'Default Max Convo Tokens' is the default maximum size a conversation can reach in the 'planner' role before it is shortened by summarization. For 128k context, ~10000 is recommended. For 200k context, ~15000 is recommended.")
++ // For both add and update flows, open the editor
++ if len(args) == 0 {
++ selectedEditor := maybePromptAndOpen(jsonFile)
- var defaultMaxConvoTokens int
+ if selectedEditor {
- fmt.Println("πŸ“ Opened template")
- fmt.Println(`πŸ‘¨β€πŸ’» Edit it, then come back here to finish importing`)
-
++ fmt.Println("πŸ“ Opened in editor")
++ fmt.Println("πŸ‘¨β€πŸ’» Edit the file, then come back here to finish importing")
+ fmt.Println()
- if maxTokens >= 180000 {
- defaultMaxConvoTokens = 15000
- } else if maxTokens >= 100000 {
- defaultMaxConvoTokens = 10000
- }
+ confirmed, err := term.ConfirmYesNo("Done editing and ready to import?")
+ if err != nil {
- term.OutputErrorAndExit("Error confirming template: %v", err)
++ term.OutputErrorAndExit("Error confirming: %v", err)
+ return
+ }
- fmt.Println()
-
- if confirmed {
- jsonFile = path
- } else {
- fmt.Println("πŸ€·β€β™‚οΈ Didn't import")
- var maxConvoTokensStr string
- if defaultMaxConvoTokens == 0 {
- maxConvoTokensStr, err = term.GetRequiredUserStringInput("Default Max Convo Tokens:")
- } else {
- maxConvoTokensStr, err = term.GetRequiredUserStringInputWithDefault("Default Max Convo Tokens:", strconv.Itoa(defaultMaxConvoTokens))
- }
++ if !confirmed {
++ fmt.Println("πŸ€·β€β™‚οΈ Import cancelled")
+ fmt.Println()
- fmt.Println("When you're ready, either:")
- fmt.Println(manualImport)
+
- if err != nil {
- term.OutputErrorAndExit("Error reading max convo tokens: %v", err)
- return
- }
- maxConvoTokens, err := strconv.Atoi(maxConvoTokensStr)
- if err != nil {
- term.OutputErrorAndExit("Invalid number for max convo tokens: %v", err)
- return
- }
- model.DefaultMaxConvoTokens = maxConvoTokens
-
- fmt.Println("'Max Output Tokens' is the hard limit on output length for the model. Check with the model provider for the recommended value. 8k is a reasonable default if it's not documented, though some models have no max output limitβ€”in that case 'Max Output Tokens' should be set to the same value as 'Max Tokens'.")
++ // Clean up temp file
++ if looksLikeEphemeralTemplate(jsonFile) {
++ os.Remove(jsonFile)
++ }
+
- maxOutputTokensStr, err := term.GetRequiredUserStringInputWithDefault("Max Output Tokens:", "8192")
- if err != nil {
- term.OutputErrorAndExit("Error reading reserved output tokens: %v", err)
- return
- }
- maxOutputTokens, err := strconv.Atoi(maxOutputTokensStr)
- if err != nil {
- term.OutputErrorAndExit("Invalid number for reserved output tokens: %v", err)
- return
- }
- model.MaxOutputTokens = maxOutputTokens
++ pf := "\\"
++ if !term.IsRepl {
++ pf = "plandex "
++ }
+
- fmt.Println("'Reserved Output Tokens' is the default number of tokens reserved for model output. This ensures the model has enough tokens to generate a response. It can be lower than the 'Max Output Tokens' limit and should be set to what a *realistic* output could reach under normal circumstances. If the 'Max Output Tokens' limit is fairly low, just use that. If the 'Max Output Tokens' is very high, or is equal to the 'Max Tokens' input limit, set a lower value so that there's enough room for input. For reasoning models, make sure enough space is included for reasoning tokens.")
++ fmt.Println("When you're ready, run:")
++ fmt.Printf("β€’ %s\n", color.New(color.Bold, color.BgCyan, color.FgHiWhite).
++ Sprintf(" %smodels import %s ", pf, jsonFile))
+ return
+ }
-
++ fmt.Println()
+ } else {
++ // No editor available or user chose manual
++ fmt.Println("πŸ‘¨β€πŸ’» Edit the file in your JSON editor of choice")
++ fmt.Println()
- fmt.Println(`πŸ‘¨β€πŸ’» Edit the template in your IDE or JSON editor of choice, then either:`)
- fmt.Println(manualImport)
- var defaultReservedOutputTokens int
- if maxOutputTokens <= int(float64(maxTokens)*0.2) {
- defaultReservedOutputTokens = maxOutputTokens
- }
++ pf := "\\"
++ if !term.IsRepl {
++ pf = "plandex "
++ }
+
- var reservedOutputTokensStr string
- if defaultReservedOutputTokens == 0 {
- reservedOutputTokensStr, err = term.GetRequiredUserStringInputWithDefault("Reserved Output Tokens:", "8192")
- } else {
- reservedOutputTokensStr, err = term.GetRequiredUserStringInputWithDefault("Reserved Output Tokens:", strconv.Itoa(defaultReservedOutputTokens))
++ fmt.Println("When you're ready, run:")
++ fmt.Printf("β€’ %s\n", color.New(color.Bold, color.BgCyan, color.FgHiWhite).
++ Sprintf(" %smodels import %s ", pf, jsonFile))
+ return
+ }
}
++ // Import the JSON file
+ jsonData, err := os.ReadFile(jsonFile)
if err != nil {
- term.OutputErrorAndExit("Error reading reserved output tokens: %v", err)
+ term.OutputErrorAndExit("Error reading JSON file: %v", err)
return
}
- reservedOutputTokens, err := strconv.Atoi(reservedOutputTokensStr)
+ modelsInput, err := schema.ValidateModelsInputJSON(jsonData)
if err != nil {
- term.OutputErrorAndExit("Invalid number for reserved output tokens: %v", err)
+ color.New(color.Bold, term.ColorHiRed).Println("🚨 Error validating JSON file")
+ fmt.Println(err.Error())
return
}
- model.ReservedOutputTokens = reservedOutputTokens
- fmt.Println("'Preferred Output Format' is the format for roles needing structured output. Currently, OpenAI models do best with 'Tool Call JSON' and other models generally do better with 'XML'. Choose 'XML' if you're unsure as it offers the widest compatibility. 'Tool Call JSON' requires tool call support and reliable JSON generation.")
-
- outputFormatLabels := map[string]string{
- string(shared.ModelOutputFormatXml): "XML",
- string(shared.ModelOutputFormatToolCallJson): "Tool Call JSON",
- }
+ term.StartSpinner("")
+ apiErr := api.Client.CreateCustomModels(&modelsInput)
+ term.StopSpinner()
- res, err := term.SelectFromList("Preferred Output Format:", []string{
- outputFormatLabels[string(shared.ModelOutputFormatXml)],
- outputFormatLabels[string(shared.ModelOutputFormatToolCallJson)],
- })
- if err != nil {
- term.OutputErrorAndExit("Error selecting output format: %v", err)
+ if apiErr != nil {
+ term.OutputErrorAndExit("Error importing models: %v", apiErr.Msg)
return
}
- for key, label := range outputFormatLabels {
- if label == res {
- model.PreferredModelOutputFormat = shared.ModelOutputFormat(key)
- break
- }
- }
- model.HasImageSupport, err = term.ConfirmYesNo("Is multi-modal image support enabled?")
- if err != nil {
- term.OutputErrorAndExit("Error confirming image support: %v", err)
- return
++ action := "Imported"
++
+ for _, provider := range modelsInput.CustomProviders {
- fmt.Println("βœ… Imported custom", color.New(term.ColorHiCyan).Sprint("provider"), "β†’", color.New(color.Bold, term.ColorHiGreen).Sprint(provider.Name))
++ fmt.Printf("βœ… %s custom %s β†’ %s\n",
++ action,
++ color.New(term.ColorHiCyan).Sprint("provider"),
++ color.New(color.Bold, term.ColorHiGreen).Sprint(provider.Name))
}
- term.StartSpinner("")
- apiErr := api.Client.CreateCustomModel(model)
- term.StopSpinner()
+ for _, model := range modelsInput.CustomModels {
- fmt.Println("βœ… Imported custom", color.New(term.ColorHiCyan).Sprint("model"), "β†’", color.New(color.Bold, term.ColorHiGreen).Sprint(string(model.ModelId)))
++ fmt.Printf("βœ… %s custom %s β†’ %s\n",
++ action,
++ color.New(term.ColorHiCyan).Sprint("model"),
++ color.New(color.Bold, term.ColorHiGreen).Sprint(string(model.ModelId)))
+ }
- if apiErr != nil {
- term.OutputErrorAndExit("Error adding model: %v", apiErr.Msg)
- return
+ for _, modelPack := range modelsInput.CustomModelPacks {
- fmt.Println("βœ… Imported custom", color.New(term.ColorHiCyan).Sprint("model pack"), "β†’", color.New(color.Bold, term.ColorHiGreen).Sprint(modelPack.Name))
++ fmt.Printf("βœ… %s custom %s β†’ %s\n",
++ action,
++ color.New(term.ColorHiCyan).Sprint("model pack"),
++ color.New(color.Bold, term.ColorHiGreen).Sprint(modelPack.Name))
}
- if genTemplate || looksLikeEphemeralTemplate(jsonFile) {
- fmt.Println("βœ… Added custom model", color.New(color.Bold, term.ColorHiCyan).Sprint(string(model.Provider)+" β†’ "+string(model.ModelId)))
++ // Clean up temp file if it was generated
++ if len(args) == 0 && looksLikeEphemeralTemplate(jsonFile) {
+ err = os.Remove(jsonFile)
+ if err != nil {
- term.OutputErrorAndExit("Error cleaning up template: %v", err)
++ term.OutputErrorAndExit("Error cleaning up temp file: %v", err)
+ }
+ }
}
func models(cmd *cobra.Command, args []string) {
@@@ -590,252 -649,88 +647,252 @@@ func renderModelPack(modelPack *shared.
}
}
- var temp float32
- var topP float32
- var disabled bool
+ addModelRow(string(shared.ModelRolePlanner), modelPack.Planner.ModelRoleConfig, 0)
- if modelPack.Planner.BaseModelConfig.RoleParamsDisabled {
- temp = 1
- topP = 1
- disabled = true
- anyRoleParamsDisabled = true
- } else {
- temp = modelPack.Planner.Temperature
- topP = modelPack.Planner.TopP
- }
+ addModelRow(string(shared.ModelRoleArchitect), modelPack.GetArchitect(), 0)
+ addModelRow(string(shared.ModelRoleCoder), modelPack.GetCoder(), 0)
+ addModelRow(string(shared.ModelRolePlanSummary), modelPack.PlanSummary, 0)
+ addModelRow(string(shared.ModelRoleBuilder), modelPack.Builder, 0)
+ addModelRow(string(shared.ModelRoleWholeFileBuilder), modelPack.GetWholeFileBuilder(), 0)
+ addModelRow(string(shared.ModelRoleName), modelPack.Namer, 0)
+ addModelRow(string(shared.ModelRoleCommitMsg), modelPack.CommitMsg, 0)
+ addModelRow(string(shared.ModelRoleExecStatus), modelPack.ExecStatus, 0)
+ table.Render()
- tempStr := fmt.Sprintf("%.1f", temp)
- if disabled {
- tempStr = "*" + tempStr
+ if anyRoleParamsDisabled && allProperties {
+ fmt.Println("* these models do not support changing temperature or top p")
}
- topPStr := fmt.Sprintf("%.1f", topP)
- if disabled {
- topPStr = "*" + topPStr
+ fmt.Println()
+
+}
+
+func customModelsNotImplemented(cmd *cobra.Command, args []string) {
+ color.New(color.Bold, color.FgHiRed).Println("⛔️ Not implemented")
+ fmt.Println()
+ fmt.Println("Use " + color.New(color.BgCyan, color.FgHiWhite).Sprint(" plandex models import ") + " to add or update custom models, providers, and model packs with a JSON file")
+ os.Exit(1)
+}
+
+type editorCandidate struct {
+ name string
+ cmd string
+ args []string
+ isJetBrains bool
+}
+
+const maxEditorOpts = 5
+
+func detectEditors() []editorCandidate {
+ guess := []editorCandidate{
+ // Popular non-JetBrains launchers
+ {"VS Code", "code", nil, false},
+ {"Cursor", "cursor", nil, false},
+ {"Zed", "zed", nil, false},
+ {"Neovim", "nvim", nil, false},
+
+ // JetBrains IDE-specific launchers
+ {"IntelliJ IDEA", "idea", nil, true},
+ {"GoLand", "goland", nil, true},
+ {"PyCharm", "pycharm", nil, true},
+ {"CLion", "clion", nil, true},
+ {"WebStorm", "webstorm", nil, true},
+ {"PhpStorm", "phpstorm", nil, true},
+ {"DataGrip", "datagrip", nil, true},
+ {"RubyMine", "rubymine", nil, true},
+ {"Rider", "rider", nil, true},
+ {"DataSpell", "dataspell", nil, true},
+
+ // JetBrains universal CLI (2023.2+)
+ {"JetBrains (jb)", "jb", []string{"open"}, true},
+
+ {"Vim", "vim", nil, false},
+ {"Nano", "nano", nil, false},
+ {"Helix", "hx", nil, false},
+ {"Micro", "micro", nil, false},
+ {"Sublime Text", "subl", nil, false},
+ {"TextMate", "mate", nil, false},
+ {"Kakoune", "kak", nil, false},
+ {"Emacs", "emacs", nil, false},
+ {"Kate", "kate", nil, false},
+ }
+ pref := map[string]bool{}
+ for _, env := range []string{"VISUAL", "EDITOR"} {
+ if v := os.Getenv(env); v != "" {
+ // keep only the binary name, drop path/flags
+ cmd := filepath.Base(strings.Fields(v)[0])
+ pref[cmd] = true
+ }
}
- // Handle planner separately since it has a different fallback structure
- table.Append([]string{
- string(shared.ModelRolePlanner),
- string(modelPack.Planner.BaseModelConfig.Provider),
- string(modelPack.Planner.BaseModelConfig.ModelId),
- tempStr,
- topPStr,
- fmt.Sprintf("%d πŸͺ™", modelPack.Planner.BaseModelConfig.MaxTokens-modelPack.Planner.GetReservedOutputTokens()),
- })
- if modelPack.Planner.LargeContextFallback != nil {
- var temp float32
- var topP float32
- var disabled bool
+ _, err := exec.LookPath("jb") // true if universal launcher exists
+ jbOnPath := err == nil
- if modelPack.Planner.LargeContextFallback.BaseModelConfig.RoleParamsDisabled {
- temp = 1
- topP = 1
- disabled = true
- anyRoleParamsDisabled = true
- } else {
- temp = modelPack.Planner.LargeContextFallback.Temperature
- topP = modelPack.Planner.LargeContextFallback.TopP
+ var found []editorCandidate
+ for _, c := range guess {
+ if _, err := exec.LookPath(c.cmd); err != nil {
+ continue // not on PATH
}
- tempStr := fmt.Sprintf("%.1f", temp)
- if disabled {
- tempStr = "*" + tempStr
+ // If jb is present, drop per-IDE launchers *unless* this exact cmd
+ // is marked preferred by VISUAL/EDITOR.
+ if jbOnPath && c.isJetBrains && !pref[c.cmd] {
+ continue
}
+ found = append(found, c)
+ }
- topPStr := fmt.Sprintf("%.1f", topP)
- if disabled {
- topPStr = "*" + topPStr
+ for cmd := range pref {
+ if _, err := exec.LookPath(cmd); err == nil {
+ already := false
+ for _, c := range found {
+ if c.cmd == cmd {
+ already = true
+ break
+ }
+ }
+ if !already {
+ found = append(found, editorCandidate{name: cmd, cmd: cmd})
+ }
+ }
+ }
+ sort.SliceStable(found, func(i, j int) bool {
+ pi, pj := pref[found[i].cmd], pref[found[j].cmd]
+ if pi == pj {
+ return false // keep original order
}
+ return pi // true β†’ i comes before j
+ })
+ if len(found) > maxEditorOpts {
+ found = found[:maxEditorOpts]
+ }
- table.Append([]string{
- "└─ large-context",
- string(modelPack.Planner.LargeContextFallback.BaseModelConfig.Provider),
- string(modelPack.Planner.LargeContextFallback.BaseModelConfig.ModelId),
- tempStr,
- topPStr,
- fmt.Sprintf("%d πŸͺ™", modelPack.Planner.LargeContextFallback.BaseModelConfig.MaxTokens-modelPack.Planner.LargeContextFallback.GetReservedOutputTokens()),
- })
+ return found
+}
+
+func maybePromptAndOpen(path string) bool {
+ editors := detectEditors()
+ if len(editors) == 0 {
+ // just exit if there are no editors available
+ return false
+ }
+ opts := []string{}
+ for _, c := range editors {
+ opts = append(opts, "Open with "+c.name)
}
- addModelRow(string(shared.ModelRoleArchitect), modelPack.GetArchitect())
- addModelRow(string(shared.ModelRoleCoder), modelPack.GetCoder())
- addModelRow(string(shared.ModelRolePlanSummary), modelPack.PlanSummary)
- addModelRow(string(shared.ModelRoleBuilder), modelPack.Builder)
- addModelRow(string(shared.ModelRoleWholeFileBuilder), modelPack.GetWholeFileBuilder())
- addModelRow(string(shared.ModelRoleName), modelPack.Namer)
- addModelRow(string(shared.ModelRoleCommitMsg), modelPack.CommitMsg)
- addModelRow(string(shared.ModelRoleExecStatus), modelPack.ExecStatus)
- table.Render()
+ const openManually = "Open manually"
+ opts = append(opts, openManually)
- if anyRoleParamsDisabled {
- fmt.Println("* these models do not support changing temperature or top p")
+ choice, err := term.SelectFromList("Edit the template now?", opts)
+ if err != nil {
+ term.OutputErrorAndExit("Error selecting editor: %v", err)
}
- fmt.Println()
+ if choice == openManually {
+ return false
+ }
+ var idx int
+ for i, c := range opts {
+ if c == choice {
+ idx = i
+ break
+ }
+ }
+
+ if idx < len(editors) {
+ sel := editors[idx]
+ err = exec.Command(sel.cmd, append(sel.args, path)...).Start()
+ if err != nil {
+ term.OutputErrorAndExit("Error opening template: %v", err)
+ }
+ return true
+ }
+
+ return false
+}
+
+func looksLikeEphemeralTemplate(p string) bool {
+ // covers cases where the user pasted the temp name manually
+ tmp := os.TempDir()
+ return strings.HasPrefix(p, tmp+string(os.PathSeparator)) &&
+ strings.HasPrefix(filepath.Base(p), "plandex-models-") &&
+ strings.HasSuffix(p, ".json")
+}
+
+func getExampleTemplate() shared.ModelsInput {
+ exampleProviderName := "togetherai"
+
+ return shared.ModelsInput{
+ SchemaUrl: shared.SchemaUrlInputConfig,
- CustomProviders: []shared.CustomProvider{
++ CustomProviders: []*shared.CustomProvider{
+ {
+ Name: exampleProviderName,
+ BaseUrl: "https://api.together.xyz/v1",
+ ApiKeyEnvVar: "TOGETHER_API_KEY",
+ },
+ },
- CustomModels: []shared.CustomModel{
++ CustomModels: []*shared.CustomModel{
+ {
+ ModelId: shared.ModelId("meta-llama/llama-4-maverick"),
+ Publisher: shared.ModelPublisher("meta-llama"),
+ Description: "Meta Llama 4 Maverick",
+
+ BaseModelShared: shared.BaseModelShared{
+ DefaultMaxConvoTokens: 75000,
+ MaxTokens: 1048576,
+ MaxOutputTokens: 16000,
+ ReservedOutputTokens: 16000,
+ ModelCompatibility: shared.FullCompatibility,
+ PreferredOutputFormat: shared.ModelOutputFormatXml,
+ },
+
+ Providers: []shared.BaseModelUsesProvider{
+ {
+ Provider: shared.ModelProviderCustom,
+ CustomProvider: &exampleProviderName,
+ ModelName: "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",
+ },
+ {
+ Provider: shared.ModelProviderOpenRouter,
+ ModelName: "meta-llama/llama-4-maverick",
+ },
+ },
+ },
+ },
- CustomModelPacks: []shared.ModelPackSchema{
++ CustomModelPacks: []*shared.ModelPackSchema{
+ {
+ Name: "example-model-pack",
+ Description: "Example model pack",
+ Planner: shared.ModelRoleConfigSchema{
+ ModelId: shared.ModelId("deepseek/r1-reasoning-visible"),
+ },
+ Architect: &shared.ModelRoleConfigSchema{
+ ModelId: shared.ModelId("deepseek/r1-reasoning-visible"),
+ },
+ Coder: &shared.ModelRoleConfigSchema{
+ ModelId: shared.ModelId("deepseek/v3-0324"),
+ },
+ PlanSummary: shared.ModelRoleConfigSchema{
+ ModelId: shared.ModelId("meta-llama/llama-4-maverick"),
+ },
+ Builder: shared.ModelRoleConfigSchema{
+ ModelId: shared.ModelId("deepseek/r1-reasoning-hidden"),
+ },
+ WholeFileBuilder: &shared.ModelRoleConfigSchema{
+ ModelId: shared.ModelId("deepseek/r1-reasoning-hidden"),
+ },
+ ExecStatus: shared.ModelRoleConfigSchema{
+ ModelId: shared.ModelId("deepseek/r1-reasoning-hidden"),
+ },
+ Namer: shared.ModelRoleConfigSchema{
+ ModelId: shared.ModelId("meta-llama/llama-4-maverick"),
+ },
+ CommitMsg: shared.ModelRoleConfigSchema{
+ ModelId: shared.ModelId("meta-llama/llama-4-maverick"),
+ },
+ },
+ },
+ }
}
diff --cc app/server/db/data_models.go
index b28d3689,2db0749a..c2bec0ff
--- a/app/server/db/data_models.go
+++ b/app/server/db/data_models.go
@@@ -313,23 -310,9 +313,24 @@@ type ModelPack struct
ExecStatus shared.ModelRoleConfig `db:"exec_status"`
Architect *shared.ModelRoleConfig `db:"context_loader"`
CreatedAt time.Time `db:"created_at"`
+ UpdatedAt time.Time `db:"updated_at"`
}
+func ModelPackFromApi(apiModelPack *shared.ModelPack) *ModelPack {
+ return &ModelPack{
+ Name: apiModelPack.Name,
+ Description: apiModelPack.Description,
+ Planner: apiModelPack.Planner,
+ Architect: apiModelPack.Architect,
+ Coder: apiModelPack.Coder,
+ PlanSummary: apiModelPack.PlanSummary,
+ Builder: apiModelPack.Builder,
+ Namer: apiModelPack.Namer,
+ CommitMsg: apiModelPack.CommitMsg,
+ ExecStatus: apiModelPack.ExecStatus,
+ }
+}
+
func (modelPack *ModelPack) ToApi() *shared.ModelPack {
return &shared.ModelPack{
Id: modelPack.Id,
diff --cc app/server/model/client.go
index 6c492335,a3c80bff..8ffb43fe
--- a/app/server/model/client.go
+++ b/app/server/model/client.go
@@@ -392,54 -376,7 +392,7 @@@ func resolveReq(req *types.ExtendedChat
}
}
- // this isn't working yet
- // if modelConfig.BaseModelConfig.UsesOpenAIResponsesAPI {
- // log.Println("Using OpenAI Responses API")
- // input := make([]types.ExtendedChatMessage, 0)
-
- // for _, msg := range req.Messages {
- // // isDevRole := false
- // isAssistantRole := false
- // if msg.Role == openai.ChatMessageRoleSystem {
- // log.Println("Changing role of system message to 'developer'")
- // msg.Role = openai.ChatMessageRoleDeveloper
- // // isDevRole = true
- // } else if msg.Role == openai.ChatMessageRoleAssistant {
- // isAssistantRole = true
- // }
-
- // for j, part := range msg.Content {
- // if part.Type == "text" {
- // if isAssistantRole {
- // part.Type = "output_text"
- // } else {
- // part.Type = "input_text"
- // }
- // }
-
- // msg.Content[j] = part
- // }
-
- // input = append(input, msg)
- // }
-
- // // stop is not supported for the responses API
- // if req.Stop != nil {
- // req.Stop = nil
- // }
-
- // if req.StreamOptions != nil {
- // req.StreamOptions = nil
- // }
-
- // req.Input = input
- // req.Messages = nil
-
- // log.Println("req.Input", len(req.Input))
- // log.Println("req.Messages", len(req.Messages))
- // }
-
- if modelConfig.BaseModelConfig.RoleParamsDisabled {
+ if modelConfig.GetSharedBaseConfig().RoleParamsDisabled {
log.Println("Role params disabled - setting temperature and top p to 1")
req.Temperature = 1
req.TopP = 1
diff --cc app/server/model/client_stream.go
index 7ec3bb00,8e6852fc..36e361f8
--- a/app/server/model/client_stream.go
+++ b/app/server/model/client_stream.go
@@@ -80,7 -102,12 +82,13 @@@ func processChatCompletionStream
) (*types.ModelResponse, error) {
streamCtx, cancel := context.WithCancel(ctx)
+ log.Println("processChatCompletionStream - modelConfig", spew.Sdump(map[string]interface{}{
+ "model": modelConfig.BaseModelConfig.ModelName,
+ "provider": modelConfig.BaseModelConfig.Provider,
+ }))
+
- stream, err := createChatCompletionStreamExtended(modelConfig, client, baseUrl, streamCtx, req)
+ stream, err := createChatCompletionStreamExtended(modelConfig, client, authVars, streamCtx, req)
++
if err != nil {
cancel()
return nil, fmt.Errorf("error creating chat completion stream: %w", err)
diff --cc app/shared/ai_models_available.go
index b80356c1,f584c745..cbb6fecc
--- a/app/shared/ai_models_available.go
+++ b/app/shared/ai_models_available.go
@@@ -328,13 -224,52 +328,145 @@@ var BuiltInModels = []*BaseModelConfigS
},
},
- // OpenRouter models
+ {
- Description: "Anthropic Claude 4 Sonnet via OpenRouter",
- DefaultMaxConvoTokens: 15000,
- BaseModelConfig: BaseModelConfig{
- Provider: ModelProviderOpenRouter,
- ModelName: "anthropic/claude-sonnet-4",
- ModelId: "anthropic/claude-sonnet-4",
++ ModelTag: "anthropic/claude-opus-4",
++ Publisher: ModelPublisherAnthropic,
++ Description: "Anthropic Claude Opus 4",
++
++ BaseModelShared: BaseModelShared{
++ DefaultMaxConvoTokens: 15000,
+ MaxTokens: 200000,
+ MaxOutputTokens: 128000,
+ ReservedOutputTokens: 20000,
+ SupportsCacheControl: true,
- ApiKeyEnvVar: ApiKeyByProvider[ModelProviderOpenRouter],
- ModelCompatibility: fullCompatibility,
- BaseUrl: BaseUrlByProvider[ModelProviderOpenRouter],
- PreferredModelOutputFormat: ModelOutputFormatXml,
++ PreferredOutputFormat: ModelOutputFormatXml,
+ SingleMessageNoSystemPrompt: true,
+ TokenEstimatePaddingPct: 0.10,
+ },
++
++ Variants: []BaseModelConfigVariant{
++ {
++ IsBaseVariant: true,
++ },
++ {
++ VariantTag: "thinking",
++ Description: "thinking",
++ Overrides: BaseModelShared{
++ ReasoningBudget: AnthropicMaxReasoningBudget,
++ },
++
++ Variants: []BaseModelConfigVariant{
++ {
++ VariantTag: "visible",
++ Description: "visible",
++ Overrides: BaseModelShared{
++ IncludeReasoning: true,
++ },
++ },
++ {
++ VariantTag: "hidden",
++ Description: "hidden",
++ Overrides: BaseModelShared{
++ IncludeReasoning: false,
++ },
++ },
++ },
++ },
++ },
++
++ Providers: []BaseModelUsesProvider{
++ {
++ Provider: ModelProviderAnthropic,
++ ModelName: "anthropic/claude-opus-4-0",
++ },
++ {
++ Provider: ModelProviderAmazonBedrock,
++ ModelName: "bedrock/anthropic.claude-opus-4-20250514-v1:0",
++ },
++ {
++ Provider: ModelProviderGoogleVertex,
++ ModelName: "vertex_ai/claude-opus-4@20250514",
++ },
++ {
++ Provider: ModelProviderOpenRouter,
++ ModelName: "anthropic/claude-opus-4",
++ },
++ },
+ },
++
+ {
- Description: "Anthropic Claude 4 Opus via OpenRouter",
- DefaultMaxConvoTokens: 15000,
- BaseModelConfig: BaseModelConfig{
- Provider: ModelProviderOpenRouter,
- ModelName: "anthropic/claude-opus-4",
- ModelId: "anthropic/claude-opus-4",
++ ModelTag: "anthropic/claude-sonnet-4",
++ Publisher: ModelPublisherAnthropic,
++ Description: "Anthropic Claude Sonnet 4",
++
++ BaseModelShared: BaseModelShared{
++ DefaultMaxConvoTokens: 15000,
+ MaxTokens: 200000,
+ MaxOutputTokens: 128000,
+ ReservedOutputTokens: 20000,
+ SupportsCacheControl: true,
- ApiKeyEnvVar: ApiKeyByProvider[ModelProviderOpenRouter],
- ModelCompatibility: fullCompatibility,
- BaseUrl: BaseUrlByProvider[ModelProviderOpenRouter],
- PreferredModelOutputFormat: ModelOutputFormatXml,
++ PreferredOutputFormat: ModelOutputFormatXml,
+ SingleMessageNoSystemPrompt: true,
+ TokenEstimatePaddingPct: 0.10,
+ },
++
++ Variants: []BaseModelConfigVariant{
++ {
++ IsBaseVariant: true,
++ },
++ {
++ VariantTag: "thinking",
++ Description: "thinking",
++ Overrides: BaseModelShared{
++ ReasoningBudget: AnthropicMaxReasoningBudget,
++ },
++
++ Variants: []BaseModelConfigVariant{
++ {
++ VariantTag: "visible",
++ Description: "visible",
++ Overrides: BaseModelShared{
++ IncludeReasoning: true,
++ },
++ },
++ {
++ VariantTag: "hidden",
++ Description: "hidden",
++ Overrides: BaseModelShared{
++ IncludeReasoning: false,
++ },
++ },
++ },
++ },
++ },
++
++ Providers: []BaseModelUsesProvider{
++ {
++ Provider: ModelProviderAnthropic,
++ ModelName: "anthropic/claude-sonnet-4-0", // β€œ-0” alias
++ },
++ {
++ Provider: ModelProviderAmazonBedrock,
++ ModelName: "bedrock/anthropic.claude-sonnet-4-20250514-v1:0",
++ },
++ {
++ Provider: ModelProviderGoogleVertex,
++ ModelName: "vertex_ai/claude-sonnet-4@20250514",
++ },
++ {
++ Provider: ModelProviderOpenRouter,
++ ModelName: "anthropic/claude-sonnet-4",
++ },
++ },
+ },
++
{
- Description: "Anthropic Claude 3.7 Sonnet via OpenRouter",
- DefaultMaxConvoTokens: 15000,
- BaseModelConfig: BaseModelConfig{
- Provider: ModelProviderOpenRouter,
- ModelName: "anthropic/claude-3.7-sonnet",
- ModelId: "anthropic/claude-3.7-sonnet",
+ ModelTag: "anthropic/claude-3.7-sonnet",
+ Publisher: ModelPublisherAnthropic,
+ Description: "Anthropic Claude 3.7 Sonnet",
+
+ BaseModelShared: BaseModelShared{
+ DefaultMaxConvoTokens: 15000,
MaxTokens: 200000,
MaxOutputTokens: 128000,
ReservedOutputTokens: 20000,
@@@ -496,90 -413,136 +628,103 @@@
},
},
{
- Description: "Google Gemini Flash 2.5 Preview via OpenRouter",
- DefaultMaxConvoTokens: 75000,
- BaseModelConfig: BaseModelConfig{
- Provider: ModelProviderOpenRouter,
- ModelName: "google/gemini-2.5-flash-preview",
- ModelId: "google/gemini-2.5-flash-preview",
- MaxTokens: 1048576,
- MaxOutputTokens: 65535,
- ReservedOutputTokens: 65535,
- ApiKeyEnvVar: ApiKeyByProvider[ModelProviderOpenRouter],
- ModelCompatibility: fullCompatibility,
- BaseUrl: BaseUrlByProvider[ModelProviderOpenRouter],
- PreferredModelOutputFormat: ModelOutputFormatXml,
- SupportsCacheControl: true,
+ ModelTag: "google/gemini-2.5-pro-preview",
+ Publisher: ModelPublisherGoogle,
+ Description: "Google Gemini 2.5 Pro (Preview)",
+
+ BaseModelShared: BaseModelShared{
+ DefaultMaxConvoTokens: 75000,
+ MaxTokens: 1048576,
+ MaxOutputTokens: 65535,
+ ReservedOutputTokens: 65535,
+ // SupportsCacheControl: true, // gemini now uses implicit caching
+ PreferredOutputFormat: ModelOutputFormatXml,
},
- },
- {
- Description: "Google Gemini Flash 2.5 Preview (thinking) via OpenRouter",
- DefaultMaxConvoTokens: 75000,
- BaseModelConfig: BaseModelConfig{
- Provider: ModelProviderOpenRouter,
- ModelName: "google/gemini-2.5-flash-preview-05-20:thinking",
- ModelId: "google/gemini-2.5-flash-preview-05-20:thinking",
- MaxTokens: 1048576,
- MaxOutputTokens: 65535,
- ReservedOutputTokens: 65535,
- ApiKeyEnvVar: ApiKeyByProvider[ModelProviderOpenRouter],
- ModelCompatibility: fullCompatibility,
- BaseUrl: BaseUrlByProvider[ModelProviderOpenRouter],
- PreferredModelOutputFormat: ModelOutputFormatXml,
- SupportsCacheControl: true,
+ Providers: []BaseModelUsesProvider{
+ {
+ Provider: ModelProviderGoogleAIStudio,
+ ModelName: "gemini/gemini-2.5-pro-preview-05-06",
+ },
+ {
+ Provider: ModelProviderGoogleVertex,
+ ModelName: "vertex_ai/gemini-2.5-pro-preview-05-06",
+ },
+ {
+ Provider: ModelProviderOpenRouter,
+ ModelName: "google/gemini-2.5-pro-preview",
+ },
},
},
-
{
- Description: "DeepSeek V3 0324 via OpenRouter",
- DefaultMaxConvoTokens: 7500,
- BaseModelConfig: BaseModelConfig{
- Provider: ModelProviderOpenRouter,
- ModelName: "deepseek/deepseek-chat-v3-0324",
- ModelId: "deepseek/deepseek-chat-v3-0324",
- MaxTokens: 64000,
- MaxOutputTokens: 8192,
- ReservedOutputTokens: 8192,
- ApiKeyEnvVar: ApiKeyByProvider[ModelProviderOpenRouter],
- ModelCompatibility: ModelCompatibility{
- HasImageSupport: false,
- },
- BaseUrl: BaseUrlByProvider[ModelProviderOpenRouter],
- PreferredModelOutputFormat: ModelOutputFormatXml,
+ ModelTag: "google/gemini-2.5-pro-exp",
+ Publisher: ModelPublisherGoogle,
+ Description: "Google Gemini 2.5 Pro (Experimental)",
+
+ BaseModelShared: BaseModelShared{
+ DefaultMaxConvoTokens: 75000,
+ MaxTokens: 1048576,
+ MaxOutputTokens: 65535,
+ ReservedOutputTokens: 65535,
+ PreferredOutputFormat: ModelOutputFormatXml,
},
- },
- {
- Description: "DeepSeek R1 via OpenRouter (includes reasoning)",
- DefaultMaxConvoTokens: 7500,
- BaseModelConfig: BaseModelConfig{
- Provider: ModelProviderOpenRouter,
- ModelName: "deepseek/deepseek-r1",
- ModelId: "deepseek/deepseek-r1-reasoning",
- MaxTokens: 64000,
- MaxOutputTokens: 8192,
- ReservedOutputTokens: 8192,
- ApiKeyEnvVar: ApiKeyByProvider[ModelProviderOpenRouter],
- ModelCompatibility: ModelCompatibility{
- HasImageSupport: false,
- },
- BaseUrl: BaseUrlByProvider[ModelProviderOpenRouter],
- PreferredModelOutputFormat: ModelOutputFormatXml,
- IncludeReasoning: true,
+ Providers: []BaseModelUsesProvider{
+ {
+ Provider: ModelProviderGoogleAIStudio,
+ ModelName: "gemini/gemini-2.5-pro-exp-03-25",
+ },
+ {
+ Provider: ModelProviderGoogleVertex,
+ ModelName: "vertex_ai/gemini-2.5-pro-exp-03-25",
+ },
+ {
+ Provider: ModelProviderOpenRouter,
+ ModelName: "google/gemini-2.5-pro-exp-03-25",
+ },
},
},
-
{
- Description: "DeepSeek R1 via OpenRouter (reasoning hidden)",
- DefaultMaxConvoTokens: 7500,
- BaseModelConfig: BaseModelConfig{
- Provider: ModelProviderOpenRouter,
- ModelName: "deepseek/deepseek-r1",
- ModelId: "deepseek/deepseek-r1-no-reasoning",
- MaxTokens: 64000,
- MaxOutputTokens: 8192,
- ReservedOutputTokens: 8192,
- ApiKeyEnvVar: ApiKeyByProvider[ModelProviderOpenRouter],
- ModelCompatibility: ModelCompatibility{
- HasImageSupport: false,
- },
- BaseUrl: BaseUrlByProvider[ModelProviderOpenRouter],
- PreferredModelOutputFormat: ModelOutputFormatXml,
+ ModelTag: "google/gemini-2.5-flash-preview",
+ Publisher: ModelPublisherGoogle,
+ Description: "Google Gemini 2.5 Flash (Preview)",
+
+ BaseModelShared: BaseModelShared{
+ DefaultMaxConvoTokens: 75000,
+
+ MaxTokens: 1048576,
+ MaxOutputTokens: 65535,
+ ReservedOutputTokens: 65535,
+ // SupportsCacheControl: true, // gemini now uses implicit caching
+ PreferredOutputFormat: ModelOutputFormatXml,
},
- },
- {
- Description: "Perplexity R1 1776 via OpenRouter (includes reasoning)",
- DefaultMaxConvoTokens: 7500,
- BaseModelConfig: BaseModelConfig{
- Provider: ModelProviderOpenRouter,
- ModelName: "perplexity/r1-1776",
- ModelId: "perplexity/r1-1776",
- MaxTokens: 128000,
- MaxOutputTokens: 128000,
- ReservedOutputTokens: 30000,
- ApiKeyEnvVar: ApiKeyByProvider[ModelProviderOpenRouter],
- ModelCompatibility: ModelCompatibility{
- HasImageSupport: false,
- },
- BaseUrl: BaseUrlByProvider[ModelProviderOpenRouter],
- PreferredModelOutputFormat: ModelOutputFormatXml,
- IncludeReasoning: true,
++ Variants: []BaseModelConfigVariant{
++ {
++ IsBaseVariant: true,
++ },
++ {
++ VariantTag: "thinking",
++ Description: "thinking",
++ Overrides: BaseModelShared{
++ IncludeReasoning: true,
++ },
++ },
+ },
- },
+
- {
- Description: "Perplexity Sonar Reasoning via OpenRouter (includes reasoning)",
- DefaultMaxConvoTokens: 7500,
- BaseModelConfig: BaseModelConfig{
- Provider: ModelProviderOpenRouter,
- ModelName: "perplexity/sonar-reasoning",
- ModelId: "perplexity/sonar-reasoning",
- MaxTokens: 127000,
- MaxOutputTokens: 127000,
- ReservedOutputTokens: 30000,
- ApiKeyEnvVar: ApiKeyByProvider[ModelProviderOpenRouter],
- ModelCompatibility: ModelCompatibility{
- HasImageSupport: false,
- },
- BaseUrl: BaseUrlByProvider[ModelProviderOpenRouter],
- PreferredModelOutputFormat: ModelOutputFormatXml,
- IncludeReasoning: true,
+ Providers: []BaseModelUsesProvider{
+ {
+ Provider: ModelProviderGoogleAIStudio,
- ModelName: "gemini/gemini-2.5-flash-preview-04-17",
++ ModelName: "gemini/gemini-2.5-flash-preview-05-20",
+ },
+ {
+ Provider: ModelProviderGoogleVertex,
- ModelName: "vertex_ai/gemini-2.5-flash-preview-04-17",
++ ModelName: "vertex_ai/gemini-2.5-flash-preview-05-20",
+ },
+ {
+ Provider: ModelProviderOpenRouter,
- ModelName: "google/gemini-2.5-flash-preview",
++ ModelName: "google/gemini-2.5-flash-preview-05-20",
+ },
},
},
diff --cc app/shared/ai_models_custom.go
index 03c9b39d,00000000..f6dd6fd1
mode 100644,000000..100644
--- a/app/shared/ai_models_custom.go
+++ b/app/shared/ai_models_custom.go
@@@ -1,46 -1,0 +1,46 @@@
+package shared
+
+import "time"
+
+type SchemaUrl string
+
+const SchemaUrlInputConfig SchemaUrl = "https://plandex.ai/schemas/models-input.schema.json"
+
+type CustomModel struct {
+ Id string `json:"id,omitempty"`
+ ModelId ModelId `json:"modelId"`
+ Publisher ModelPublisher `json:"publisher"`
+ Description string `json:"description"`
+
+ BaseModelShared
+
+ Providers []BaseModelUsesProvider `json:"providers"`
+
+ CreatedAt *time.Time `json:"createdAt,omitempty"`
+ UpdatedAt *time.Time `json:"updatedAt,omitempty"`
+}
+
+type CustomProvider struct {
+ Id string `json:"id,omitempty"`
+ Name string `json:"name"`
+ BaseUrl string `json:"baseUrl"`
+
+ // for AWS Bedrock models
+ HasAWSAuth bool `json:"hasAWSAuth,omitempty"`
+
+ // for local models that don't require auth (ollama, etc.)
+ SkipAuth bool `json:"skipAuth,omitempty"`
+
+ ApiKeyEnvVar string `json:"apiKeyEnvVar,omitempty"`
+ ExtraAuthVars []ModelProviderExtraAuthVars `json:"extraAuthVars,omitempty"`
+
+ CreatedAt *time.Time `json:"createdAt,omitempty"`
+ UpdatedAt *time.Time `json:"updatedAt,omitempty"`
+}
+
+type ModelsInput struct {
- SchemaUrl SchemaUrl `json:"schemaUrl"`
- CustomModels []CustomModel `json:"customModels"`
- CustomProviders []CustomProvider `json:"customProviders"`
- CustomModelPacks []ModelPackSchema `json:"customModelPacks"`
++ SchemaUrl SchemaUrl `json:"schemaUrl"`
++ CustomModels []*CustomModel `json:"customModels"`
++ CustomProviders []*CustomProvider `json:"customProviders"`
++ CustomModelPacks []*ModelPackSchema `json:"customModelPacks"`
+}
diff --cc app/shared/ai_models_data_models.go
index 4828b1e5,08791f47..29caf578
--- a/app/shared/ai_models_data_models.go
+++ b/app/shared/ai_models_data_models.go
@@@ -270,129 -95,8 +270,163 @@@ type ModelRoleConfig struct
LargeContextFallback *ModelRoleConfig `json:"largeContextFallback"`
LargeOutputFallback *ModelRoleConfig `json:"largeOutputFallback"`
ErrorFallback *ModelRoleConfig `json:"errorFallback"`
- MissingKeyFallback *ModelRoleConfig `json:"missingKeyFallback"`
- StrongModel *ModelRoleConfig `json:"strongModel"`
+ // MissingKeyFallback *ModelRoleConfig `json:"missingKeyFallback"` // removed in 2.2.0 refactor β€”
+ StrongModel *ModelRoleConfig `json:"strongModel"`
+}
+
+type ModelRoleModelConfig struct {
+ Provider ModelProvider `json:"provider"`
+ CustomProvider *string `json:"customProvider,omitempty"`
+ ModelTag ModelTag `json:"modelTag"`
+}
+
+type ModelRoleConfigSchema struct {
+ ModelId ModelId `json:"modelId"`
+
+ Temperature float32 `json:"temperature,omitempty"`
+ TopP float32 `json:"topP,omitempty"`
+ ReservedOutputTokens int `json:"reservedOutputTokens,omitempty"`
+ MaxConvoTokens int `json:"maxConvoTokens,omitempty"`
+
+ LargeContextFallback *ModelRoleConfigSchema `json:"largeContextFallback,omitempty"`
+ LargeOutputFallback *ModelRoleConfigSchema `json:"largeOutputFallback,omitempty"`
+ ErrorFallback *ModelRoleConfigSchema `json:"errorFallback,omitempty"`
+ StrongModel *ModelRoleConfigSchema `json:"strongModel,omitempty"`
+}
+
+func (m *ModelRoleConfigSchema) AllModelIds() []ModelId {
+ ids := []ModelId{}
+
+ if m.ModelId != "" {
+ ids = append(ids, m.ModelId)
+ }
+
+ if m.LargeContextFallback != nil {
+ ids = append(ids, m.LargeContextFallback.AllModelIds()...)
+ }
+
+ if m.LargeOutputFallback != nil {
+ ids = append(ids, m.LargeOutputFallback.AllModelIds()...)
+ }
+
+ if m.ErrorFallback != nil {
+ ids = append(ids, m.ErrorFallback.AllModelIds()...)
+ }
+
+ if m.StrongModel != nil {
+ ids = append(ids, m.StrongModel.AllModelIds()...)
+ }
+
+ return ids
+}
+
+func (m *ModelRoleConfigSchema) ToModelRoleConfig(role ModelRole) ModelRoleConfig {
+ return m.toModelRoleConfig(role)
+}
+
+func (m *ModelRoleConfigSchema) toModelRoleConfig(role ModelRole) ModelRoleConfig {
+ var largeContextFallback *ModelRoleConfig
+ if m.LargeContextFallback != nil {
+ c := m.LargeContextFallback.ToModelRoleConfig(role)
+ largeContextFallback = &c
+ }
+ var largeOutputFallback *ModelRoleConfig
+ if m.LargeOutputFallback != nil {
+ c := m.LargeOutputFallback.ToModelRoleConfig(role)
+ largeOutputFallback = &c
+ }
+ var errorFallback *ModelRoleConfig
+ if m.ErrorFallback != nil {
+ c := m.ErrorFallback.ToModelRoleConfig(role)
+ errorFallback = &c
+ }
+ var strongModel *ModelRoleConfig
+ if m.StrongModel != nil {
+ c := m.StrongModel.ToModelRoleConfig(role)
+ strongModel = &c
+ }
+
+ return ModelRoleConfig{
+ Role: role,
+
+ ModelId: m.ModelId,
+
+ Temperature: m.Temperature,
+ TopP: m.TopP,
+ ReservedOutputTokens: m.ReservedOutputTokens,
+
+ LargeContextFallback: largeContextFallback,
+ LargeOutputFallback: largeOutputFallback,
+ ErrorFallback: errorFallback,
+ StrongModel: strongModel,
+ }
+}
+
++func (m *ModelRoleConfig) ToModelRoleConfigSchema() ModelRoleConfigSchema {
++ var largeContextFallback *ModelRoleConfigSchema
++ if m.LargeContextFallback != nil {
++ c := m.LargeContextFallback.ToModelRoleConfigSchema()
++ largeContextFallback = &c
++ }
++ var largeOutputFallback *ModelRoleConfigSchema
++ if m.LargeOutputFallback != nil {
++ c := m.LargeOutputFallback.ToModelRoleConfigSchema()
++ largeOutputFallback = &c
++ }
++ var errorFallback *ModelRoleConfigSchema
++ if m.ErrorFallback != nil {
++ c := m.ErrorFallback.ToModelRoleConfigSchema()
++ errorFallback = &c
++ }
++ var strongModel *ModelRoleConfigSchema
++ if m.StrongModel != nil {
++ c := m.StrongModel.ToModelRoleConfigSchema()
++ strongModel = &c
++ }
++
++ return ModelRoleConfigSchema{
++ ModelId: m.ModelId,
++ Temperature: m.Temperature,
++ TopP: m.TopP,
++ ReservedOutputTokens: m.ReservedOutputTokens,
++ LargeContextFallback: largeContextFallback,
++ LargeOutputFallback: largeOutputFallback,
++ ErrorFallback: errorFallback,
++ StrongModel: strongModel,
++ }
++}
++
+func (m ModelRoleConfig) GetModelId() ModelId {
+ if m.BaseModelConfig != nil {
+ return m.BaseModelConfig.ModelId
+ }
+
+ return m.ModelId
+}
+
+func (m ModelRoleConfig) GetBaseModelConfig(authVars map[string]string) *BaseModelConfig {
+ if m.BaseModelConfig != nil {
+ return m.BaseModelConfig
+ }
+
+ foundProvider := m.GetFirstProviderForAuthVars(authVars)
+ if foundProvider == nil {
+ return m.BaseModelConfig
+ }
+
+ c := GetAvailableModel(foundProvider.Provider, m.ModelId).BaseModelConfig
+
+ return &c
+}
+
+func (m ModelRoleConfig) GetProviderComposite(authVars map[string]string) string {
+ baseModelConfig := m.GetBaseModelConfig(authVars)
+
+ if baseModelConfig == nil {
+ return ""
+ }
+
+ return baseModelConfig.ToComposite()
}
func (m ModelRoleConfig) GetReservedOutputTokens() int {
@@@ -585,6 -183,6 +619,38 @@@ func (m *ModelPack) GetArchitect() Mode
return *m.Architect
}
++func (m *ModelPack) ToModelPackSchema() *ModelPackSchema {
++ var coder *ModelRoleConfigSchema
++ if m.Coder != nil {
++ c := m.Coder.ToModelRoleConfigSchema()
++ coder = &c
++ }
++ var wholeFileBuilder *ModelRoleConfigSchema
++ if m.WholeFileBuilder != nil {
++ c := m.WholeFileBuilder.ToModelRoleConfigSchema()
++ wholeFileBuilder = &c
++ }
++ var architect *ModelRoleConfigSchema
++ if m.Architect != nil {
++ c := m.Architect.ToModelRoleConfigSchema()
++ architect = &c
++ }
++
++ return &ModelPackSchema{
++ Name: m.Name,
++ Description: m.Description,
++ Planner: m.Planner.ToModelRoleConfigSchema(),
++ Coder: coder,
++ Architect: architect,
++ PlanSummary: m.PlanSummary.ToModelRoleConfigSchema(),
++ Builder: m.Builder.ToModelRoleConfigSchema(),
++ WholeFileBuilder: wholeFileBuilder,
++ Namer: m.Namer.ToModelRoleConfigSchema(),
++ CommitMsg: m.CommitMsg.ToModelRoleConfigSchema(),
++ ExecStatus: m.ExecStatus.ToModelRoleConfigSchema(),
++ }
++}
++
type ModelOverrides struct {
MaxConvoTokens *int `json:"maxConvoTokens"`
MaxTokens *int `json:"maxContextTokens"`