fixing acompletion

This commit is contained in:
Krrish Dholakia 2023-08-03 13:53:38 -07:00
parent eb475ad0be
commit 82a75a9d92
5 changed files with 28 additions and 3 deletions

View file

@ -2,6 +2,7 @@ import os, openai, cohere, replicate, sys
from typing import Any
from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT
import traceback
from functools import partial
import dotenv
import traceback
import litellm
@ -261,8 +262,11 @@ def completion(
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)
# Use a partial function to pass your keyword arguments
func = partial(completion, *args, **kwargs)
# Call the synchronous function using run_in_executor
return await loop.run_in_executor(None, func)
### EMBEDDING ENDPOINTS ####################
@client