updating helper functions with a try-except

This commit is contained in:
Krrish Dholakia 2023-08-01 13:03:03 -07:00
parent 2d75db70ad
commit 42bf542ba6
10 changed files with 123 additions and 109 deletions

View file

@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: litellm
Version: 0.1.2
Version: 0.1.207
Summary: Library to easily interface with LLM API providers
Author: BerriAI
License-File: LICENSE

View file

@ -3,6 +3,8 @@ README.md
setup.py
litellm/__init__.py
litellm/main.py
litellm/timeout.py
litellm/utils.py
litellm.egg-info/PKG-INFO
litellm.egg-info/SOURCES.txt
litellm.egg-info/dependency_links.txt

View file

@ -1,2 +1,7 @@
openai
cohere
pytest
anthropic
replicate
python-dotenv
openai[datalib]

View file

@ -10,8 +10,6 @@ import random
####### ENVIRONMENT VARIABLES ###################
dotenv.load_dotenv() # Loading env variables using dotenv
def get_optional_params(
# 12 optional params
functions = [],

View file

@ -101,6 +101,7 @@ def client(original_function):
####### HELPER FUNCTIONS ################
def set_callbacks(callback_list):
global sentry_sdk_instance, capture_exception, add_breadcrumb, posthog, slack_app, alerts_channel
try:
for callback in callback_list:
if callback == "sentry":
try:
@ -136,10 +137,13 @@ def set_callbacks(callback_list):
)
alerts_channel = os.environ["SLACK_API_CHANNEL"]
print_verbose(f"Initialized Slack App: {slack_app}")
except:
pass
def handle_failure(exception, traceback_exception, args, kwargs):
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 kwargs: {kwargs}")
@ -196,8 +200,11 @@ def handle_failure(exception, traceback_exception, args, kwargs):
}
failure_handler(call_details)
pass
except:
pass
def handle_success(*args, **kwargs):
try:
success_handler = additional_details.pop("success_handler", None)
failure_handler = additional_details.pop("failure_handler", None)
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):
success_handler(args, kwargs)
pass
except:
pass
def exception_type(model, original_exception):