Skip to content

Commit

Permalink
Merge pull request #1839 from BerriAI/litellm_slack_langfuse_alerting
Browse files Browse the repository at this point in the history
fix(proxy/utils.py): if langfuse trace id passed in, include in slack alert
  • Loading branch information
krrishdholakia authored Feb 6, 2024
2 parents db68b83 + 9e9fb74 commit 0fd64bc
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions litellm/proxy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,20 @@ async def response_taking_too_long(
if request_data is not None:
model = request_data.get("model", "")
messages = request_data.get("messages", "")
# try casting messages to str and get the first 100 characters, else mark as None
try:
trace_id = request_data.get("metadata", {}).get(
"trace_id", None
) # get langfuse trace id
if trace_id is not None:
messages = str(messages)
messages = messages[:10000]
except:
messages = None
messages = messages[:100]
messages = f"{messages}\nLangfuse Trace Id: {trace_id}"
else:
# try casting messages to str and get the first 100 characters, else mark as None
try:
messages = str(messages)
messages = messages[:10000]
except:
messages = None

request_info = f"\nRequest Model: {model}\nMessages: {messages}"
else:
Expand Down

0 comments on commit 0fd64bc

Please sign in to comment.