File tree Expand file tree Collapse file tree 4 files changed +14
-6
lines changed
rbi/openai/internal/transport
sig/openai/internal/transport Expand file tree Collapse file tree 4 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -104,10 +104,10 @@ def initialize(
104
104
organization : ENV [ "OPENAI_ORG_ID" ] ,
105
105
project : ENV [ "OPENAI_PROJECT_ID" ] ,
106
106
base_url : ENV [ "OPENAI_BASE_URL" ] ,
107
- max_retries : OpenAI :: Client ::DEFAULT_MAX_RETRIES ,
108
- timeout : OpenAI :: Client ::DEFAULT_TIMEOUT_IN_SECONDS ,
109
- initial_retry_delay : OpenAI :: Client ::DEFAULT_INITIAL_RETRY_DELAY ,
110
- max_retry_delay : OpenAI :: Client ::DEFAULT_MAX_RETRY_DELAY
107
+ max_retries : self . class ::DEFAULT_MAX_RETRIES ,
108
+ timeout : self . class ::DEFAULT_TIMEOUT_IN_SECONDS ,
109
+ initial_retry_delay : self . class ::DEFAULT_INITIAL_RETRY_DELAY ,
110
+ max_retry_delay : self . class ::DEFAULT_MAX_RETRY_DELAY
111
111
)
112
112
base_url ||= "https://api.openai.com/v1"
113
113
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ class PooledNetRequester
11
11
# https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49
12
12
KEEP_ALIVE_TIMEOUT = 30
13
13
14
+ DEFAULT_MAX_CONNECTIONS = [ Etc . nprocessors , 99 ] . max
15
+
14
16
class << self
15
17
# @api private
16
18
#
@@ -184,7 +186,7 @@ def execute(request)
184
186
# @api private
185
187
#
186
188
# @param size [Integer]
187
- def initialize ( size : Etc . nprocessors )
189
+ def initialize ( size : self . class :: DEFAULT_MAX_CONNECTIONS )
188
190
@mutex = Mutex . new
189
191
@size = size
190
192
@pools = { }
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ module OpenAI
22
22
# https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49
23
23
KEEP_ALIVE_TIMEOUT = 30
24
24
25
+ DEFAULT_MAX_CONNECTIONS = T . let ( T . unsafe ( nil ) , Integer )
26
+
25
27
class << self
26
28
# @api private
27
29
sig { params ( url : URI ::Generic ) . returns ( Net ::HTTP ) }
@@ -66,7 +68,9 @@ module OpenAI
66
68
67
69
# @api private
68
70
sig { params ( size : Integer ) . returns ( T . attached_class ) }
69
- def self . new ( size : Etc . nprocessors )
71
+ def self . new (
72
+ size : OpenAI ::Internal ::Transport ::PooledNetRequester ::DEFAULT_MAX_CONNECTIONS
73
+ )
70
74
end
71
75
end
72
76
end
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ module OpenAI
15
15
16
16
KEEP_ALIVE_TIMEOUT: 30
17
17
18
+ DEFAULT_MAX_CONNECTIONS: Integer
19
+
18
20
def self.connect : (URI::Generic url) -> top
19
21
20
22
def self.calibrate_socket_timeout : (top conn, Float deadline) -> void
You can’t perform that action at this time.
0 commit comments