finic-ai / doctran

MIT License
491 stars 42 forks source link

asynchronous support #10

Open hello-z opened 1 year ago

hello-z commented 1 year ago

The code on github is out of sync with that in pypi, but It seems that async is not used when calling the openai.ChatCompletion.create function, as follows:

# doctran/transformers/transformers.py
completion = self.config.openai.ChatCompletion.create(**function_call.dict())
arguments = completion.choices[0].message["function_call"]["arguments"]

Maybe it should?

# doctran/transformers/transformers.py
completion = await self.config.openai.ChatCompletion.acreate(**function_call.dict())
arguments = completion.choices[0].message["function_call"]["arguments"]