mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
Merge pull request #1185 from navidre/prevent_key_log_documentation
Sample code to prevent logging API key in callback to Slack
This commit is contained in:
commit
9fa2fe0c37
1 changed files with 13 additions and 1 deletions
|
|
@ -41,6 +41,18 @@ def send_slack_alert(
|
|||
# get it from https://api.slack.com/messaging/webhooks
|
||||
slack_webhook_url = os.environ['SLACK_WEBHOOK_URL'] # "https://hooks.slack.com/services/<>/<>/<>"
|
||||
|
||||
# Remove api_key from kwargs under litellm_params
|
||||
if kwargs.get('litellm_params'):
|
||||
kwargs['litellm_params'].pop('api_key', None)
|
||||
if kwargs['litellm_params'].get('metadata'):
|
||||
kwargs['litellm_params']['metadata'].pop('deployment', None)
|
||||
# Remove deployment under metadata
|
||||
if kwargs.get('metadata'):
|
||||
kwargs['metadata'].pop('deployment', None)
|
||||
# Prevent api_key from being logged
|
||||
if kwargs.get('api_key'):
|
||||
kwargs.pop('api_key', None)
|
||||
|
||||
# Define the text payload, send data available in litellm custom_callbacks
|
||||
text_payload = f"""LiteLLM Logging: kwargs: {str(kwargs)}\n\n, response: {str(completion_response)}\n\n, start time{str(start_time)} end time: {str(end_time)}
|
||||
"""
|
||||
|
|
@ -90,4 +102,4 @@ response = litellm.completion(
|
|||
- [Schedule Demo 👋](https://calendly.com/d/4mp-gd3-k5k/berriai-1-1-onboarding-litellm-hosted-version)
|
||||
- [Community Discord 💭](https://discord.gg/wuPM9dRgDw)
|
||||
- Our numbers 📞 +1 (770) 8783-106 / +1 (412) 618-6238
|
||||
- Our emails ✉️ ishaan@berri.ai / krrish@berri.ai
|
||||
- Our emails ✉️ ishaan@berri.ai / krrish@berri.ai
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue