File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ type cliOptions struct {
49
49
OpenAITemperature float32 `name:"temperature" help:"OpenAI temperature" env:"OPENAI_TEMPERATURE" default:"0.3"`
50
50
OpenAITopP float32 `name:"top-p" help:"OpenAI top_p" env:"OPENAI_TOP_P" default:"0.3"`
51
51
OpenAIResponseFormat string `name:"format" help:"OpenAI response format ('text' or 'json_object')" env:"OPENAI_RESPONSE_FORMAT" default:"text"`
52
+ OpenAIChunkTimeout string `name:"chunk-timeout" help:"Timeout for each token chunk" env:"OPENAI_CHUNK_TIMEOUT"`
52
53
53
54
Timeout time.Duration `short:"T" help:"Timeout for API requests" env:"DRAGOMAN_TIMEOUT" default:"3m"`
54
55
Verbose bool `short:"v" help:"Verbose output"`
@@ -126,6 +127,14 @@ func (app *App) translate() {
126
127
opts = append (opts , openai .Stream (os .Stdout ))
127
128
}
128
129
130
+ if options .OpenAIChunkTimeout != "" {
131
+ chunkTimeout , err := time .ParseDuration (options .OpenAIChunkTimeout )
132
+ if err != nil {
133
+ app .kong .Fatalf ("invalid chunk timeout: %v" , err )
134
+ }
135
+ opts = append (opts , openai .ChunkTimeout (chunkTimeout ))
136
+ }
137
+
129
138
model := openai .New (options .OpenAIKey , opts ... )
130
139
translator := dragoman .NewTranslator (model )
131
140
You can’t perform that action at this time.
0 commit comments