forked from phoenix/litellm-mirror
updating helper functions with a try-except
This commit is contained in:
parent
2d75db70ad
commit
42bf542ba6
10 changed files with 123 additions and 109 deletions
|
@ -1,6 +1,6 @@
|
||||||
Metadata-Version: 2.1
|
Metadata-Version: 2.1
|
||||||
Name: litellm
|
Name: litellm
|
||||||
Version: 0.1.2
|
Version: 0.1.207
|
||||||
Summary: Library to easily interface with LLM API providers
|
Summary: Library to easily interface with LLM API providers
|
||||||
Author: BerriAI
|
Author: BerriAI
|
||||||
License-File: LICENSE
|
License-File: LICENSE
|
||||||
|
|
|
@ -3,6 +3,8 @@ README.md
|
||||||
setup.py
|
setup.py
|
||||||
litellm/__init__.py
|
litellm/__init__.py
|
||||||
litellm/main.py
|
litellm/main.py
|
||||||
|
litellm/timeout.py
|
||||||
|
litellm/utils.py
|
||||||
litellm.egg-info/PKG-INFO
|
litellm.egg-info/PKG-INFO
|
||||||
litellm.egg-info/SOURCES.txt
|
litellm.egg-info/SOURCES.txt
|
||||||
litellm.egg-info/dependency_links.txt
|
litellm.egg-info/dependency_links.txt
|
||||||
|
|
|
@ -1,2 +1,7 @@
|
||||||
openai
|
openai
|
||||||
cohere
|
cohere
|
||||||
|
pytest
|
||||||
|
anthropic
|
||||||
|
replicate
|
||||||
|
python-dotenv
|
||||||
|
openai[datalib]
|
||||||
|
|
Binary file not shown.
|
@ -10,8 +10,6 @@ import random
|
||||||
####### ENVIRONMENT VARIABLES ###################
|
####### ENVIRONMENT VARIABLES ###################
|
||||||
dotenv.load_dotenv() # Loading env variables using dotenv
|
dotenv.load_dotenv() # Loading env variables using dotenv
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_optional_params(
|
def get_optional_params(
|
||||||
# 12 optional params
|
# 12 optional params
|
||||||
functions = [],
|
functions = [],
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -101,6 +101,7 @@ def client(original_function):
|
||||||
####### HELPER FUNCTIONS ################
|
####### HELPER FUNCTIONS ################
|
||||||
def set_callbacks(callback_list):
|
def set_callbacks(callback_list):
|
||||||
global sentry_sdk_instance, capture_exception, add_breadcrumb, posthog, slack_app, alerts_channel
|
global sentry_sdk_instance, capture_exception, add_breadcrumb, posthog, slack_app, alerts_channel
|
||||||
|
try:
|
||||||
for callback in callback_list:
|
for callback in callback_list:
|
||||||
if callback == "sentry":
|
if callback == "sentry":
|
||||||
try:
|
try:
|
||||||
|
@ -136,10 +137,13 @@ def set_callbacks(callback_list):
|
||||||
)
|
)
|
||||||
alerts_channel = os.environ["SLACK_API_CHANNEL"]
|
alerts_channel = os.environ["SLACK_API_CHANNEL"]
|
||||||
print_verbose(f"Initialized Slack App: {slack_app}")
|
print_verbose(f"Initialized Slack App: {slack_app}")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def handle_failure(exception, traceback_exception, args, kwargs):
|
def handle_failure(exception, traceback_exception, args, kwargs):
|
||||||
global sentry_sdk_instance, capture_exception, add_breadcrumb, posthog, slack_app, alerts_channel
|
global sentry_sdk_instance, capture_exception, add_breadcrumb, posthog, slack_app, alerts_channel
|
||||||
|
try:
|
||||||
print_verbose(f"handle_failure args: {args}")
|
print_verbose(f"handle_failure args: {args}")
|
||||||
print_verbose(f"handle_failure kwargs: {kwargs}")
|
print_verbose(f"handle_failure kwargs: {kwargs}")
|
||||||
|
|
||||||
|
@ -196,8 +200,11 @@ def handle_failure(exception, traceback_exception, args, kwargs):
|
||||||
}
|
}
|
||||||
failure_handler(call_details)
|
failure_handler(call_details)
|
||||||
pass
|
pass
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def handle_success(*args, **kwargs):
|
def handle_success(*args, **kwargs):
|
||||||
|
try:
|
||||||
success_handler = additional_details.pop("success_handler", None)
|
success_handler = additional_details.pop("success_handler", None)
|
||||||
failure_handler = additional_details.pop("failure_handler", None)
|
failure_handler = additional_details.pop("failure_handler", None)
|
||||||
additional_details["Event_Name"] = additional_details.pop("successful_event_name", "litellm.succes_query")
|
additional_details["Event_Name"] = additional_details.pop("successful_event_name", "litellm.succes_query")
|
||||||
|
@ -225,6 +232,8 @@ def handle_success(*args, **kwargs):
|
||||||
if success_handler and callable(success_handler):
|
if success_handler and callable(success_handler):
|
||||||
success_handler(args, kwargs)
|
success_handler(args, kwargs)
|
||||||
pass
|
pass
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def exception_type(model, original_exception):
|
def exception_type(model, original_exception):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue