Open anunayajoshi opened 10 months ago
@anunayajoshi happy to run the script and check what's happening. Your testing doesn't seem to imply the async calls aren't being made at all- just not run when asyncio.sleep() occurs?
Renaming the issue to more precisely describe the problem.
For context, acompletions does make async calls. Here's an example of the load test script we run locally https://github.com/BerriAI/litellm/blob/37251d327d4b0fe564fd8d7223d5d96cde7752b1/litellm/tests/test_profiling_router.py#L4
Yup, apologise for the confusion. Reason I used asyncio.sleep() was to figure out when the POST requests were happening. Issue more specifically, is that the API calls to OpenAI don't happen during the asyncio.sleep, which I imagine means that they don't happen in the background while other tasks are run? Is it my assumption false?
Also apologise if the 2 test script functions isn't exactly the same, was testing out a bunch of stuff, but i think the output logs do prove what i mean.
We're using async openai as well. I suspect this has to do with where the client is being initialized (if no client is passed in, litellm initializes it when .completion() is called).
Is this issue also present when using litellm.Router()
? @anunayajoshi
https://docs.litellm.ai/docs/routing
I'll try and get to this today/tomorrow.
I have not tried using the router yet, will update you once I try it. am a bit caught up with other work atm, so might take a while
What happened?
I have a script that I pasted at the bottom of this issue, you can use to verify this. Thing to note is when the HTTP POST request to openAI is triggered.
Here are my outputs for the run_multiple_acompletions function
which only does the POST request to openAI when i run task.result(), and not during asyncio.sleep()
whereas when i use openai directly using the other function with openai directly,
it does the post requests, during the sleep.
Using acompletions, I am missing out on the intended latency saved by running my call asyncronously.
Script:
Relevant log output
Twitter / LinkedIn details
No response