Skip to content

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

Add parallel API calls and model pack hash support

Dane Schneiderc782e19a3f75
diff --git a/app/cli/cmd/models.go b/app/cli/cmd/models.go
index 783a7b41..9d76e053 100644
--- a/app/cli/cmd/models.go
+++ b/app/cli/cmd/models.go
@@ -95,10 +95,37 @@ func manageCustomModels(cmd *cobra.Command, args []string) {
term.StartSpinner("")
- serverModelsInput, err := lib.GetServerModelsInput()
- if err != nil {
- term.OutputErrorAndExit("Error getting server models input: %v", err)
- return
+ var serverModelsInput *shared.ModelsInput
+ var defaultConfig *shared.PlanConfig
+
+ errCh := make(chan error, 2)
+
+ go func() {
+ var err error
+ serverModelsInput, err = lib.GetServerModelsInput()
+ if err != nil {
+ errCh <- fmt.Errorf("error getting server models input: %v", err)
+ return
+ }
+ errCh <- nil
+ }()
+
+ go func() {
+ var apiErr *shared.ApiError
+ defaultConfig, apiErr = api.Client.GetDefaultPlanConfig()
+ if apiErr != nil {
+ errCh <- fmt.Errorf("error getting default config: %v", apiErr.Msg)
+ return
+ }
+ errCh <- nil
+ }()
+
+ for i := 0; i < 2; i++ {
+ err := <-errCh
+ if err != nil {
+ term.OutputErrorAndExit(err.Error())
+ return
+ }
}
usingDefaultPath := false
@@ -120,7 +147,7 @@ func manageCustomModels(cmd *cobra.Command, args []string) {
}
} else {
if serverModelsInput.IsEmpty() {
- jsonData, err := json.MarshalIndent(getExampleTemplate(auth.Current.IsCloud), "", " ")
+ jsonData, err := json.MarshalIndent(getExampleTemplate(auth.Current.IsCloud, auth.Current.IntegratedModelsMode), "", " ")
if err != nil {
term.OutputErrorAndExit("Error marshalling template: %v", err)
return
@@ -197,7 +224,7 @@ func manageCustomModels(cmd *cobra.Command, args []string) {
pathArg = fmt.Sprintf(" --file %s", customModelsPath)
}
- res := maybePromptAndOpenModelsFile(customModelsPath, pathArg, "models custom")
+ res := maybePromptAndOpenModelsFile(customModelsPath, pathArg, "models custom", defaultConfig, nil)
if res.shouldReturn {
return
}
@@ -246,7 +273,7 @@ func models(cmd *cobra.Command, args []string) {
renderSettings(settings, allProperties)
- term.PrintCmds("", "set-model", "models available", "models default")
+ term.PrintCmds("", "set-model", "models available", "models default", "models custom")
}
func defaultModels(cmd *cobra.Command, args []string) {
@@ -277,6 +304,11 @@ func defaultModels(cmd *cobra.Command, args []string) {
func listAvailableModels(cmd *cobra.Command, args []string) {
auth.MustResolveAuthWithOrg()
+ if customModelsOnly && auth.Current.IntegratedModelsMode {
+ term.OutputErrorAndExit("Custom models are not supported in Integrated Models mode on Plandex Cloud")
+ return
+ }
+
term.StartSpinner("")
customModels, err := api.Client.ListCustomModels()
@@ -316,12 +348,12 @@ func listAvailableModels(cmd *cobra.Command, args []string) {
if customModelsOnly {
if len(customModels) > 0 {
- term.PrintCmds("", "models", "set-model", "models add", "models delete")
+ term.PrintCmds("", "models", "set-model", "models custom")
} else {
- term.PrintCmds("", "models add")
+ term.PrintCmds("", "models custom")
}
} else {
- term.PrintCmds("", "models available --custom", "models", "set-model", "models add", "models delete")
+ term.PrintCmds("", "models available --custom", "models", "set-model", "models custom")
}
}
@@ -475,7 +507,7 @@ func customModelsNotImplemented(cmd *cobra.Command, args []string) {
os.Exit(1)
}
-func getExampleTemplate(isCloud bool) shared.ClientModelsInput {
+func getExampleTemplate(isCloud, isCloudIntegratedModels bool) shared.ClientModelsInput {
exampleProviderName := "togetherai"
var customProviders []*shared.CustomProvider
@@ -498,10 +530,9 @@ func getExampleTemplate(isCloud bool) shared.ClientModelsInput {
ModelName: "meta-llama/llama-4-maverick",
})
- return shared.ClientModelsInput{
- SchemaUrl: shared.SchemaUrlInputConfig,
- CustomProviders: customProviders,
- CustomModels: []*shared.CustomModel{
+ var customModels []*shared.CustomModel
+ if !isCloudIntegratedModels {
+ customModels = []*shared.CustomModel{
{
ModelId: shared.ModelId("meta-llama/llama-4-maverick"),
Publisher: shared.ModelPublisher("meta-llama"),
@@ -518,7 +549,13 @@ func getExampleTemplate(isCloud bool) shared.ClientModelsInput {
Providers: usesProviders,
},
- },
+ }
+ }
+
+ return shared.ClientModelsInput{
+ SchemaUrl: shared.SchemaUrlInputConfig,
+ CustomProviders: customProviders,
+ CustomModels: customModels,
CustomModelPacks: []*shared.ClientModelPackSchema{
{
Name: "example-model-pack",
diff --git a/app/cli/cmd/set_model.go b/app/cli/cmd/set_model.go
index 99663dbb..2e9bb16e 100644
--- a/app/cli/cmd/set_model.go
+++ b/app/cli/cmd/set_model.go
@@ -152,10 +152,48 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings, d
builtInModelPacks = filtered
}
- customModelPacks, apiErr := api.Client.ListModelPacks()
- if apiErr != nil {
- term.OutputErrorAndExit("Error getting custom model packs: %v", apiErr)
- return nil
+ var customModelPacks []*shared.ModelPack
+ var defaultConfig *shared.PlanConfig
+ var planConfig *shared.PlanConfig
+
+ errCh := make(chan error, 3)
+
+ go func() {
+ var apiErr *shared.ApiError
+ customModelPacks, apiErr = api.Client.ListModelPacks()
+ if apiErr != nil {
+ errCh <- fmt.Errorf("error getting custom model packs: %v", apiErr.Msg)
+ return
+ }
+ errCh <- nil
+ }()
+
+ go func() {
+ var apiErr *shared.ApiError
+ defaultConfig, apiErr = api.Client.GetDefaultPlanConfig()
+ if apiErr != nil {
+ errCh <- fmt.Errorf("error getting default config: %v", apiErr.Msg)
+ return
+ }
+ errCh <- nil
+ }()
+
+ go func() {
+ var apiErr *shared.ApiError
+ planConfig, apiErr = api.Client.GetPlanConfig(lib.CurrentPlanId)
+ if apiErr != nil {
+ errCh <- fmt.Errorf("error getting plan config: %v", apiErr.Msg)
+ return
+ }
+ errCh <- nil
+ }()
+
+ for i := 0; i < 3; i++ {
+ err := <-errCh
+ if err != nil {
+ term.OutputErrorAndExit(err.Error())
+ return nil
+ }
}
useJsonFile := setModelUseJsonFile || setModelSave
@@ -200,7 +238,7 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings, d
return nil
}
- if saveCustomModels {
+ if setModelSave {
if !exists {
term.OutputErrorAndExit("File not found: %s", customModelsPath)
}
@@ -245,7 +283,7 @@ func updateModelSettings(args []string, originalSettings *shared.PlanSettings, d
pathArg = fmt.Sprintf(" --file %s", setModelJsonFilePath)
}
- res := maybePromptAndOpenModelsFile(setModelJsonFilePath, pathArg, "set-model")
+ res := maybePromptAndOpenModelsFile(setModelJsonFilePath, pathArg, "set-model", defaultConfig, planConfig)
if res.shouldReturn {
return nil
}
diff --git a/app/cli/lib/model_settings.go b/app/cli/lib/model_settings.go
index ec19eef4..e0f863d7 100644
--- a/app/cli/lib/model_settings.go
+++ b/app/cli/lib/model_settings.go
@@ -76,7 +76,9 @@ func WriteModelSettingsFile(path string, originalSettings *shared.PlanSettings)
return fmt.Errorf("error creating directory: %v", err)
}
- clientModelPackRoles := originalSettings.GetModelPack().ToModelPackSchema().ToClientModelPackSchemaRoles()
+ modelPackSchemaRoles := originalSettings.GetModelPack().ToModelPackSchema().ModelPackSchemaRoles
+
+ clientModelPackRoles := modelPackSchemaRoles.ToClientModelPackSchemaRoles()
bytes, err := json.MarshalIndent(clientModelPackRoles, "", " ")
if err != nil {
@@ -88,6 +90,11 @@ func WriteModelSettingsFile(path string, originalSettings *shared.PlanSettings)
return fmt.Errorf("error writing JSON file: %v", err)
}
+ err = SaveModelPackRolesHash(path, &modelPackSchemaRoles)
+ if err != nil {
+ return fmt.Errorf("error saving model pack roles hash: %v", err)
+ }
+
return nil
}