Skip to content

Commit

Permalink
fix: openai async client bug #130
Browse files Browse the repository at this point in the history
Update openai.py
  • Loading branch information
chenweize1998 authored Apr 25, 2024
2 parents 6e6dff6 + c755193 commit 4dd772d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions agentverse/llms/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,12 @@ def generate_response(
try:
# Execute function call
if functions != []:
response = openai_client.chat.completions.create(
messages=messages,
functions=functions,
**self.args.dict(),
)
async with async_openai_client:
response = openai_client.chat.completions.create(
messages=messages,
functions=functions,
**self.args.dict(),
)

logger.log_prompt(
[
Expand Down Expand Up @@ -275,10 +276,11 @@ def generate_response(
)

else:
response = openai_client.chat.completions.create(
messages=messages,
**self.args.dict(),
)
async with async_openai_client:
response = openai_client.chat.completions.create(
messages=messages,
**self.args.dict(),
)
logger.log_prompt(
[
{
Expand Down

0 comments on commit 4dd772d

Please sign in to comment.