Skip to content

Commit

Permalink
Add client kwargs in openai
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik4949 authored and blythed committed Jan 26, 2024
1 parent 5837579 commit a4252f5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions superduperdb/ext/openai/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ def _available_models():

@dc.dataclass(kw_only=True)
class _OpenAI(APIModel):
'''
:param client_kwargs: The kwargs to be passed to OpenAI
'''

client_kwargs: t.Optional[dict] = dc.field(default_factory=dict)
__doc__ = APIModel.__doc__ # type: ignore[assignment]

def __post_init__(self):
Expand All @@ -46,8 +52,8 @@ def __post_init__(self):
msg = f'model {self.model} not in OpenAI available models, {mo}'
raise ValueError(msg)

self.syncClient = SyncOpenAI()
self.asyncClient = AsyncOpenAI()
self.syncClient = SyncOpenAI(**self.client_kwargs)
self.asyncClient = AsyncOpenAI(**self.client_kwargs)

if 'OPENAI_API_KEY' not in os.environ:
raise ValueError('OPENAI_API_KEY not set')
Expand Down

0 comments on commit a4252f5

Please sign in to comment.