@@ -45,6 +45,9 @@ var preprompt *string
45
45
var url * string
46
46
var logFile * string
47
47
var shouldExecuteCommand * bool
48
+ var out * string
49
+ var height * int
50
+ var width * int
48
51
49
52
func main () {
50
53
execPath , err := os .Executable ()
@@ -67,6 +70,9 @@ func main() {
67
70
top_p = flag .String ("top_p" , "" , "Set top_p" )
68
71
max_length = flag .String ("max_length" , "" , "Set max length of response" )
69
72
preprompt = flag .String ("preprompt" , "" , "Set preprompt" )
73
+ out = flag .String ("out" , "" , "Output file path" )
74
+ width = flag .Int ("width" , 1024 , "Output image width" )
75
+ height = flag .Int ("height" , 1024 , "Output image height" )
70
76
71
77
defaultUrl := ""
72
78
if * provider == "openai" {
@@ -170,17 +176,22 @@ func main() {
170
176
case * isChangelog :
171
177
getVersionHistory ()
172
178
case * isImage :
173
- params := structs.Params {
174
- ApiKey : * apiKey ,
175
- ApiModel : * apiModel ,
176
- Provider : * provider ,
177
- Max_length : * max_length ,
178
- Temperature : * temperature ,
179
- Top_p : * top_p ,
180
- Preprompt : * preprompt ,
181
- Url : * url ,
182
- PrevMessages : "" ,
183
- ThreadID : "" ,
179
+ params := structs.ImageParams {
180
+ Params : structs.Params {
181
+ ApiKey : * apiKey ,
182
+ ApiModel : * apiModel ,
183
+ Provider : * provider ,
184
+ Max_length : * max_length ,
185
+ Temperature : * temperature ,
186
+ Top_p : * top_p ,
187
+ Preprompt : * preprompt ,
188
+ Url : * url ,
189
+ PrevMessages : "" ,
190
+ ThreadID : "" ,
191
+ },
192
+ Width : * width ,
193
+ Height : * height ,
194
+ Out : * out ,
184
195
}
185
196
186
197
if len (prompt ) > 1 {
@@ -223,11 +234,11 @@ func main() {
223
234
fmt .Fprintln (os .Stderr , `Example: tgpt -q "What is encryption?"` )
224
235
os .Exit (1 )
225
236
}
226
- getSilentText (* preprompt + trimmedPrompt + contextText + pipedInput , structs.ExtraOptions {})
237
+ getSilentText (* preprompt + trimmedPrompt + contextText + pipedInput , structs.ExtraOptions {})
227
238
} else {
228
239
formattedInput := getFormattedInputStdin ()
229
240
fmt .Println ()
230
- getSilentText (* preprompt + formattedInput + cleanPipedInput , structs.ExtraOptions {})
241
+ getSilentText (* preprompt + formattedInput + cleanPipedInput , structs.ExtraOptions {})
231
242
}
232
243
case * isShell :
233
244
if len (prompt ) > 1 {
@@ -381,7 +392,7 @@ func main() {
381
392
os .Exit (1 )
382
393
}
383
394
384
- getData (* preprompt + formattedInput + contextText + pipedInput , structs.Params {}, structs.ExtraOptions {IsNormal : true , IsInteractive : false , })
395
+ getData (* preprompt + formattedInput + contextText + pipedInput , structs.Params {}, structs.ExtraOptions {IsNormal : true , IsInteractive : false })
385
396
}
386
397
387
398
} else {
@@ -390,7 +401,7 @@ func main() {
390
401
input := scanner .Text ()
391
402
go loading (& stopSpin )
392
403
formattedInput := strings .TrimSpace (input )
393
- getData (* preprompt + formattedInput + pipedInput , structs.Params {}, structs.ExtraOptions {IsInteractive : false , })
404
+ getData (* preprompt + formattedInput + pipedInput , structs.Params {}, structs.ExtraOptions {IsInteractive : false })
394
405
}
395
406
}
396
407
@@ -537,6 +548,11 @@ func showHelpMessage() {
537
548
fmt .Printf ("%-50v Set preprompt\n " , "--preprompt" )
538
549
fmt .Printf ("%-50v Execute shell command without confirmation\n " , "-y" )
539
550
551
+ boldBlue .Println ("\n Options supported for image generation (with -image flag)" )
552
+ fmt .Printf ("%-50v Output image filename\n " , "-s, --out" )
553
+ fmt .Printf ("%-50v Output image height\n " , "-s, --height" )
554
+ fmt .Printf ("%-50v Output image width\n " , "-s, --width" )
555
+
540
556
boldBlue .Println ("\n Options:" )
541
557
fmt .Printf ("%-50v Print version \n " , "-v, --version" )
542
558
fmt .Printf ("%-50v Print help message \n " , "-h, --help" )
@@ -593,6 +609,7 @@ func showHelpMessage() {
593
609
fmt .Println (`tgpt -s "How to update my system?"` )
594
610
fmt .Println (`tgpt --provider duckduckgo "What is 1+1"` )
595
611
fmt .Println (`tgpt --img "cat"` )
612
+ fmt .Println (`tgpt --img --out ~/my-cat.jpg --height 256 --width 256 "cat"` )
596
613
fmt .Println (`tgpt --provider openai --key "sk-xxxx" --model "gpt-3.5-turbo" "What is 1+1"` )
597
614
fmt .Println (`cat install.sh | tgpt "Explain the code"` )
598
615
}
0 commit comments