Skip to content

Commit 1a71731

Browse files
Switch to old implementation for OpenAI client.
1 parent 5452bc8 commit 1a71731

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

singlestoredb/ai/chat.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import httpx
88

99
from singlestoredb import manage_workspaces
10-
from singlestoredb.ai.utils import SingleStoreOpenAIAuth
1110
from singlestoredb.management.inference_api import InferenceAPIInfo
1211

1312
try:
@@ -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,

singlestoredb/ai/debugv3.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import httpx
88

99
from singlestoredb import manage_workspaces
10-
from singlestoredb.ai.utils import SingleStoreOpenAIAuth
1110
from singlestoredb.management.inference_api import InferenceAPIInfo
1211

1312
try:
@@ -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,

0 commit comments

Comments
 (0)