From c615af246fa7581eb0cadb9b70a15bf1bd6712e3 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Mon, 18 Sep 2023 08:49:27 -0700 Subject: [PATCH] add doc string for a completion --- litellm/main.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/litellm/main.py b/litellm/main.py index 23cfb2c581..40f957fc19 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -50,8 +50,25 @@ dotenv.load_dotenv() # Loading env variables using dotenv ####### COMPLETION ENDPOINTS ################ -############################################# + async def acompletion(*args, **kwargs): + """ + Asynchronously perform a completion() using the any LiteLLM model (ex gpt-3.5-turbo, claude-2) + + This function takes the same arguments as the 'completion' function and is used for asynchronous completion requests. + + Parameters: + *args: Positional arguments to pass to the 'litellm.completion' function. + **kwargs: Keyword arguments to pass to the 'litellm.completion' function. + + Returns: + The completion response, either as a litellm.ModelResponse Object or an async generator if 'stream' is set to True. + + Note: + - This function uses asynchronous programming to perform completions. + - It leverages the 'loop.run_in_executor' method to execute the synchronous 'completion' function. + - If 'stream' is set to True in kwargs, the function returns an async generator. + """ loop = asyncio.get_event_loop() # Use a partial function to pass your keyword arguments