forked from phoenix/litellm-mirror
add check for AsyncClient
This commit is contained in:
parent
e8f47e96c3
commit
ce0061d136
1 changed files with 11 additions and 1 deletions
|
@ -10,6 +10,8 @@ ALLOWED_FILES = [
|
||||||
"./litellm/llms/custom_httpx/http_handler.py",
|
"./litellm/llms/custom_httpx/http_handler.py",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
warning_msg = "this is a serious violation that can impact latency. Creating Async clients per request can add +500ms per request"
|
||||||
|
|
||||||
|
|
||||||
def check_for_async_http_handler(file_path):
|
def check_for_async_http_handler(file_path):
|
||||||
"""
|
"""
|
||||||
|
@ -39,7 +41,15 @@ def check_for_async_http_handler(file_path):
|
||||||
name.lower() for name in target_names
|
name.lower() for name in target_names
|
||||||
]:
|
]:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"found violation in file {file_path} line: {node.lineno}. Please use `get_async_httpx_client` instead."
|
f"found violation in file {file_path} line: {node.lineno}. Please use `get_async_httpx_client` instead. {warning_msg}"
|
||||||
|
)
|
||||||
|
# Add check for httpx.AsyncClient
|
||||||
|
elif isinstance(node.func, ast.Attribute) and isinstance(
|
||||||
|
node.func.value, ast.Name
|
||||||
|
):
|
||||||
|
if node.func.value.id == "httpx" and node.func.attr == "AsyncClient":
|
||||||
|
raise ValueError(
|
||||||
|
f"found violation in file {file_path} line: {node.lineno}. Please use `get_async_httpx_client` instead. {warning_msg}"
|
||||||
)
|
)
|
||||||
return violations
|
return violations
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue