Merge pull request #3244 from BerriAI/litellm_fix_linking_langfuse_slack_alerts

[Fix] Linking Langfuse Projects to Slack Alerts
This commit is contained in:
Ishaan Jaff 2024-04-23 12:53:18 -07:00 committed by GitHub
commit e15ce79833
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -34,6 +34,14 @@ class LangFuseLogger:
flush_interval=1, # flush interval in seconds
)
# set the current langfuse project id in the environ
# this is used by Alerting to link to the correct project
try:
project_id = self.Langfuse.client.projects.get().data[0].id
except:
project_id = None
os.environ["LANGFUSE_PROJECT_ID"] = project_id
if os.getenv("UPSTREAM_LANGFUSE_SECRET_KEY") is not None:
self.upstream_langfuse_secret_key = os.getenv(
"UPSTREAM_LANGFUSE_SECRET_KEY"

View file

@ -305,7 +305,14 @@ class ProxyLogging:
_litellm_params["metadata"]["trace_id"] = trace_id
_langfuse_host = os.environ.get("LANGFUSE_HOST", "https://cloud.langfuse.com")
request_info += f"\n🪢 Langfuse Trace: {_langfuse_host}/trace/{trace_id}"
_langfuse_project_id = os.environ.get("LANGFUSE_PROJECT_ID")
# langfuse urls look like: https://us.cloud.langfuse.com/project/************/traces/litellm-alert-trace-ididi9dk-09292-************
_langfuse_url = (
f"{_langfuse_host}/project/{_langfuse_project_id}/traces/{trace_id}"
)
request_info += f"\n🪢 Langfuse Trace: {_langfuse_url}"
return request_info
async def response_taking_too_long(