File tree Expand file tree Collapse file tree 2 files changed +10
-28
lines changed
Expand file tree Collapse file tree 2 files changed +10
-28
lines changed Original file line number Diff line number Diff line change 77import httpx
88
99from singlestoredb import manage_workspaces
10- from singlestoredb .ai .utils import SingleStoreOpenAIAuth
1110from singlestoredb .management .inference_api import InferenceAPIInfo
1211
1312try :
@@ -172,25 +171,17 @@ def _inject_headers(request: Any, **_ignored: Any) -> None:
172171 ** kwargs ,
173172 )
174173
175- if t is not None :
176- http_client = httpx .Client (
177- timeout = t ,
178- auth = SingleStoreOpenAIAuth (api_key_getter_fn , obo_token_getter_fn ),
179- )
180- else :
181- http_client = httpx .Client (
182- timeout = httpx .Timeout (timeout = 600 , connect = 5.0 ), # default OpenAI timeout
183- auth = SingleStoreOpenAIAuth (api_key_getter_fn , obo_token_getter_fn ),
184- )
185-
186174 # OpenAI / Azure OpenAI path
175+ token = api_key_getter_fn ()
176+
187177 openai_kwargs = dict (
188178 base_url = info .connection_url ,
189- api_key = 'placeholder' ,
179+ api_key = token ,
190180 model = model_name ,
191181 streaming = streaming ,
192- http_client = http_client ,
193182 )
183+ if http_client is not None :
184+ openai_kwargs ['http_client' ] = http_client
194185 return ChatOpenAI (
195186 ** openai_kwargs ,
196187 ** kwargs ,
Original file line number Diff line number Diff line change 77import httpx
88
99from singlestoredb import manage_workspaces
10- from singlestoredb .ai .utils import SingleStoreOpenAIAuth
1110from singlestoredb .management .inference_api import InferenceAPIInfo
1211
1312try :
@@ -172,25 +171,17 @@ def _inject_headers(request: Any, **_ignored: Any) -> None:
172171 ** kwargs ,
173172 )
174173
175- if t is not None :
176- http_client_internal = httpx .Client (
177- timeout = t ,
178- auth = SingleStoreOpenAIAuth (api_key_getter_fn , obo_token_getter_fn ),
179- )
180- else :
181- http_client_internal = httpx .Client (
182- timeout = httpx .Timeout (timeout = 600 , connect = 5.0 ), # default OpenAI timeout
183- auth = SingleStoreOpenAIAuth (api_key_getter_fn , obo_token_getter_fn ),
184- )
185-
186174 # OpenAI / Azure OpenAI path
175+ token = api_key_getter_fn ()
176+
187177 openai_kwargs = dict (
188178 base_url = info .connection_url ,
189- api_key = api_key_getter_fn () ,
179+ api_key = token ,
190180 model = model_name ,
191181 streaming = streaming ,
192- http_client = http_client_internal ,
193182 )
183+ if http_client is not None :
184+ openai_kwargs ['http_client' ] = http_client
194185 return ChatOpenAI (
195186 ** openai_kwargs ,
196187 ** kwargs ,
You can’t perform that action at this time.
0 commit comments