only show error log dashboard on fail

This commit is contained in:
ishaan-jaff 2023-09-20 20:09:02 -07:00
parent fc10cf5eeb
commit 2ba8e9bc02

View file

@ -1881,15 +1881,17 @@ def exception_type(
global user_logger_fn, liteDebuggerClient global user_logger_fn, liteDebuggerClient
exception_mapping_worked = False exception_mapping_worked = False
if litellm.set_verbose == True:
litellm.error_logs['EXCEPTION'] = original_exception litellm.error_logs['EXCEPTION'] = original_exception
litellm.error_logs['KWARGS'] = completion_kwargs litellm.error_logs['KWARGS'] = completion_kwargs
try:
# code to show users their litellm error dashboard
import urllib.parse import urllib.parse
import json import json
for log_key in litellm.error_logs: for log_key in litellm.error_logs:
current_logs = litellm.error_logs[log_key] current_logs = litellm.error_logs[log_key]
if type(current_logs) == dict: if type(current_logs) == dict:
filtered_error_logs = {key: value for key, value in current_logs.items() if isinstance(value, (str, int, float, bool, list, dict))} filtered_error_logs = {key: str(value) for key, value in current_logs.items()}
litellm.error_logs[log_key] = filtered_error_logs litellm.error_logs[log_key] = filtered_error_logs
else: else:
litellm.error_logs[log_key] = str(current_logs) litellm.error_logs[log_key] = str(current_logs)
@ -1898,14 +1900,12 @@ def exception_type(
error_logs_json = json.dumps(litellm.error_logs) error_logs_json = json.dumps(litellm.error_logs)
# URL-encode the JSON data # URL-encode the JSON data
encoded_data = urllib.parse.quote(error_logs_json) encoded_data = urllib.parse.quote(error_logs_json)
print(encoded_data)
# Print the encoded data (this is what you can include in a URL)
print("\033[91m" + str(litellm.error_logs) + "\033[0m")
decoded_data = urllib.parse.unquote(encoded_data) print("👉 view error logs:")
print("\033[91m" + '\033[4m' + 'https://logs.litellm.ai/?data=' + str(encoded_data) + "\033[0m")
# Print the decoded data except:
print(decoded_data) pass
try: try:
if isinstance(original_exception, OriginalError): if isinstance(original_exception, OriginalError):
# Handle the OpenAIError # Handle the OpenAIError