Skip to content

Commit d85cb3d

Browse files
committed
feat(client.go): introduce DefaultChunkTimeout for streaming operations
feat(client.go): add MaxTokens and ChunkTimeout options to configure client behavior
1 parent 01fd7f3 commit d85cb3d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

openai/client.go

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ const (
2929
// option when creating a new client.
3030
DefaultTimeout = 3 * time.Minute
3131

32+
// DefaultChunkTimeout specifies the default duration for waiting on a chunk of
33+
// data during streaming operations before timing out. This value can be
34+
// adjusted to control how long the system will wait for a chunk before
35+
// considering the operation timed out.
3236
DefaultChunkTimeout = 5 * time.Second
3337
)
3438

@@ -85,6 +89,9 @@ func ResponseFormat[Format string | openai.ChatCompletionResponseFormatType](for
8589
}
8690
}
8791

92+
// MaxTokens configures the maximum number of tokens that the Client can use for
93+
// generating text completions. It accepts an integer value and returns an
94+
// [Option] to modify a [Client] instance.
8895
func MaxTokens(maxTokens int) Option {
8996
return func(m *Client) {
9097
m.maxTokens = maxTokens
@@ -106,6 +113,9 @@ func TopP(topP float32) Option {
106113
}
107114
}
108115

116+
// ChunkTimeout sets the maximum duration a Client should wait for a chunk of
117+
// data during streaming operations before timing out. This is configured as an
118+
// Option that modifies the chunkTimeout field of a Client instance.
109119
func ChunkTimeout(timeout time.Duration) Option {
110120
return func(m *Client) {
111121
m.chunkTimeout = timeout

0 commit comments

Comments
 (0)