File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,9 @@ def __init__(
151
151
continue
152
152
self .stream : bool = False
153
153
self ._openai = openai .OpenAI ()
154
+ self ._async_openai : Optional [openai .AsyncOpenAI ] = (
155
+ None # Lazily create as not used in the CLI
156
+ )
154
157
if model is None :
155
158
models = self ._openai .models .list ().data
156
159
if self ._is_valid_model ("gpt-4" , models = models ):
@@ -347,8 +350,10 @@ async def asend(self) -> Union[Message, AioMessageStream]:
347
350
append the result to this thread. Note that this method must
348
351
be awaited.
349
352
"""
353
+ if self ._async_openai is None :
354
+ self ._async_openai = openai .AsyncOpenAI ()
350
355
self ._pre_send ()
351
- resp = await self ._openai .chat .completions .acreate (
356
+ resp = await self ._openai .chat .completions .create (
352
357
** self ._get_openai_kwargs ()
353
358
)
354
359
return self ._post_send (resp , AioMessageStream )
You can’t perform that action at this time.
0 commit comments