diff --git a/litellm/__pycache__/main.cpython-311.pyc b/litellm/__pycache__/main.cpython-311.pyc index 114fba2782..e6d09b6c95 100644 Binary files a/litellm/__pycache__/main.cpython-311.pyc and b/litellm/__pycache__/main.cpython-311.pyc differ diff --git a/litellm/__pycache__/utils.cpython-311.pyc b/litellm/__pycache__/utils.cpython-311.pyc index 15aa082355..8de0072fec 100644 Binary files a/litellm/__pycache__/utils.cpython-311.pyc and b/litellm/__pycache__/utils.cpython-311.pyc differ diff --git a/litellm/main.py b/litellm/main.py index c414fd5fc3..01075761be 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -7,6 +7,7 @@ import traceback import litellm from litellm import client, logging, exception_type, timeout, success_callback, failure_callback import random +import asyncio from tenacity import ( retry, stop_after_attempt, @@ -69,7 +70,7 @@ def completion( temperature=1, top_p=1, n=1, stream=False, stop=None, max_tokens=float('inf'), presence_penalty=0, frequency_penalty=0, logit_bias={}, user="", # Optional liteLLM function params - *, api_key=None, force_timeout=60, azure=False, logger_fn=None, verbose=False + *, return_async=False, api_key=None, force_timeout=60, azure=False, logger_fn=None, verbose=False ): try: # check if user passed in any of the OpenAI optional params @@ -254,6 +255,12 @@ def completion( raise exception_type(model=model, original_exception=e) +async def acompletion(*args, **kwargs): + loop = asyncio.get_event_loop() + + # Call the synchronous function using run_in_executor() + return loop.run_in_executor(None, completion, *args, **kwargs) + ### EMBEDDING ENDPOINTS #################### @client @timeout(60) ## set timeouts, in case calls hang (e.g. Azure) - default is 60s, override with `force_timeout`