15
15
import copy
16
16
import json
17
17
import logging
18
+ import ssl
18
19
from json import JSONDecodeError
19
20
from typing import Any , AsyncGenerator
20
21
@@ -96,7 +97,9 @@ def invoke(self, params: CompletionsParameters) -> CompletionsResponse:
96
97
headers = self .headers ,
97
98
json = model_input ,
98
99
timeout = self .task_gen_timeout (task_count ),
99
- verify = self .config .verify_ssl ,
100
+ verify = (
101
+ self .config .ca_cert_file if self .config .ca_cert_file else self .config .verify_ssl
102
+ ),
100
103
)
101
104
result .raise_for_status ()
102
105
response = json .loads (result .text )
@@ -114,7 +117,13 @@ def self_test(self) -> HealthCheckSummary:
114
117
}
115
118
)
116
119
try :
117
- res = requests .get (url , verify = self .config .verify_ssl , timeout = 1 )
120
+ res = requests .get (
121
+ url ,
122
+ verify = (
123
+ self .config .ca_cert_file if self .config .ca_cert_file else self .config .verify_ssl
124
+ ),
125
+ timeout = 1 ,
126
+ )
118
127
res .raise_for_status ()
119
128
except Exception as e :
120
129
logger .exception (str (e ))
@@ -146,7 +155,9 @@ def self_test(self) -> HealthCheckSummary:
146
155
self .config .inference_url + "/readiness" ,
147
156
headers = headers ,
148
157
timeout = 1 ,
149
- verify = self .config .verify_ssl ,
158
+ verify = (
159
+ self .config .ca_cert_file if self .config .ca_cert_file else self .config .verify_ssl
160
+ ),
150
161
)
151
162
r .raise_for_status ()
152
163
@@ -203,7 +214,7 @@ def invoke(self, params: ChatBotParameters) -> ChatBotResponse:
203
214
headers = self .headers ,
204
215
json = data ,
205
216
timeout = self .task_gen_timeout (1 ),
206
- verify = self .config .verify_ssl ,
217
+ verify = self .config .ca_cert_file if self . config . ca_cert_file else self . config . verify_ssl ,
207
218
)
208
219
209
220
if response .status_code == 200 :
@@ -267,8 +278,11 @@ def send_schema1_event(self, ev):
267
278
async def async_invoke (self , params : StreamingChatBotParameters ) -> AsyncGenerator :
268
279
269
280
# Configure SSL context based on verify_ssl setting
270
- ssl_context = self .config .verify_ssl
271
- connector = aiohttp .TCPConnector (ssl = ssl_context )
281
+ if self .config .ca_cert_file :
282
+ ssl_context = ssl .create_default_context (cafile = self .config .ca_cert_file )
283
+ connector = aiohttp .TCPConnector (ssl = ssl_context )
284
+ else :
285
+ connector = aiohttp .TCPConnector (ssl = self .config .verify_ssl )
272
286
273
287
async with aiohttp .ClientSession (raise_for_status = True , connector = connector ) as session :
274
288
headers = {
0 commit comments