This repository was archived by the owner on Oct 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +24
-9
lines changed
Expand file tree Collapse file tree 1 file changed +24
-9
lines changed Original file line number Diff line number Diff line change 44 "bufio"
55 "errors"
66 "fmt"
7+ "io"
78 "os"
89 "strings"
910
@@ -102,13 +103,29 @@ func newRunCmd() *cobra.Command {
102103
103104 model := args [0 ]
104105 prompt := ""
105- if len (args ) == 1 {
106- if debug {
107- cmd .Printf ("Running model %s\n " , model )
106+ args_len := len (args )
107+ if args_len > 1 {
108+ prompt = strings .Join (args [1 :], " " )
109+ }
110+
111+ fi , err := os .Stdin .Stat ()
112+ if err == nil && (fi .Mode ()& os .ModeCharDevice ) == 0 {
113+ // Read all from stdin
114+ reader := bufio .NewReader (os .Stdin )
115+ input , err := io .ReadAll (reader )
116+ if err == nil {
117+ if prompt != "" {
118+ prompt += "\n \n "
119+ }
120+
121+ prompt += string (input )
108122 }
109- } else {
110- prompt = args [1 ]
111- if debug {
123+ }
124+
125+ if debug {
126+ if prompt == "" {
127+ cmd .Printf ("Running model %s\n " , model )
128+ } else {
112129 cmd .Printf ("Running model %s with prompt %s\n " , model , prompt )
113130 }
114131 }
@@ -180,9 +197,7 @@ func newRunCmd() *cobra.Command {
180197 "See 'docker model run --help' for more information" ,
181198 )
182199 }
183- if len (args ) > 2 {
184- return fmt .Errorf ("too many arguments, expected " + cmdArgs )
185- }
200+
186201 return nil
187202 }
188203
You can’t perform that action at this time.
0 commit comments