Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
wip: model refactor/json input
Dane Schneider5af468ab3605
diff --git a/app/cli/cmd/model_packs.go b/app/cli/cmd/model_packs.goindex 6035fb63..cbb44b23 100644--- a/app/cli/cmd/model_packs.go+++ b/app/cli/cmd/model_packs.go@@ -5,7 +5,6 @@ import ("os""plandex-cli/api""plandex-cli/auth"- "plandex-cli/lib""plandex-cli/term""strconv"@@ -209,36 +208,36 @@ func createModelPack(cmd *cobra.Command, args []string) {}mp.Description = description- term.StartSpinner("")- customModels, apiErr := api.Client.ListCustomModels()- term.StopSpinner()+ // term.StartSpinner("")+ // customModels, apiErr := api.Client.ListCustomModels()+ // term.StopSpinner()- if apiErr != nil {- term.OutputErrorAndExit("Error fetching models: %v", apiErr)- }+ // if apiErr != nil {+ // term.OutputErrorAndExit("Error fetching models: %v", apiErr)+ // }// Selecting models for each role- mp.Planner = getPlannerRoleConfig(customModels)+ // mp.Planner = getPlannerRoleConfig(customModels)- contextLoader := getModelRoleConfig(customModels, shared.ModelRoleArchitect)- mp.Architect = &contextLoader+ // contextLoader := getModelRoleConfig(customModels, shared.ModelRoleArchitect)+ // mp.Architect = &contextLoader- coder := getModelRoleConfig(customModels, shared.ModelRoleCoder)- mp.Coder = &coder+ // coder := getModelRoleConfig(customModels, shared.ModelRoleCoder)+ // mp.Coder = &coder- mp.Builder = getModelRoleConfig(customModels, shared.ModelRoleBuilder)+ // mp.Builder = getModelRoleConfig(customModels, shared.ModelRoleBuilder)- wholeFileBuilder := getModelRoleConfig(customModels, shared.ModelRoleWholeFileBuilder)- mp.WholeFileBuilder = &wholeFileBuilder+ // wholeFileBuilder := getModelRoleConfig(customModels, shared.ModelRoleWholeFileBuilder)+ // mp.WholeFileBuilder = &wholeFileBuilder- mp.Namer = getModelRoleConfig(customModels, shared.ModelRoleName)- mp.CommitMsg = getModelRoleConfig(customModels, shared.ModelRoleCommitMsg)+ // mp.Namer = getModelRoleConfig(customModels, shared.ModelRoleName)+ // mp.CommitMsg = getModelRoleConfig(customModels, shared.ModelRoleCommitMsg)- mp.PlanSummary = getModelRoleConfig(customModels, shared.ModelRolePlanSummary)- mp.ExecStatus = getModelRoleConfig(customModels, shared.ModelRoleExecStatus)+ // mp.PlanSummary = getModelRoleConfig(customModels, shared.ModelRolePlanSummary)+ // mp.ExecStatus = getModelRoleConfig(customModels, shared.ModelRoleExecStatus)term.StartSpinner("")- apiErr = api.Client.CreateModelPack(mp)+ apiErr := api.Client.CreateModelPack(mp)term.StopSpinner()if apiErr != nil {@@ -270,11 +269,11 @@ func updateModelPack(cmd *cobra.Command, args []string) {return}- customModels, apiErr := api.Client.ListCustomModels()- term.StopSpinner()- if apiErr != nil {- term.OutputErrorAndExit("Error fetching models: %v", apiErr)- }+ // customModels, apiErr := api.Client.ListCustomModels()+ // term.StopSpinner()+ // if apiErr != nil {+ // term.OutputErrorAndExit("Error fetching models: %v", apiErr)+ // }var toUpdate *shared.ModelPack@@ -307,7 +306,7 @@ func updateModelPack(cmd *cobra.Command, args []string) {return}- var role shared.ModelRole+ // var role shared.ModelRoleroleOpts := make([]string, len(shared.AllModelRoles))for i, role := range shared.AllModelRoles {@@ -316,52 +315,52 @@ func updateModelPack(cmd *cobra.Command, args []string) {renderModelPack(toUpdate, allProperties)- for {- selected, err := term.SelectFromList("Select a role to update:", roleOpts)- if err != nil {- term.OutputErrorAndExit("Error selecting role: %v", err)- }-- role = shared.ModelRole(selected)-- switch role {- case shared.ModelRolePlanner:- toUpdate.Planner = getPlannerRoleConfig(customModels)- case shared.ModelRoleArchitect:- contextLoader := getModelRoleConfig(customModels, shared.ModelRoleArchitect)- toUpdate.Architect = &contextLoader- case shared.ModelRoleCoder:- coder := getModelRoleConfig(customModels, shared.ModelRoleCoder)- toUpdate.Coder = &coder- case shared.ModelRoleBuilder:- builder := getModelRoleConfig(customModels, shared.ModelRoleBuilder)- toUpdate.Builder = builder- case shared.ModelRoleWholeFileBuilder:- wholeFileBuilder := getModelRoleConfig(customModels, shared.ModelRoleWholeFileBuilder)- toUpdate.WholeFileBuilder = &wholeFileBuilder- case shared.ModelRolePlanSummary:- toUpdate.PlanSummary = getModelRoleConfig(customModels, role)- case shared.ModelRoleExecStatus:- toUpdate.ExecStatus = getModelRoleConfig(customModels, role)- case shared.ModelRoleCommitMsg:- toUpdate.CommitMsg = getModelRoleConfig(customModels, role)- case shared.ModelRoleName:- toUpdate.Namer = getModelRoleConfig(customModels, role)- }-- updateOpt := "Update another role"- saveOpt := "Save model pack and exit"- opts := []string{updateOpt, saveOpt}-- selected, err = term.SelectFromList("Finished editing?", opts)- if err != nil {- term.OutputErrorAndExit("Error selecting option: %v", err)- }-- if selected == saveOpt {- break- }- }+ // for {+ // selected, err := term.SelectFromList("Select a role to update:", roleOpts)+ // if err != nil {+ // term.OutputErrorAndExit("Error selecting role: %v", err)+ // }++ // role = shared.ModelRole(selected)++ // switch role {+ // case shared.ModelRolePlanner:+ // toUpdate.Planner = getPlannerRoleConfig(customModels)+ // case shared.ModelRoleArchitect:+ // contextLoader := getModelRoleConfig(customModels, shared.ModelRoleArchitect)+ // toUpdate.Architect = &contextLoader+ // case shared.ModelRoleCoder:+ // coder := getModelRoleConfig(customModels, shared.ModelRoleCoder)+ // toUpdate.Coder = &coder+ // case shared.ModelRoleBuilder:+ // builder := getModelRoleConfig(customModels, shared.ModelRoleBuilder)+ // toUpdate.Builder = builder+ // case shared.ModelRoleWholeFileBuilder:+ // wholeFileBuilder := getModelRoleConfig(customModels, shared.ModelRoleWholeFileBuilder)+ // toUpdate.WholeFileBuilder = &wholeFileBuilder+ // case shared.ModelRolePlanSummary:+ // toUpdate.PlanSummary = getModelRoleConfig(customModels, role)+ // case shared.ModelRoleExecStatus:+ // toUpdate.ExecStatus = getModelRoleConfig(customModels, role)+ // case shared.ModelRoleCommitMsg:+ // toUpdate.CommitMsg = getModelRoleConfig(customModels, role)+ // case shared.ModelRoleName:+ // toUpdate.Namer = getModelRoleConfig(customModels, role)+ // }++ // updateOpt := "Update another role"+ // saveOpt := "Save model pack and exit"+ // opts := []string{updateOpt, saveOpt}++ // selected, err = term.SelectFromList("Finished editing?", opts)+ // if err != nil {+ // term.OutputErrorAndExit("Error selecting option: %v", err)+ // }++ // if selected == saveOpt {+ // break+ // }+ // }term.StartSpinner("")apiErr = api.Client.UpdateModelPack(toUpdate)@@ -438,67 +437,67 @@ func showModelPack(cmd *cobra.Command, args []string) {term.PrintCmds("", "model-packs update", "model-packs delete", "set-model", "set-model default")}-func getModelRoleConfig(customModels []*shared.CustomModel, modelRole shared.ModelRole) shared.ModelRoleConfig {- _, modelConfig := getModelWithRoleConfig(customModels, modelRole)- return modelConfig-}--func getModelWithRoleConfig(customModels []*shared.CustomModel, modelRole shared.ModelRole) (*shared.CustomModel, shared.ModelRoleConfig) {- role := string(modelRole)-- model := getModelForRole(customModels, modelRole)-- temperatureStr, err := term.GetUserStringInputWithDefault("Temperature for "+role+":", fmt.Sprintf("%.1f", shared.DefaultConfigByRole[modelRole].Temperature))- if err != nil {- term.OutputErrorAndExit("Error reading temperature: %v", err)- }- temperature, err := strconv.ParseFloat(temperatureStr, 32)- if err != nil {- term.OutputErrorAndExit("Invalid number for temperature: %v", err)- }-- topPStr, err := term.GetUserStringInputWithDefault("Top P for "+role+":", fmt.Sprintf("%.1f", shared.DefaultConfigByRole[modelRole].TopP))- if err != nil {- term.OutputErrorAndExit("Error reading top P: %v", err)- }- topP, err := strconv.ParseFloat(topPStr, 32)- if err != nil {- term.OutputErrorAndExit("Invalid number for top P: %v", err)- }-- var reservedOutputTokens int- if modelRole == shared.ModelRoleBuilder || modelRole == shared.ModelRolePlanner || modelRole == shared.ModelRoleWholeFileBuilder {- reservedOutputTokensStr, err := term.GetUserStringInputWithDefault("Reserved output tokens for "+role+":", fmt.Sprintf("%d", model.ReservedOutputTokens))- if err != nil {- term.OutputErrorAndExit("Error reading reserved output tokens: %v", err)- }- reservedOutputTokens, err = strconv.Atoi(reservedOutputTokensStr)- if err != nil {- term.OutputErrorAndExit("Invalid number for reserved output tokens: %v", err)- }- }-- return model, shared.ModelRoleConfig{- ModelId: model.ModelId,- Role: modelRole,- Temperature: float32(temperature),- TopP: float32(topP),- ReservedOutputTokens: reservedOutputTokens,- }-}--func getPlannerRoleConfig(customModels []*shared.CustomModel) shared.PlannerRoleConfig {- model, modelConfig := getModelWithRoleConfig(customModels, shared.ModelRolePlanner)-- return shared.PlannerRoleConfig{- ModelRoleConfig: modelConfig,- PlannerModelConfig: shared.PlannerModelConfig{- MaxConvoTokens: model.DefaultMaxConvoTokens,- },- }-}--func getModelForRole(customModels []*shared.CustomModel, role shared.ModelRole) *shared.CustomModel {- color.New(color.Bold).Printf("Select a model for the %s role π\n", role)- return lib.SelectModelForRole(customModels, role, false)-}+// func getModelRoleConfig(customModels []*shared.CustomModel, modelRole shared.ModelRole) shared.ModelRoleConfig {+// _, modelConfig := getModelWithRoleConfig(customModels, modelRole)+// return modelConfig+// }++// func getModelWithRoleConfig(customModels []*shared.CustomModel, modelRole shared.ModelRole) (*shared.CustomModel, shared.ModelRoleConfig) {+// role := string(modelRole)++// modelId := getModelIdForRole(customModels, modelRole)++// temperatureStr, err := term.GetUserStringInputWithDefault("Temperature for "+role+":", fmt.Sprintf("%.1f", shared.DefaultConfigByRole[modelRole].Temperature))+// if err != nil {+// term.OutputErrorAndExit("Error reading temperature: %v", err)+// }+// temperature, err := strconv.ParseFloat(temperatureStr, 32)+// if err != nil {+// term.OutputErrorAndExit("Invalid number for temperature: %v", err)+// }++// topPStr, err := term.GetUserStringInputWithDefault("Top P for "+role+":", fmt.Sprintf("%.1f", shared.DefaultConfigByRole[modelRole].TopP))+// if err != nil {+// term.OutputErrorAndExit("Error reading top P: %v", err)+// }+// topP, err := strconv.ParseFloat(topPStr, 32)+// if err != nil {+// term.OutputErrorAndExit("Invalid number for top P: %v", err)+// }++// var reservedOutputTokens int+// if modelRole == shared.ModelRoleBuilder || modelRole == shared.ModelRolePlanner || modelRole == shared.ModelRoleWholeFileBuilder {+// reservedOutputTokensStr, err := term.GetUserStringInputWithDefault("Reserved output tokens for "+role+":", fmt.Sprintf("%d", model.ReservedOutputTokens))+// if err != nil {+// term.OutputErrorAndExit("Error reading reserved output tokens: %v", err)+// }+// reservedOutputTokens, err = strconv.Atoi(reservedOutputTokensStr)+// if err != nil {+// term.OutputErrorAndExit("Invalid number for reserved output tokens: %v", err)+// }+// }++// return model, shared.ModelRoleConfig{+// ModelId: model.ModelId,+// Role: modelRole,+// Temperature: float32(temperature),+// TopP: float32(topP),+// ReservedOutputTokens: reservedOutputTokens,+// }+// }++// func getPlannerRoleConfig(customModels []*shared.CustomModel) shared.PlannerRoleConfig {+// model, modelConfig := getModelWithRoleConfig(customModels, shared.ModelRolePlanner)++// return shared.PlannerRoleConfig{+// ModelRoleConfig: modelConfig,+// PlannerModelConfig: shared.PlannerModelConfig{+// MaxConvoTokens: model.DefaultMaxConvoTokens,+// },+// }+// }++// func getModelIdForRole(customModels []*shared.CustomModel, role shared.ModelRole) shared.ModelId {+// color.New(color.Bold).Printf("Select a model for the %s role π\n", role)+// return lib.SelectModelIdForRole(customModels, role)+// }diff --git a/app/cli/cmd/model_providers.go b/app/cli/cmd/model_providers.goindex 878554d7..6bc20aaf 100644--- a/app/cli/cmd/model_providers.go+++ b/app/cli/cmd/model_providers.go@@ -17,16 +17,12 @@ import ("github.com/spf13/cobra")+var customProvidersOnly bool+var providersCmd = &cobra.Command{Use: "providers",- Short: "Manage custom model providers",-}--var listProvidersCmd = &cobra.Command{- Use: "list",- Aliases: []string{"ls"},- Short: "List custom model providers",- Run: listProviders,+ Short: "List built-in and custom model providers",+ Run: listProviders,}var addProviderCmd = &cobra.Command{@@ -53,7 +49,7 @@ var updateProviderCmd = &cobra.Command{func init() {RootCmd.AddCommand(providersCmd)- providersCmd.AddCommand(listProvidersCmd)+ providersCmd.Flags().BoolVarP(&customProvidersOnly, "custom", "c", false, "List custom providers only")providersCmd.AddCommand(addProviderCmd)providersCmd.AddCommand(showProviderCmd)providersCmd.AddCommand(updateProviderCmd)@@ -62,40 +58,103 @@ func init() {func listProviders(cmd *cobra.Command, args []string) {auth.MustResolveAuthWithOrg()- term.StartSpinner("")- providers, apiErr := api.Client.ListCustomProviders()- term.StopSpinner()- if apiErr != nil {- term.OutputErrorAndExit("Error fetching providers: %v", apiErr.Msg)+ var customProviders []*shared.CustomProvider+ var apiErr *shared.ApiError++ if customProvidersOnly && auth.Current.IsCloud {+ term.OutputErrorAndExit("Custom providers are not supported on Plandex Cloud")return}- if len(providers) == 0 {+ if !auth.Current.IsCloud {+ term.StartSpinner("")+ customProviders, apiErr = api.Client.ListCustomProviders()+ term.StopSpinner()+ if apiErr != nil {+ term.OutputErrorAndExit("Error fetching providers: %v", apiErr.Msg)+ return+ }+ }++ if customProvidersOnly && len(customProviders) == 0 {fmt.Println("π€·ββοΈ No custom providers")fmt.Println()term.PrintCmds("", "providers add")return}+ color.New(color.Bold, term.ColorHiCyan).Println("π Built-in Providers")table := tablewriter.NewWriter(os.Stdout)- table.SetHeader([]string{"#", "Name", "Base URL", "Skip Auth", "API Key Env Var"})- for i, p := range providers {+ table.SetAutoWrapText(true)+ table.SetHeader([]string{"ID", "Base URL", "API Key", "Other Vars"})+ for _, p := range shared.AllModelProviders {+ if p == shared.ModelProviderCustom {+ continue+ }+ config := shared.BuiltInModelProviderConfigs[p]+ if config.LocalOnly && auth.Current.IsCloud {+ continue+ }+ var apiKey string+ if config.ApiKeyEnvVar != "" {+ apiKey = config.ApiKeyEnvVar+ } else if config.SkipAuth {+ apiKey = "No Auth"+ }++ extraVars := []string{}+ for _, v := range config.ExtraAuthVars {+ extraVars = append(extraVars, v.Var)+ }+table.Append([]string{- strconv.Itoa(i + 1),- p.Name,- p.BaseUrl,- fmt.Sprintf("%v", p.SkipAuth),- p.ApiKeyEnvVar,+ string(p),+ config.BaseUrl,+ apiKey,+ strings.Join(extraVars, "\n"),})}table.Render()fmt.Println()++ if len(customProviders) > 0 {+ color.New(color.Bold, term.ColorHiCyan).Println("π οΈ Custom Providers")+ table := tablewriter.NewWriter(os.Stdout)+ table.SetAutoWrapText(false)+ table.SetHeader([]string{"#", "Name", "Base URL", "API Key", "Other Vars"})+ for i, p := range customProviders {+ extraVars := []string{}+ for _, v := range p.ExtraAuthVars {+ extraVars = append(extraVars, v.Var)+ }+ apiKey := p.ApiKeyEnvVar+ if apiKey == "" && p.SkipAuth {+ apiKey = "No Auth"+ }++ table.Append([]string{+ strconv.Itoa(i + 1),+ p.Name,+ p.BaseUrl,+ apiKey,+ strings.Join(extraVars, "\n"),+ })+ }+ table.Render()+ fmt.Println()+ }+term.PrintCmds("", "providers show", "providers update", "providers add")}func addProvider(cmd *cobra.Command, args []string) {auth.MustResolveAuthWithOrg()+ if auth.Current.IsCloud {+ term.OutputErrorAndExit("Custom providers are not supported on Plandex Cloud")+ return+ }+name, err := term.GetRequiredUserStringInput("Provider name:")if err != nil {term.OutputErrorAndExit("Error reading name: %v", err)diff --git a/app/cli/cmd/models.go b/app/cli/cmd/models.goindex 0ad4f3ad..d3c28bce 100644--- a/app/cli/cmd/models.go+++ b/app/cli/cmd/models.go@@ -1,14 +1,15 @@package cmdimport (+ "encoding/json""fmt""os"+"plandex-cli/api""plandex-cli/auth""plandex-cli/lib""plandex-cli/term""strconv"- "strings"shared "plandex-shared"@@ -20,6 +21,7 @@ import (var customModelsOnly boolvar allProperties bool+var jsonFile stringfunc init() {RootCmd.AddCommand(modelsCmd)@@ -31,6 +33,8 @@ func init() {modelsCmd.AddCommand(deleteCustomModelCmd)modelsCmd.AddCommand(defaultModelsCmd)+ createCustomModelCmd.Flags().StringVar(&jsonFile, "json", "", "Path to a JSON file containing model configuration")+listAvailableModelsCmd.Flags().BoolVarP(&customModelsOnly, "custom", "c", false, "List custom models only")}@@ -71,216 +75,220 @@ var deleteCustomModelCmd = &cobra.Command{func createCustomModel(cmd *cobra.Command, args []string) {auth.MustResolveAuthWithOrg()- model := &shared.AvailableModel{- BaseModelConfig: shared.BaseModelConfig{+ var model *shared.CustomModel++ if jsonFile != "" {+ // Load model from JSON file+ jsonData, err := os.ReadFile(jsonFile)+ if err != nil {+ term.OutputErrorAndExit("Error reading JSON file: %v", err)+ return+ }++ // Parse JSON into a map+ var jsonMap map[string]interface{}+ if err := json.Unmarshal(jsonData, &jsonMap); err != nil {+ term.OutputErrorAndExit("Error parsing JSON: %v", err)+ return+ }++ // Convert to CustomModel+ model = &shared.CustomModel{BaseModelShared: shared.BaseModelShared{ModelCompatibility: shared.ModelCompatibility{},},- },- }+ }- 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)- }+ // Extract required fields+ if modelId, ok := jsonMap["modelId"].(string); ok {+ model.ModelId = shared.ModelId(modelId)+ } else {+ term.OutputErrorAndExit("Missing or invalid 'modelId' in JSON")+ return}- 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)+ // Extract optional fields+ if description, ok := jsonMap["description"].(string); ok {+ model.Description = description+ }- if model.Provider == shared.ModelProviderCustom {- if auth.Current.IsCloud {- term.OutputErrorAndExit("Custom model providers are not supported on Plandex Cloud")+ // Extract numeric fields+ if maxTokens, ok := jsonMap["maxTokens"].(float64); ok {+ model.MaxTokens = int(maxTokens)+ } else {+ term.OutputErrorAndExit("Missing or invalid 'maxTokens' in JSON")return}- customProvider, err := term.GetRequiredUserStringInput("Custom provider:")- if err != nil {- term.OutputErrorAndExit("Error reading custom provider: %v", err)++ if maxConvoTokens, ok := jsonMap["defaultMaxConvoTokens"].(float64); ok {+ model.DefaultMaxConvoTokens = int(maxConvoTokens)+ } else {+ term.OutputErrorAndExit("Missing or invalid 'defaultMaxConvoTokens' in JSON")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)-- 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)- 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-- if model.Provider == shared.ModelProviderCustom {- baseUrl, err := term.GetRequiredUserStringInput("Base URL:")- if err != nil {- term.OutputErrorAndExit("Error reading base URL: %v", err)+ if maxOutputTokens, ok := jsonMap["maxOutputTokens"].(float64); ok {+ model.MaxOutputTokens = int(maxOutputTokens)+ } else {+ term.OutputErrorAndExit("Missing or invalid 'maxOutputTokens' in JSON")return}- baseUrl = strings.TrimSuffix(baseUrl, "/")-- model.BaseUrl = baseUrl- } else {- providerConfig, ok := shared.BuiltInModelProviderConfigs[model.Provider]- if !ok {- term.OutputErrorAndExit("Error getting provider config: %v", err)+ if reservedOutputTokens, ok := jsonMap["reservedOutputTokens"].(float64); ok {+ model.ReservedOutputTokens = int(reservedOutputTokens)+ } else {+ term.OutputErrorAndExit("Missing or invalid 'reservedOutputTokens' in JSON")return}- model.BaseUrl = providerConfig.BaseUrl- }+ // Extract output format+ if outputFormat, ok := jsonMap["preferredOutputFormat"].(string); ok {+ model.PreferredOutputFormat = shared.ModelOutputFormat(outputFormat)+ } else {+ term.OutputErrorAndExit("Missing or invalid 'preferredOutputFormat' in JSON")+ return+ }- var apiKeyEnvVar string- if model.Provider == shared.ModelProviderCustom {- apiKeyEnvVar, err = term.GetRequiredUserStringInput("API key environment variable:")+ // Extract image support+ if hasImageSupport, ok := jsonMap["hasImageSupport"].(bool); ok {+ model.HasImageSupport = hasImageSupport+ } else {+ // Default to false if not specified+ model.HasImageSupport = false+ }} else {- providerConfig, ok := shared.BuiltInModelProviderConfigs[model.Provider]- if !ok {- term.OutputErrorAndExit("Error getting provider config: %v", err)+ // Interactive mode+ model = &shared.CustomModel{+ BaseModelShared: shared.BaseModelShared{+ ModelCompatibility: shared.ModelCompatibility{},+ },+ }++ fmt.Println("For model id, use something like 'openai/gpt-4.1' that uniquely identifies the model. This doesn't need to match the model name for any particular provider (this is set when you add providers for the model).")+ modelId, err := term.GetRequiredUserStringInput("Model id:")+ if err != nil {+ term.OutputErrorAndExit("Error reading model id: %v", err)return}- apiKeyEnvVar = providerConfig.ApiKeyEnvVar- }+ model.ModelId = shared.ModelId(modelId)- if err != nil {- term.OutputErrorAndExit("Error reading API key environment variable: %v", err)- return- }- model.ApiKeyEnvVar = apiKeyEnvVar+ 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- fmt.Println("Max Tokens is the total maximum context size of the model.")+ fmt.Println("Max Tokens is the total maximum context size of the model.")- 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- }- model.MaxTokens = maxTokens+ 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+ }+ model.MaxTokens = maxTokens- 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.")+ 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.")- var defaultMaxConvoTokens int+ var defaultMaxConvoTokens int- if maxTokens >= 180000 {- defaultMaxConvoTokens = 15000- } else if maxTokens >= 100000 {- defaultMaxConvoTokens = 10000- }+ if maxTokens >= 180000 {+ defaultMaxConvoTokens = 15000+ } else if maxTokens >= 100000 {+ defaultMaxConvoTokens = 10000+ }- 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))- }+ 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 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+ 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'.")+ 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'.")- 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+ 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- 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("'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.")- var defaultReservedOutputTokens int- if maxOutputTokens <= int(float64(maxTokens)*0.2) {- defaultReservedOutputTokens = maxOutputTokens- }+ var defaultReservedOutputTokens int+ if maxOutputTokens <= int(float64(maxTokens)*0.2) {+ defaultReservedOutputTokens = maxOutputTokens+ }- 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))- }+ 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))+ }- if err != nil {- term.OutputErrorAndExit("Error reading reserved output tokens: %v", err)- return- }+ if err != nil {+ term.OutputErrorAndExit("Error reading reserved output tokens: %v", err)+ return+ }- reservedOutputTokens, err := strconv.Atoi(reservedOutputTokensStr)- if err != nil {- term.OutputErrorAndExit("Invalid number for reserved output tokens: %v", err)- return- }- model.ReservedOutputTokens = reservedOutputTokens+ reservedOutputTokens, err := strconv.Atoi(reservedOutputTokensStr)+ if err != nil {+ term.OutputErrorAndExit("Invalid number for reserved output tokens: %v", err)+ 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.")+ 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",- }+ outputFormatLabels := map[string]string{+ string(shared.ModelOutputFormatXml): "XML",+ string(shared.ModelOutputFormatToolCallJson): "Tool Call JSON",+ }- 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)- return- }- for key, label := range outputFormatLabels {- if label == res {- model.PreferredOutputFormat = shared.ModelOutputFormat(key)- break+ 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)+ return+ }+ for key, label := range outputFormatLabels {+ if label == res {+ model.PreferredOutputFormat = 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+ model.HasImageSupport, err = term.ConfirmYesNo("Is multi-modal image support enabled?")+ if err != nil {+ term.OutputErrorAndExit("Error confirming image support: %v", err)+ return+ }}term.StartSpinner("")@@ -292,7 +300,7 @@ func createCustomModel(cmd *cobra.Command, args []string) {return}- fmt.Println("β Added custom model", color.New(color.Bold, term.ColorHiCyan).Sprint(string(model.Provider)+" β "+string(model.ModelId)))+ fmt.Println("β Added custom model", color.New(color.Bold, term.ColorHiCyan).Sprint(string(model.ModelId)))}func models(cmd *cobra.Command, args []string) {@@ -377,10 +385,8 @@ func listAvailableModels(cmd *cobra.Command, args []string) {table := tablewriter.NewWriter(os.Stdout)table.SetAutoWrapText(false)table.SetHeader([]string{"Model", "Input", "Output", "Reserved"})- for _, modelId := range shared.BaseModelIds {- model := shared.BuiltInBaseModelsById[modelId]-- table.Append([]string{string(modelId), fmt.Sprintf("%d πͺ", model.MaxTokens), fmt.Sprintf("%d πͺ", model.MaxOutputTokens), fmt.Sprintf("%d πͺ", model.ReservedOutputTokens)})+ for _, model := range shared.BuiltInBaseModels {+ table.Append([]string{string(model.ModelId), fmt.Sprintf("%d πͺ", model.MaxTokens), fmt.Sprintf("%d πͺ", model.MaxOutputTokens), fmt.Sprintf("%d πͺ", model.ReservedOutputTokens)})}table.Render()fmt.Println()@@ -390,17 +396,9 @@ func listAvailableModels(cmd *cobra.Command, args []string) {color.New(color.Bold, term.ColorHiCyan).Println("π οΈ Custom Models")table := tablewriter.NewWriter(os.Stdout)table.SetAutoWrapText(false)- table.SetHeader([]string{"#", "Provider", "Name", "πͺ", "π"})+ table.SetHeader([]string{"#", "ID", "πͺ"})for i, model := range customModels {- var provider string- p := model.Provider- if p == shared.ModelProviderCustom {- provider = *model.CustomProvider- } else {- provider = string(p)- }-- table.Append([]string{fmt.Sprintf("%d", i+1), provider, string(model.ModelId), strconv.Itoa(model.MaxTokens), model.ApiKeyEnvVar})+ table.Append([]string{fmt.Sprintf("%d", i+1), string(model.ModelId), strconv.Itoa(model.MaxTokens)})}table.Render()} else if customModelsOnly {@@ -438,7 +436,7 @@ func deleteCustomModel(cmd *cobra.Command, args []string) {return}- var modelToDelete *shared.AvailableModel+ var modelToDelete *shared.CustomModelif len(args) == 1 {input := args[0]@@ -460,14 +458,7 @@ func deleteCustomModel(cmd *cobra.Command, args []string) {if modelToDelete == nil {opts := make([]string, len(models))for i, model := range models {- var provider string- p := model.Provider- if p == shared.ModelProviderCustom {- provider = *model.CustomProvider- } else {- provider = string(p)- }- opts[i] = provider + " β " + string(model.ModelId)+ opts[i] = string(model.ModelId)}selected, err := term.SelectFromList("Select model to delete:", opts)@@ -489,7 +480,7 @@ func deleteCustomModel(cmd *cobra.Command, args []string) {}term.StartSpinner("")- apiErr = api.Client.DeleteAvailableModel(modelToDelete.Id)+ apiErr = api.Client.DeleteCustomModel(modelToDelete.Id)term.StopSpinner()if apiErr != nil {@@ -497,7 +488,7 @@ func deleteCustomModel(cmd *cobra.Command, args []string) {return}- fmt.Printf("β Deleted custom model %s\n", color.New(color.Bold, term.ColorHiCyan).Sprint(string(modelToDelete.Provider)+" β "+string(modelToDelete.ModelId)))+ fmt.Printf("β Deleted custom model %s\n", color.New(color.Bold, term.ColorHiCyan).Sprint(string(modelToDelete.ModelId)))fmt.Println()term.PrintCmds("", "models available", "models add")@@ -516,7 +507,7 @@ func renderSettings(settings *shared.PlanSettings, allProperties bool) {table.SetHeader([]string{"Max Tokens", "Max Convo Tokens"})table.Append([]string{fmt.Sprintf("%d", modelPack.Planner.GetFinalLargeContextFallback().GetSharedBaseConfig().MaxTokens),- fmt.Sprintf("%d", modelPack.Planner.MaxConvoTokens),+ fmt.Sprintf("%d", modelPack.Planner.GetMaxConvoTokens()),})table.Render()fmt.Println()@@ -578,7 +569,15 @@ func renderModelPack(modelPack *shared.ModelPack, allProperties bool) {anyRoleParamsDisabled := false- addModelRow := func(role string, config shared.ModelRoleConfig) {+ var addModelRow func(role string, config shared.ModelRoleConfig, indent int)+ addModelRow = func(role string, config shared.ModelRoleConfig, indent int) {+ if indent > 0 {+ role = "ββ " + role+ for i := 0; i < indent-1; i++ {+ role = " " + role+ }+ }+var temp float32var topP float32var disabled bool@@ -605,7 +604,7 @@ func renderModelPack(modelPack *shared.ModelPack, allProperties bool) {row := []string{role,- string(config.ModelId),+ string(config.GetModelId()),}if allProperties {@@ -618,164 +617,33 @@ func renderModelPack(modelPack *shared.ModelPack, allProperties bool) {table.Append(row)// Add large context and large output fallback(s) if present-if config.LargeContextFallback != nil {- if config.LargeContextFallback.GetSharedBaseConfig().RoleParamsDisabled {- temp = 1- topP = 1- disabled = true- anyRoleParamsDisabled = true- } else {- temp = config.LargeContextFallback.Temperature- topP = config.LargeContextFallback.TopP- }-- tempStr := fmt.Sprintf("%.1f", temp)- if disabled {- tempStr = "*" + tempStr- }-- topPStr := fmt.Sprintf("%.1f", topP)- if disabled {- topPStr = "*" + topPStr- }-- row = []string{- "ββ large-context",- string(config.LargeContextFallback.ModelId),- }- if allProperties {- row = append(row, []string{- tempStr,- topPStr,- fmt.Sprintf("%d πͺ", config.LargeContextFallback.GetSharedBaseConfig().MaxTokens-config.LargeContextFallback.GetReservedOutputTokens()),- }...)- }-- table.Append(row)+ addModelRow("large-context", *config.LargeContextFallback, indent+1)}if config.LargeOutputFallback != nil {- if config.LargeOutputFallback.GetSharedBaseConfig().RoleParamsDisabled {- temp = 1- topP = 1- disabled = true- anyRoleParamsDisabled = true- } else {- temp = config.LargeOutputFallback.Temperature- topP = config.LargeOutputFallback.TopP- }-- tempStr := fmt.Sprintf("%.1f", temp)- if disabled {- tempStr = "*" + tempStr- }-- topPStr := fmt.Sprintf("%.1f", topP)- if disabled {- topPStr = "*" + topPStr- }-- row := []string{- "ββ large-output",- string(config.LargeOutputFallback.ModelId),- }- if allProperties {- row = append(row, []string{- tempStr,- topPStr,- fmt.Sprintf("%d πͺ", config.LargeOutputFallback.GetSharedBaseConfig().MaxTokens-config.LargeOutputFallback.GetReservedOutputTokens()),- }...)- }- table.Append(row)+ addModelRow("large-output", *config.LargeOutputFallback, indent+1)}- }-- // Handle planner separately since it has a different fallback structure- var temp float32- var topP float32- var disabled bool-- if modelPack.Planner.GetSharedBaseConfig().RoleParamsDisabled {- temp = 1- topP = 1- disabled = true- anyRoleParamsDisabled = true- } else {- temp = modelPack.Planner.Temperature- topP = modelPack.Planner.TopP- }-- tempStr := fmt.Sprintf("%.1f", temp)- if disabled {- tempStr = "*" + tempStr- }- topPStr := fmt.Sprintf("%.1f", topP)- if disabled {- topPStr = "*" + topPStr- }-- row := []string{- string(shared.ModelRolePlanner),- string(modelPack.Planner.ModelId),- }- if allProperties {- row = append(row, []string{- tempStr,- topPStr,- fmt.Sprintf("%d πͺ", modelPack.Planner.GetSharedBaseConfig().MaxTokens-modelPack.Planner.GetReservedOutputTokens()),- }...)- }- table.Append(row)-- if modelPack.Planner.LargeContextFallback != nil {- var temp float32- var topP float32- var disabled bool-- if modelPack.Planner.LargeContextFallback.GetSharedBaseConfig().RoleParamsDisabled {- temp = 1- topP = 1- disabled = true- anyRoleParamsDisabled = true- } else {- temp = modelPack.Planner.LargeContextFallback.Temperature- topP = modelPack.Planner.LargeContextFallback.TopP+ if config.StrongModel != nil {+ addModelRow("strong", *config.StrongModel, indent+1)}- tempStr := fmt.Sprintf("%.1f", temp)- if disabled {- tempStr = "*" + tempStr+ if config.ErrorFallback != nil {+ addModelRow("error", *config.ErrorFallback, indent+1)}-- topPStr := fmt.Sprintf("%.1f", topP)- if disabled {- topPStr = "*" + topPStr- }-- row := []string{- "ββ large-context",- string(modelPack.Planner.LargeContextFallback.ModelId),- }- if allProperties {- row = append(row, []string{- tempStr,- topPStr,- fmt.Sprintf("%d πͺ", modelPack.Planner.LargeContextFallback.GetSharedBaseConfig().MaxTokens-modelPack.Planner.LargeContextFallback.GetReservedOutputTokens()),- }...)- }- table.Append(row)}- 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)+ addModelRow(string(shared.ModelRolePlanner), modelPack.Planner.ModelRoleConfig, 0)++ 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()if anyRoleParamsDisabled && allProperties {diff --git a/app/cli/cmd/schema_validation.go b/app/cli/cmd/schema_validation.goindex ce9d6497..4a9e802b 100644--- a/app/cli/cmd/schema_validation.go+++ b/app/cli/cmd/schema_validation.go@@ -23,8 +23,8 @@ type embeddedSchemaLoader struct {}// newEmbeddedSchemaLoader creates a new loader for embedded schemas-func newEmbeddedSchemaLoader(source string) *embeddedSchemaLoader {- return &embeddedSchemaLoader{+func newEmbeddedSchemaLoader(source string) embeddedSchemaLoader {+ return embeddedSchemaLoader{source: source,fs: schemaFS,}@@ -205,7 +205,7 @@ func ValidateModelConfigJSON(jsonFilePath string) (*shared.CustomModel, error) {}if tokenEstimatePaddingPct, ok := jsonMap["tokenEstimatePaddingPct"].(float64); ok {- model.TokenEstimatePaddingPct = float32(tokenEstimatePaddingPct)+ model.TokenEstimatePaddingPct = tokenEstimatePaddingPct}if reasoningBudget, ok := jsonMap["reasoningBudget"].(float64); ok {diff --git a/app/cli/cmd/set_model.go b/app/cli/cmd/set_model.goindex 3f71ef6a..244ce9ad 100644--- a/app/cli/cmd/set_model.go+++ b/app/cli/cmd/set_model.go@@ -130,7 +130,7 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings) *var role shared.ModelRolevar settingCompact stringvar settingDasherized string- var selectedModel *shared.AvailableModel+ var selectedModelId shared.ModelIdvar temperature *float64var topP *float64var reservedOutputTokens *int@@ -320,28 +320,31 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings) *term.OutputErrorAndExit("Error fetching models: %v", apiErr)}- customModels = shared.FilterCompatibleModels(customModels, role)- builtInModels := shared.FilterCompatibleModels(shared.AvailableModels, role)+ builtInModels := shared.FilterBuiltInCompatibleModels(shared.BuiltInBaseModels, role)+ customModels = shared.FilterCustomCompatibleModels(customModels, role)- allModels := append(customModels, builtInModels...)+ customModelsById := map[shared.ModelId]*shared.CustomModel{}+ for _, m := range customModels {+ customModelsById[m.ModelId] = m+ }- for _, m := range allModels {- var p string- if m.Provider == shared.ModelProviderCustom {- p = *m.CustomProvider- } else {- p = string(m.Provider)- }- p = strings.ToLower(p)+ modelIds := []shared.ModelId{}+ for _, m := range builtInModels {+ modelIds = append(modelIds, m.ModelId)+ }+ for _, m := range customModels {+ modelIds = append(modelIds, m.ModelId)+ }- if propertyCompact == fmt.Sprintf("%s/%s", p, shared.Compact(string(m.ModelId))) {- selectedModel = m+ for _, id := range modelIds {+ if propertyCompact == fmt.Sprintf("%s/%s", role, shared.Compact(string(id))) {+ selectedModelId = idbreak}}}- if selectedModel == nil && propertyCompact == "" {+ if selectedModelId == "" && propertyCompact == "" {Outer:for {opts := []string{@@ -376,9 +379,9 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings) *term.OutputErrorAndExit("Error fetching models: %v", apiErr)}- selectedModel = lib.SelectModelForRole(customModels, role, true)+ selectedModelId = lib.SelectModelIdForRole(customModels, role)- if selectedModel != nil {+ if selectedModelId != "" {break Outer}} else if selection == "Set temperature" {@@ -394,7 +397,7 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings) *}}- if selectedModel == nil {+ if selectedModelId == "" {if propertyCompact != "" {if value == "" {msg := "Set"@@ -449,11 +452,8 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings) *switch role {case shared.ModelRolePlanner:- if selectedModel != nil {- settings.ModelPack.Planner.BaseModelConfig = &selectedModel.BaseModelConfig- settings.ModelPack.Planner.PlannerModelConfig = shared.PlannerModelConfig{- MaxConvoTokens: selectedModel.DefaultMaxConvoTokens,- }+ if selectedModelId != "" {+ settings.ModelPack.Planner.ModelId = selectedModelId} else if temperature != nil {settings.ModelPack.Planner.Temperature = float32(*temperature)} else if topP != nil {@@ -463,8 +463,8 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings) *}case shared.ModelRoleArchitect:- if selectedModel != nil {- settings.ModelPack.Architect.BaseModelConfig = &selectedModel.BaseModelConfig+ if selectedModelId != "" {+ settings.ModelPack.Architect.ModelId = selectedModelId} else if temperature != nil {settings.ModelPack.Architect.Temperature = float32(*temperature)} else if topP != nil {@@ -472,8 +472,8 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings) *}case shared.ModelRoleCoder:- if selectedModel != nil {- settings.ModelPack.Coder.BaseModelConfig = &selectedModel.BaseModelConfig+ if selectedModelId != "" {+ settings.ModelPack.Coder.ModelId = selectedModelId} else if temperature != nil {settings.ModelPack.Coder.Temperature = float32(*temperature)} else if topP != nil {@@ -481,8 +481,8 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings) *}case shared.ModelRolePlanSummary:- if selectedModel != nil {- settings.ModelPack.PlanSummary.BaseModelConfig = &selectedModel.BaseModelConfig+ if selectedModelId != "" {+ settings.ModelPack.PlanSummary.ModelId = selectedModelId} else if temperature != nil {settings.ModelPack.PlanSummary.Temperature = float32(*temperature)} else if topP != nil {@@ -490,8 +490,8 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings) *}case shared.ModelRoleBuilder:- if selectedModel != nil {- settings.ModelPack.Builder.BaseModelConfig = &selectedModel.BaseModelConfig+ if selectedModelId != "" {+ settings.ModelPack.Builder.ModelId = selectedModelId} else if temperature != nil {settings.ModelPack.Builder.Temperature = float32(*temperature)} else if topP != nil {@@ -499,8 +499,8 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings) *}case shared.ModelRoleWholeFileBuilder:- if selectedModel != nil {- settings.ModelPack.WholeFileBuilder.BaseModelConfig = &selectedModel.BaseModelConfig+ if selectedModelId != "" {+ settings.ModelPack.WholeFileBuilder.ModelId = selectedModelId} else if temperature != nil {settings.ModelPack.WholeFileBuilder.Temperature = float32(*temperature)} else if topP != nil {@@ -508,8 +508,8 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings) *}case shared.ModelRoleName:- if selectedModel != nil {- settings.ModelPack.Namer.BaseModelConfig = &selectedModel.BaseModelConfig+ if selectedModelId != "" {+ settings.ModelPack.Namer.ModelId = selectedModelId} else if temperature != nil {settings.ModelPack.Namer.Temperature = float32(*temperature)} else if topP != nil {@@ -517,8 +517,8 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings) *}case shared.ModelRoleCommitMsg:- if selectedModel != nil {- settings.ModelPack.CommitMsg.BaseModelConfig = &selectedModel.BaseModelConfig+ if selectedModelId != "" {+ settings.ModelPack.CommitMsg.ModelId = selectedModelId} else if temperature != nil {settings.ModelPack.CommitMsg.Temperature = float32(*temperature)} else if topP != nil {@@ -526,8 +526,8 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings) *}case shared.ModelRoleExecStatus:- if selectedModel != nil {- settings.ModelPack.ExecStatus.BaseModelConfig = &selectedModel.BaseModelConfig+ if selectedModelId != "" {+ settings.ModelPack.ExecStatus.ModelId = selectedModelId} else if temperature != nil {settings.ModelPack.ExecStatus.Temperature = float32(*temperature)} else if topP != nil {diff --git a/app/cli/cmd/tell.go b/app/cli/cmd/tell.goindex 7dd1a7fe..66195ce7 100644--- a/app/cli/cmd/tell.go+++ b/app/cli/cmd/tell.go@@ -43,9 +43,9 @@ func doTell(cmd *cobra.Command, args []string) {lib.MustResolveProject()mustSetPlanExecFlags(cmd)- var apiKeys map[string]string+ var authVars map[string]stringif !auth.Current.IntegratedModelsMode {- apiKeys = lib.MustVerifyAuthVars()+ authVars = lib.MustVerifyAuthVars()}if isImplementationOfChat && len(args) > 0 {@@ -76,7 +76,7 @@ func doTell(cmd *cobra.Command, args []string) {plan_exec.TellPlan(plan_exec.ExecParams{CurrentPlanId: lib.CurrentPlanId,CurrentBranch: lib.CurrentBranch,- AuthVars: apiKeys,+ AuthVars: authVars,CheckOutdatedContext: func(maybeContexts []*shared.Context, projectPaths *types.ProjectPaths) (bool, bool, error) {auto := autoConfirm || tellAutoApply || tellAutoContextreturn lib.CheckOutdatedContextWithOutput(auto, auto, maybeContexts, projectPaths)diff --git a/app/cli/go.mod b/app/cli/go.modindex 817966dc..1a92e8e1 100644--- a/app/cli/go.mod+++ b/app/cli/go.mod@@ -68,6 +68,9 @@ require (github.com/muesli/cancelreader v0.2.2 // indirectgithub.com/pkg/term v1.2.0-beta.2 // indirectgithub.com/rivo/uniseg v0.4.7 // indirect+ github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect+ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect+ github.com/xeipuuv/gojsonschema v1.2.0 // indirectgithub.com/yuin/goldmark v1.6.0 // indirectgithub.com/yuin/goldmark-emoji v1.0.2 // indirectgolang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirectdiff --git a/app/cli/go.sum b/app/cli/go.sumindex f8c6554a..aaf493a3 100644--- a/app/cli/go.sum+++ b/app/cli/go.sum@@ -755,6 +755,12 @@ github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGgithub.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=+github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=+github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=+github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=+github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=+github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=+github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=diff --git a/app/shared/json-schemas/definitions/auto-modes.schema.json b/app/cli/json-schemas/definitions/auto-modes.schema.jsonsimilarity index 100%rename from app/shared/json-schemas/definitions/auto-modes.schema.jsonrename to app/cli/json-schemas/definitions/auto-modes.schema.jsondiff --git a/app/shared/json-schemas/definitions/model-providers.schema.json b/app/cli/json-schemas/definitions/model-providers.schema.jsonsimilarity index 100%rename from app/shared/json-schemas/definitions/model-providers.schema.jsonrename to app/cli/json-schemas/definitions/model-providers.schema.jsondiff --git a/app/shared/json-schemas/definitions/model-roles.schema.json b/app/cli/json-schemas/definitions/model-roles.schema.jsonsimilarity index 100%rename from app/shared/json-schemas/definitions/model-roles.schema.jsonrename to app/cli/json-schemas/definitions/model-roles.schema.jsondiff --git a/app/shared/json-schemas/model-config.schema.json b/app/cli/json-schemas/model-config.schema.jsonsimilarity index 100%rename from app/shared/json-schemas/model-config.schema.jsonrename to app/cli/json-schemas/model-config.schema.jsondiff --git a/app/shared/json-schemas/model-pack-config.schema.json b/app/cli/json-schemas/model-pack-config.schema.jsonsimilarity index 100%rename from app/shared/json-schemas/model-pack-config.schema.jsonrename to app/cli/json-schemas/model-pack-config.schema.jsondiff --git a/app/shared/json-schemas/model-provider-config.schema.json b/app/cli/json-schemas/model-provider-config.schema.jsonsimilarity index 100%rename from app/shared/json-schemas/model-provider-config.schema.jsonrename to app/cli/json-schemas/model-provider-config.schema.jsondiff --git a/app/shared/json-schemas/model-role-config.schema.json b/app/cli/json-schemas/model-role-config.schema.jsonsimilarity index 100%rename from app/shared/json-schemas/model-role-config.schema.jsonrename to app/cli/json-schemas/model-role-config.schema.jsondiff --git a/app/shared/json-schemas/plan-config.schema.json b/app/cli/json-schemas/plan-config.schema.jsonsimilarity index 100%rename from app/shared/json-schemas/plan-config.schema.jsonrename to app/cli/json-schemas/plan-config.schema.jsondiff --git a/app/cli/lib/model_settings.go b/app/cli/lib/model_settings.goindex 5c95e8ff..ad30e16a 100644--- a/app/cli/lib/model_settings.go+++ b/app/cli/lib/model_settings.go@@ -9,24 +9,24 @@ import (const GoBack = "β Go back"-func SelectModelForRole(customModels []*shared.CustomModel, role shared.ModelRole) *shared.CustomModel {- builtInModels := shared.FilterAvailableCompatibleModels(shared.AvailableModels, role)+func SelectModelIdForRole(customModels []*shared.CustomModel, role shared.ModelRole) shared.ModelId {+ builtInModels := shared.FilterBuiltInCompatibleModels(shared.BuiltInBaseModels, role)customModels = shared.FilterCustomCompatibleModels(customModels, role)for {- var selectableModels []*shared.AvailableModel+ var selectableModelIds []shared.ModelIdopts := []string{}for _, m := range builtInModels {- label := fmt.Sprintf("%s | max %d πͺ", m.ModelString(), m.MaxTokens)+ label := fmt.Sprintf("%s | max %d πͺ", m.ModelId, m.MaxTokens)opts = append(opts, label)- selectableModels = append(selectableModels, m)+ selectableModelIds = append(selectableModelIds, m.ModelId)}for _, m := range customModels {- label := fmt.Sprintf("%s β %s | max %d πͺ", p, m.ModelName, m.MaxTokens)+ label := fmt.Sprintf("%s | max %d πͺ", m.ModelId, m.MaxTokens)opts = append(opts, label)- selectableModels = append(selectableModels, m)+ selectableModelIds = append(selectableModelIds, m.ModelId)}opts = append(opts, GoBack)@@ -35,11 +35,11 @@ func SelectModelForRole(customModels []*shared.CustomModel, role shared.ModelRolif err != nil {if err.Error() == "interrupt" {- return nil+ return ""}term.OutputErrorAndExit("Error selecting model: %v", err)- return nil+ return ""}if selection == GoBack {@@ -54,10 +54,8 @@ func SelectModelForRole(customModels []*shared.CustomModel, role shared.ModelRol}}- return selectableModels[idx]+ id := selectableModelIds[idx]+ return id}-- return nil-}diff --git a/app/cli/term/help.go b/app/cli/term/help.goindex 5afa28ed..fa368195 100644--- a/app/cli/term/help.go+++ b/app/cli/term/help.go@@ -109,12 +109,20 @@ var CliCommands = []CmdConfig{{"models available --custom", "", "show available custom models only", true},{"models delete", "", "delete a custom model", true},{"models add", "", "add a custom model", true},++ {"providers", "", "show all available model providers", true},+ {"providers --custom", "", "show available custom model providers only", true},+ {"providers show", "", "show a built-in or custom model provider's settings", true},+ {"providers update", "", "update a custom model provider's settings", true},+ {"providers delete", "", "delete a custom model provider", true},+{"model-packs", "", "show all available model packs", true},{"model-packs create", "", "create a new custom model pack", true},{"model-packs delete", "", "delete a custom model pack", true},{"model-packs --custom", "", "show custom model packs only", true},{"model-packs update", "", "update a custom model pack", true},{"model-packs show", "", "show a built-in or custom model pack's settings", true},+{"set-model", "", "update current plan model settings", true},{"set-model default", "", "update the default model settings for new plans", true},@@ -325,7 +333,7 @@ func PrintHelpAllCommands() {fmt.Fprintln(builder)color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " Custom Models ")- printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "models available", "models available --custom", "models add", "models delete", "model-packs --custom", "model-packs create", "model-packs show", "model-packs update", "model-packs delete")+ printCmds(builder, " ", []color.Attribute{color.Bold, ColorHiCyan}, "models available", "models available --custom", "models add", "models delete", "providers", "providers --custom", "providers show", "providers update", "providers delete", "model-packs --custom", "model-packs create", "model-packs show", "model-packs update", "model-packs delete")fmt.Fprintln(builder)color.New(color.Bold, color.BgCyan, color.FgHiWhite).Fprintln(builder, " Accounts ")diff --git a/app/server/litellm_proxy.py b/app/server/litellm_proxy.pyindex 112e469e..543b6654 100644--- a/app/server/litellm_proxy.py+++ b/app/server/litellm_proxy.py@@ -1,9 +1,11 @@from fastapi import FastAPI, Requestfrom fastapi.responses import StreamingResponse, JSONResponse-from litellm import completion+from litellm import completion, _turn_on_debugimport jsonimport re+# _turn_on_debug()+LOGGING_ENABLED = Falseprint("Litellm proxy: starting proxy server on port 4000...")@@ -60,21 +62,30 @@ async def passthrough(request: Request):try:if payload.get("stream"):++ try:+ response_stream = completion(api_key=api_key, **payload)+ except Exception as e:+ return error_response(e)def stream_generator():- try:- response_stream = completion(api_key=api_key, **payload)+ try:for chunk in response_stream:yield f"data: {json.dumps(chunk.to_dict())}\n\n"yield "data: [DONE]\n\n"except Exception as e:yield f"data: {json.dumps({'error': str(e)})}\n\n"+ finally:+ response_stream.close()print(f"Litellm proxy: Initiating streaming response for model: {payload.get('model', 'unknown')}")return StreamingResponse(stream_generator(), media_type="text/event-stream")else:print(f"Litellm proxy: Non-streaming response requested for model: {payload.get('model', 'unknown')}")- result = completion(api_key=api_key, **payload)+ try:+ result = completion(api_key=api_key, **payload)+ except Exception as e:+ return error_response(e)return JSONResponse(content=result)except Exception as e:@@ -89,3 +100,12 @@ async def passthrough(request: Request):status_code=status_code,content={"error": err_msg})++def error_response(exc: Exception) -> JSONResponse:+ status = getattr(exc, "status_code", 500)+ retry_after = (+ getattr(getattr(exc, "response", None), "headers", {})+ .get("Retry-After")+ )+ hdrs = {"Retry-After": retry_after} if retry_after else {}+ return JSONResponse(status_code=status, content={"error": str(exc)}, headers=hdrs)\ No newline at end of filediff --git a/app/server/model/client_stream.go b/app/server/model/client_stream.goindex dc06df22..7ec3bb00 100644--- a/app/server/model/client_stream.go+++ b/app/server/model/client_stream.go@@ -281,6 +281,7 @@ func withStreamingRetries[T any](log.Printf("withStreamingRetries - operation returned non-retriable error, but has fallback - resetting numFallbackRetry to 0 and continuing to retry")numFallbackRetry = 0newFallback = true+ compareRetries = 0// otherwise, continue to retry logic}diff --git a/app/server/model/model_request.go b/app/server/model/model_request.goindex a633ede0..7908a434 100644--- a/app/server/model/model_request.go+++ b/app/server/model/model_request.go@@ -11,6 +11,7 @@ import ("strings""time"+ "github.com/davecgh/go-spew/spew""github.com/sashabaranov/go-openai")@@ -83,6 +84,11 @@ func ModelRequest(modelConfig = &config}+ log.Println("ModelRequest - modelConfig:")+ spew.Dump(modelConfig)+ log.Println("ModelRequest - baseModelConfig:")+ spew.Dump(baseModelConfig)+log.Printf("Model config - role: %s, model: %s, max output tokens: %d\n", modelConfig.Role, baseModelConfig.ModelName, baseModelConfig.MaxOutputTokens)expectedOutputTokens := baseModelConfig.MaxOutputTokens - inputTokensEstimatediff --git a/app/server/model/plan/tell_exec.go b/app/server/model/plan/tell_exec.goindex e78261be..1c34003b 100644--- a/app/server/model/plan/tell_exec.go+++ b/app/server/model/plan/tell_exec.go@@ -394,7 +394,8 @@ func execTellPlan(params execTellPlanParams) {// log.Println("Tell plan - modelConfig:", spew.Sdump(modelConfig))state.modelConfig = &modelConfig- baseModelConfig := modelConfig.GetBaseModelConfig(state.authVars)++ baseModelConfig := modelConfig.GetBaseModelConfig(authVars)// if the model doesn't support cache control, remove the cache control spec from the messagesif !baseModelConfig.SupportsCacheControl {diff --git a/app/server/model/plan/tell_stream_main.go b/app/server/model/plan/tell_stream_main.goindex 035861ad..41cbaf68 100644--- a/app/server/model/plan/tell_stream_main.go+++ b/app/server/model/plan/tell_stream_main.go@@ -1,6 +1,7 @@package planimport (+ "errors""fmt""log""net/http"@@ -8,6 +9,7 @@ import ("plandex-server/notify""plandex-server/types""runtime/debug"+ "strings""time"shared "plandex-shared"@@ -124,13 +126,17 @@ mainLoop:state.execHookOnStop(true)var msg string+ name := modelName+ if !strings.Contains(string(modelName), string(modelProvider)) {+ name = shared.ModelName(fmt.Sprintf("%s/%s", modelProvider, modelName))+ }if active.CurrentReplyContent == "" {- msg = fmt.Sprintf("The AI model (%s/%s) didn't respond: %v", modelProvider, modelName, err)+ msg = fmt.Sprintf("The AI model (%s) didn't respond: %v", name, err)} else {- msg = fmt.Sprintf("The AI model (%s/%s) stopped responding: %v", modelProvider, modelName, err)+ msg = fmt.Sprintf("The AI model (%s) stopped responding: %v", name, err)}state.onError(onErrorParams{- streamErr: fmt.Errorf(msg, err),+ streamErr: errors.New(msg),storeDesc: true,canRetry: active.CurrentReplyContent == "", // if there was no output yet, we can retry})diff --git a/app/shared/ai_models_available.go b/app/shared/ai_models_available.goindex cc6805e2..798b306d 100644--- a/app/shared/ai_models_available.go+++ b/app/shared/ai_models_available.go@@ -783,10 +783,10 @@ var BuiltInModels = []*BaseModelConfigSchema{},}-var BaseModelIds = []ModelId{}var BuiltInBaseModelsById = map[ModelId]*BaseModelConfigSchema{}var BuiltInModelProvidersByModelId = map[ModelId][]BaseModelUsesProvider{}+var BuiltInBaseModels = []*BaseModelConfigSchema{}var AvailableModels = []*AvailableModel{}@@ -811,9 +811,10 @@ func init() {continue}+ model.ModelId = modelIdBuiltInModelProvidersByModelId[modelId] = model.ProvidersBuiltInBaseModelsById[modelId] = model- BaseModelIds = append(BaseModelIds, modelId)+ BuiltInBaseModels = append(BuiltInBaseModels, model)}}@@ -821,9 +822,10 @@ func init() {addVariants(model.Variants, ModelId(string(model.ModelTag)))} else {modelId := ModelId(string(model.ModelTag))+ model.ModelId = modelIdBuiltInModelProvidersByModelId[modelId] = model.ProvidersBuiltInBaseModelsById[modelId] = model- BaseModelIds = append(BaseModelIds, modelId)+ BuiltInBaseModels = append(BuiltInBaseModels, model)}}@@ -889,11 +891,3 @@ func GetAvailableModel(provider ModelProvider, modelId ModelId) *AvailableModelcompositeKey := string(provider) + "/" + string(modelId)return AvailableModelsByComposite[compositeKey]}--func GetBuiltInBaseModels() []*BaseModelConfigSchema {- models := []*BaseModelConfigSchema{}- for _, id := range BaseModelIds {- models = append(models, BuiltInBaseModelsById[id])- }- return models-}diff --git a/app/shared/ai_models_data_models.go b/app/shared/ai_models_data_models.goindex f27108d0..f6e03d31 100644--- a/app/shared/ai_models_data_models.go+++ b/app/shared/ai_models_data_models.go@@ -77,6 +77,7 @@ func (b BaseModelUsesProvider) ToComposite() string {type BaseModelConfigSchema struct {ModelTag ModelTag `json:"modelTag"`+ ModelId ModelId `json:"modelId"`Publisher ModelPublisher `json:"publisher"`Description string `json:"description"`@@ -337,6 +338,14 @@ func (m *ModelRoleConfigSchema) toModelRoleConfig() ModelRoleConfig {}}+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@@ -425,6 +434,14 @@ func (p PlannerRoleConfig) Value() (driver.Value, error) {return json.Marshal(p)}+func (p PlannerRoleConfig) GetMaxConvoTokens() int {+ if p.MaxConvoTokens > 0 {+ return p.MaxConvoTokens+ }++ return p.ModelRoleConfig.GetSharedBaseConfig().DefaultMaxConvoTokens+}+type ModelPackSchema struct {Name string `json:"name"`Description string `json:"description"`diff --git a/app/shared/ai_models_packs.go b/app/shared/ai_models_packs.goindex 9309841b..97bb1740 100644--- a/app/shared/ai_models_packs.go+++ b/app/shared/ai_models_packs.go@@ -108,7 +108,6 @@ var BuiltInModelPackSchemas = []*ModelPackSchema{func init() {defaultBuilder := getModelRoleConfig(ModelRoleBuilder, "openai/o4-mini-medium",getStrongModelFallback("openai/o4-mini-high"),- getErrorFallback("openai/o3-mini-medium"),)DailyDriverPackSchema = ModelPackSchema{@@ -117,30 +116,22 @@ func init() {Planner: getModelRoleConfig(ModelRolePlanner, "anthropic/claude-3.7-sonnet",getLargeContextFallback("google/gemini-2.5-pro-preview",getLargeContextFallback("google/gemini-pro-1.5"),- getErrorFallback("google/gemini-pro-1.5"),),),Architect: Pointer(getModelRoleConfig(ModelRoleArchitect, "anthropic/claude-3.7-sonnet",getLargeContextFallback("google/gemini-2.5-pro-preview",getLargeContextFallback("google/gemini-pro-1.5"),- getErrorFallback("google/gemini-pro-1.5"),),)),Coder: Pointer(getModelRoleConfig(ModelRoleCoder, "anthropic/claude-3.7-sonnet",getLargeContextFallback("openai/gpt-4.1"),)),- PlanSummary: getModelRoleConfig(ModelRolePlanSummary, "openai/o4-mini-low",- getErrorFallback("openai/o3-mini-low"),- ),- Builder: defaultBuilder,- WholeFileBuilder: Pointer(getModelRoleConfig(ModelRoleWholeFileBuilder, "openai/o4-mini-medium",- getErrorFallback("openai/o3-mini-medium"),- )),- Namer: getModelRoleConfig(ModelRoleName, "openai/gpt-4.1-mini"),- CommitMsg: getModelRoleConfig(ModelRoleCommitMsg, "openai/gpt-4.1-mini"),- ExecStatus: getModelRoleConfig(ModelRoleExecStatus, "openai/o4-mini-low",- getErrorFallback("openai/o3-mini-low"),- ),+ PlanSummary: getModelRoleConfig(ModelRolePlanSummary, "openai/o4-mini-low"),+ Builder: defaultBuilder,+ WholeFileBuilder: Pointer(getModelRoleConfig(ModelRoleWholeFileBuilder, "openai/o4-mini-medium")),+ Namer: getModelRoleConfig(ModelRoleName, "openai/gpt-4.1-mini"),+ CommitMsg: getModelRoleConfig(ModelRoleCommitMsg, "openai/gpt-4.1-mini"),+ ExecStatus: getModelRoleConfig(ModelRoleExecStatus, "openai/o4-mini-low"),}ReasoningPackSchema = ModelPackSchema{diff --git a/app/shared/ai_models_providers.go b/app/shared/ai_models_providers.goindex 823ca44b..91a7b8df 100644--- a/app/shared/ai_models_providers.go+++ b/app/shared/ai_models_providers.go@@ -55,17 +55,18 @@ var ModelProviderToLiteLLMId = map[ModelProvider]string{ModelProviderAmazonBedrock: "bedrock",}-var AllModelProviders = []string{- string(ModelProviderOpenAI),- string(ModelProviderOpenRouter),- string(ModelProviderAnthropic),- string(ModelProviderGoogleAIStudio),- string(ModelProviderGoogleVertex),- string(ModelProviderAzureOpenAI),- string(ModelProviderDeepSeek),- string(ModelProviderPerplexity),- string(ModelProviderAmazonBedrock),- string(ModelProviderCustom),+var AllModelProviders = []ModelProvider{+ ModelProviderOpenAI,+ ModelProviderOpenRouter,+ ModelProviderAnthropic,+ ModelProviderGoogleAIStudio,+ ModelProviderGoogleVertex,+ ModelProviderAzureOpenAI,+ ModelProviderDeepSeek,+ ModelProviderPerplexity,+ ModelProviderAmazonBedrock,+ ModelProviderOllama,+ ModelProviderCustom,}type ModelProviderExtraAuthVars struct {@@ -84,7 +85,8 @@ type ModelProviderConfigSchema struct {HasAWSAuth bool `json:"hasAWSAuth,omitempty"`// for local models that don't require auth (ollama, etc.)- SkipAuth bool `json:"skipAuth,omitempty"`+ SkipAuth bool `json:"skipAuth,omitempty"`+ LocalOnly bool `json:"localOnly,omitempty"`ApiKeyEnvVar string `json:"apiKeyEnvVar,omitempty"`ExtraAuthVars []ModelProviderExtraAuthVars `json:"extraAuthVars,omitempty"`@@ -187,9 +189,10 @@ var BuiltInModelProviderConfigs = map[ModelProvider]ModelProviderConfigSchema{},},ModelProviderOllama: {- Provider: ModelProviderOllama,- BaseUrl: LiteLLMBaseUrl,- SkipAuth: true,+ Provider: ModelProviderOllama,+ BaseUrl: LiteLLMBaseUrl,+ SkipAuth: true,+ LocalOnly: true,},}diff --git a/app/shared/plan_model_settings.go b/app/shared/plan_model_settings.goindex 59b679d6..e5495952 100644--- a/app/shared/plan_model_settings.go+++ b/app/shared/plan_model_settings.go@@ -129,16 +129,22 @@ func (ps PlanSettings) GetWholeFileBuilderMaxReservedOutputTokens() int {}func (ps PlanSettings) GetPlannerMaxConvoTokens() int {- if ps.ModelOverrides.MaxConvoTokens == nil {- if ps.ModelPack == nil {- defaultPlanner := DefaultModelPack.Planner+ if ps.ModelPack != nil && ps.ModelPack.Planner.MaxConvoTokens != 0 {+ return ps.ModelPack.Planner.MaxConvoTokens+ }++ if ps.ModelPack == nil {+ defaultPlanner := DefaultModelPack.Planner+ if defaultPlanner.MaxConvoTokens != 0 {return defaultPlanner.MaxConvoTokens- } else {- planner := ps.ModelPack.Planner- return planner.MaxConvoTokens}+ return defaultPlanner.GetSharedBaseConfig().DefaultMaxConvoTokens} else {- return *ps.ModelOverrides.MaxConvoTokens+ planner := ps.ModelPack.Planner+ if planner.MaxConvoTokens != 0 {+ return planner.MaxConvoTokens+ }+ return planner.GetSharedBaseConfig().DefaultMaxConvoTokens}}