Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

changed chat completion to async

SwiftyOSd0db337af82f
diff --git a/autogpts/forge/forge/sdk/llm.py b/autogpts/forge/forge/sdk/llm.py
index 9d853646f5..6980a3b8b6 100644
--- a/autogpts/forge/forge/sdk/llm.py
+++ b/autogpts/forge/forge/sdk/llm.py
@@ -9,7 +9,7 @@ LOG = ForgeLogger(__name__)
@retry(wait=wait_random_exponential(min=1, max=40), stop=stop_after_attempt(3))
-def chat_completion_request(
+async def chat_completion_request(
messages, functions=None, function_call=None, model=str, custom_labels=None
) -> typing.Union[typing.Dict[str, typing.Any], Exception]:
"""Generate a response to a list of messages using OpenAI's API"""
@@ -31,7 +31,7 @@ def chat_completion_request(
# This is an example showing adding in the labels as helicone properties
kwargs["headers"][f"Helicone-Property-{label}"] = custom_labels[label]
- resp = openai.ChatCompletion.create(**kwargs)
+ resp = await openai.ChatCompletion.acreate(**kwargs)
return resp
except Exception as e: