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 4
4
"bufio"
5
5
"errors"
6
6
"fmt"
7
+ "io"
7
8
"os"
8
9
"strings"
9
10
@@ -102,13 +103,29 @@ func newRunCmd() *cobra.Command {
102
103
103
104
model := args [0 ]
104
105
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 )
108
122
}
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 {
112
129
cmd .Printf ("Running model %s with prompt %s\n " , model , prompt )
113
130
}
114
131
}
@@ -180,9 +197,7 @@ func newRunCmd() *cobra.Command {
180
197
"See 'docker model run --help' for more information" ,
181
198
)
182
199
}
183
- if len (args ) > 2 {
184
- return fmt .Errorf ("too many arguments, expected " + cmdArgs )
185
- }
200
+
186
201
return nil
187
202
}
188
203
You can’t perform that action at this time.
0 commit comments