forked from phoenix/litellm-mirror
only show error log dashboard on fail
This commit is contained in:
parent
fc10cf5eeb
commit
2ba8e9bc02
1 changed files with 22 additions and 22 deletions
|
@ -1881,31 +1881,31 @@ def exception_type(
|
||||||
global user_logger_fn, liteDebuggerClient
|
global user_logger_fn, liteDebuggerClient
|
||||||
exception_mapping_worked = False
|
exception_mapping_worked = False
|
||||||
|
|
||||||
litellm.error_logs['EXCEPTION'] = original_exception
|
if litellm.set_verbose == True:
|
||||||
litellm.error_logs['KWARGS'] = completion_kwargs
|
litellm.error_logs['EXCEPTION'] = original_exception
|
||||||
|
litellm.error_logs['KWARGS'] = completion_kwargs
|
||||||
|
try:
|
||||||
|
# code to show users their litellm error dashboard
|
||||||
|
import urllib.parse
|
||||||
|
import json
|
||||||
|
for log_key in litellm.error_logs:
|
||||||
|
current_logs = litellm.error_logs[log_key]
|
||||||
|
if type(current_logs) == dict:
|
||||||
|
filtered_error_logs = {key: str(value) for key, value in current_logs.items()}
|
||||||
|
litellm.error_logs[log_key] = filtered_error_logs
|
||||||
|
else:
|
||||||
|
litellm.error_logs[log_key] = str(current_logs)
|
||||||
|
|
||||||
import urllib.parse
|
# Convert the filtered_error_logs dictionary to a JSON string
|
||||||
import json
|
error_logs_json = json.dumps(litellm.error_logs)
|
||||||
for log_key in litellm.error_logs:
|
# URL-encode the JSON data
|
||||||
current_logs = litellm.error_logs[log_key]
|
encoded_data = urllib.parse.quote(error_logs_json)
|
||||||
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))}
|
|
||||||
litellm.error_logs[log_key] = filtered_error_logs
|
|
||||||
else:
|
|
||||||
litellm.error_logs[log_key] = str(current_logs)
|
|
||||||
|
|
||||||
# Convert the filtered_error_logs dictionary to a JSON string
|
print("👉 view error logs:")
|
||||||
error_logs_json = json.dumps(litellm.error_logs)
|
print("\033[91m" + '\033[4m' + 'https://logs.litellm.ai/?data=' + str(encoded_data) + "\033[0m")
|
||||||
# URL-encode the JSON data
|
|
||||||
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)
|
except:
|
||||||
|
pass
|
||||||
# Print the decoded data
|
|
||||||
print(decoded_data)
|
|
||||||
try:
|
try:
|
||||||
if isinstance(original_exception, OriginalError):
|
if isinstance(original_exception, OriginalError):
|
||||||
# Handle the OpenAIError
|
# Handle the OpenAIError
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue