Skip to content

Commit 77cb909

Browse files
committed
Chore: Add ability to disable streaming from envs
Signed-off-by: Daishan Peng <[email protected]>
1 parent 3f876b2 commit 77cb909

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/openai/client.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ func override(left, right string) string {
545545
return left
546546
}
547547

548-
func (c *Client) call(ctx context.Context, request openai.ChatCompletionRequest, transactionID string, env []string, partial chan<- types.CompletionStatus) (types.CompletionMessage, error) {
548+
func (c *Client) call(ctx context.Context, request openai.ChatCompletionRequest, transactionID string, envs []string, partial chan<- types.CompletionStatus) (types.CompletionMessage, error) {
549549
streamResponse := os.Getenv("GPTSCRIPT_INTERNAL_OPENAI_STREAMING") != "false"
550550

551551
partial <- types.CompletionStatus{
@@ -567,11 +567,13 @@ func (c *Client) call(ctx context.Context, request openai.ChatCompletionRequest,
567567
},
568568
}
569569
)
570-
for _, e := range env {
570+
for _, e := range envs {
571571
if strings.HasPrefix(e, "GPTSCRIPT_MODEL_PROVIDER_") {
572572
modelProviderEnv = append(modelProviderEnv, e)
573573
} else if strings.HasPrefix(e, "GPTSCRIPT_DISABLE_RETRIES") {
574574
retryOpts = nil
575+
} else if e == "GPTSCRIPT_INTERNAL_OPENAI_STREAMING=false" {
576+
streamResponse = false
575577
}
576578
}
577579

0 commit comments

Comments
 (0)