-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] litellm.acompletion() make Langfuse success handler non blocking #1519
Merged
ishaan-jaff
merged 9 commits into
main
from
litellm_proxy_make_success_handler_non_blocking
Jan 19, 2024
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a9c5b02
(v0) fix
ishaan-jaff cd08a02
(test) add blocking callback test
ishaan-jaff e6b5152
(chore) update load test
ishaan-jaff f2cfb76
(fix) use asyncio run_in_executor
ishaan-jaff 6a69547
(fix) async langfuse logger
ishaan-jaff cb40f58
(fix) return usage in mock_completion
ishaan-jaff 2f429f3
(test) test latency added with langfuse call
ishaan-jaff cb99cd1
(feat) log cache_hit as langfuse tags
ishaan-jaff 8cf8da1
(test) langfuse_latency_test_user
ishaan-jaff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import json | ||
import sys | ||
import os | ||
import io, asyncio | ||
|
||
import logging | ||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
sys.path.insert(0, os.path.abspath("../..")) | ||
|
||
from litellm import completion | ||
import litellm | ||
|
||
litellm.num_retries = 3 | ||
import time | ||
import pytest | ||
|
||
|
||
async def custom_callback( | ||
kwargs, # kwargs to completion | ||
completion_response, # response from completion | ||
start_time, | ||
end_time, # start/end time | ||
): | ||
# Your custom code here | ||
print("LITELLM: in custom callback function") | ||
print("kwargs", kwargs) | ||
print("completion_response", completion_response) | ||
print("start_time", start_time) | ||
print("end_time", end_time) | ||
time.sleep(1) | ||
|
||
return | ||
|
||
|
||
def test_time_to_run_10_completions(): | ||
litellm.callbacks = [custom_callback] | ||
start = time.time() | ||
|
||
asyncio.run( | ||
litellm.acompletion( | ||
model="gpt-3.5-turbo", messages=[{"role": "user", "content": "hello"}] | ||
) | ||
) | ||
end = time.time() | ||
print(f"Time to run 10 completions: {end - start}") | ||
|
||
|
||
test_time_to_run_10_completions() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ishaan-jaff how does switching create task for threads solve the issue?
i'm also concerned about creating too many threads here, which would cause issues in high-traffic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krrishdholakia I update the conversation of this PR with notes