@@ -971,35 +971,18 @@ func parseDMRProviderOpts(cfg *latest.ModelConfig) (contextSize *int64, runtimeF
971971}
972972
973973func pullDockerModelIfNeeded (ctx context.Context , model string ) error {
974- // Check if running in interactive mode (stdin is a terminal)
975- interactive := term .IsTerminal (int (os .Stdin .Fd ()))
976- if ! interactive {
977- // In non-interactive mode (CI / Servers), do not attempt to pull the model
978- return nil
979- }
980-
981974 if modelExists (ctx , model ) {
982975 slog .Debug ("Model already exists, skipping pull" , "model" , model )
983976 return nil
984977 }
985978
986- // Prompt user for confirmation in interactive mode
987- fmt .Printf ("\n Model %s not found locally.\n " , model )
988- fmt .Printf ("Do you want to pull it now? ([y]es/[n]o): " )
989-
990- response , err := input .ReadLine (ctx , os .Stdin )
991- if err != nil {
992- return fmt .Errorf ("failed to read user input: %w" , err )
979+ if err := confirmModelPull (ctx , model ); err != nil {
980+ return err
993981 }
994982
995- response = strings .TrimSpace (strings .ToLower (response ))
996- if response != "y" && response != "yes" {
997- return fmt .Errorf ("model pull declined by user" )
998- }
999-
1000- // Pull the model
1001983 slog .Info ("Pulling DMR model" , "model" , model )
1002984 fmt .Printf ("Pulling model %s...\n " , model )
985+
1003986 cmd := exec .CommandContext (ctx , "docker" , "model" , "pull" , model )
1004987 cmd .Stdout = os .Stdout
1005988 cmd .Stderr = os .Stderr
@@ -1013,6 +996,30 @@ func pullDockerModelIfNeeded(ctx context.Context, model string) error {
1013996 return nil
1014997}
1015998
999+ // confirmModelPull asks for user confirmation in interactive mode.
1000+ // In non-interactive mode (e.g. devcontainers, CI), it proceeds automatically.
1001+ func confirmModelPull (ctx context.Context , model string ) error {
1002+ if ! term .IsTerminal (int (os .Stdin .Fd ())) {
1003+ slog .Info ("Model not found locally, pulling automatically (non-interactive mode)" , "model" , model )
1004+ return nil
1005+ }
1006+
1007+ fmt .Printf ("\n Model %s not found locally.\n " , model )
1008+ fmt .Printf ("Do you want to pull it now? ([y]es/[n]o): " )
1009+
1010+ response , err := input .ReadLine (ctx , os .Stdin )
1011+ if err != nil {
1012+ return fmt .Errorf ("failed to read user input: %w" , err )
1013+ }
1014+
1015+ response = strings .TrimSpace (strings .ToLower (response ))
1016+ if response != "y" && response != "yes" {
1017+ return fmt .Errorf ("model pull declined by user" )
1018+ }
1019+
1020+ return nil
1021+ }
1022+
10161023func modelExists (ctx context.Context , model string ) bool {
10171024 cmd := exec .CommandContext (ctx , "docker" , "model" , "inspect" , model )
10181025 var stderr bytes.Buffer
0 commit comments