chore: initial snapshot for gitea/github upload

This commit is contained in:
Your Name
2026-03-26 16:04:46 +08:00
commit a699a1ac98
3497 changed files with 1586237 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
EMAIL_FOOTER = """
<div class="footer">
<p>© 2025 LiteLLM. All rights reserved.</p>
<div class="social-links">
<a href="https://twitter.com/litellm">Twitter</a> •
<a href="https://github.com/BerriAI/litellm">GitHub</a> •
<a href="https://litellm.ai">Website</a>
</div>
</div>
"""

View File

@@ -0,0 +1,212 @@
"""
Modern Email Templates for LiteLLM Email Service with professional styling
"""
KEY_CREATED_EMAIL_TEMPLATE = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your API Key is Ready</title>
<style>
body, html {{
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
color: #333333;
background-color: #f8fafc;
line-height: 1.5;
}}
.container {{
max-width: 560px;
margin: 20px auto;
background-color: #ffffff;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}}
.header {{
padding: 24px 0;
text-align: center;
border-bottom: 1px solid #f1f5f9;
}}
.content {{
padding: 32px 40px;
}}
.greeting {{
font-size: 16px;
margin-bottom: 20px;
color: #333333;
}}
.message {{
font-size: 16px;
color: #333333;
margin-bottom: 20px;
}}
.key-container {{
margin: 28px 0;
}}
.key-label {{
font-size: 14px;
font-weight: 500;
margin-bottom: 8px;
color: #4b5563;
}}
.key {{
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
word-break: break-all;
background-color: #f9fafb;
border-radius: 6px;
padding: 16px;
font-size: 14px;
border: 1px solid #e5e7eb;
color: #4338ca;
}}
h2 {{
font-size: 18px;
font-weight: 600;
margin-top: 36px;
margin-bottom: 16px;
color: #333333;
}}
.budget-info {{
background-color: #f0fdf4;
border-radius: 6px;
padding: 14px 16px;
margin: 24px 0;
font-size: 14px;
border: 1px solid #dcfce7;
}}
.code-block {{
background-color: #f8fafc;
color: #334155;
border-radius: 8px;
padding: 20px;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
font-size: 13px;
overflow-x: auto;
margin: 20px 0;
line-height: 1.6;
border: 1px solid #e2e8f0;
}}
.code-comment {{
color: #64748b;
}}
.code-string {{
color: #0369a1;
}}
.code-keyword {{
color: #7e22ce;
}}
.btn {{
display: inline-block;
padding: 8px 20px;
background-color: #6366f1;
color: #ffffff !important;
text-decoration: none;
border-radius: 6px;
font-weight: 500;
margin-top: 24px;
text-align: center;
font-size: 14px;
transition: background-color 0.2s;
}}
.btn:hover {{
background-color: #4f46e5;
color: #ffffff !important;
}}
.separator {{
height: 1px;
background-color: #f1f5f9;
margin: 40px 0 30px;
}}
.footer {{
padding: 24px 40px 32px;
text-align: center;
color: #64748b;
font-size: 13px;
background-color: #f8fafc;
border-top: 1px solid #f1f5f9;
}}
.social-links {{
margin-top: 12px;
}}
.social-links a {{
display: inline-block;
margin: 0 8px;
color: #64748b;
text-decoration: none;
}}
@media only screen and (max-width: 620px) {{
.container {{
width: 100%;
margin: 0;
border-radius: 0;
}}
.content {{
padding: 24px 20px;
}}
.footer {{
padding: 20px;
}}
}}
</style>
</head>
<body>
<div class="container">
<div class="header">
<img src="{email_logo_url}" alt="LiteLLM Logo" style="height: 32px; width: auto;">
</div>
<div class="content">
<div class="greeting">
<p>Hi {recipient_email},</p>
</div>
<div class="message">
<p>Great news! Your LiteLLM API key is ready to use.</p>
</div>
<div class="budget-info">
<p style="margin: 0;"><strong>Monthly Budget:</strong> {key_budget}</p>
</div>
<div class="key-container">
<div class="key-label">Your API Key</div>
<div class="key">{key_token}</div>
</div>
<h2>Quick Start Guide</h2>
<p>Here's how to use your key with the OpenAI SDK:</p>
<div class="code-block">
<span class="code-keyword">import</span> openai<br>
<br>
client = openai.OpenAI(<br>
&nbsp;&nbsp;api_key=<span class="code-string">"{key_token}"</span>,<br>
&nbsp;&nbsp;base_url=<span class="code-string">"{base_url}"</span><br>
)<br>
<br>
response = client.chat.completions.create(<br>
&nbsp;&nbsp;model=<span class="code-string">"gpt-3.5-turbo"</span>, <span class="code-comment"># model to send to the proxy</span><br>
&nbsp;&nbsp;messages = [<br>
&nbsp;&nbsp;&nbsp;&nbsp;{{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="code-string">"role"</span>: <span class="code-string">"user"</span>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="code-string">"content"</span>: <span class="code-string">"this is a test request, write a short poem"</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;}}<br>
&nbsp;&nbsp;]<br>
)
</div>
<a href="https://docs.litellm.ai/docs/proxy/user_keys" class="btn" style="color: #ffffff;">View Documentation</a>
<div class="separator"></div>
<h2>Need Help?</h2>
<p>If you have any questions or need assistance, please contact us at {email_support_contact}.</p>
</div>
{email_footer}
</div>
</body>
</html>
"""

View File

@@ -0,0 +1,224 @@
"""
Modern Email Templates for LiteLLM Email Service with professional styling
"""
KEY_ROTATED_EMAIL_TEMPLATE = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your API Key Has Been Rotated</title>
<style>
body, html {{
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
color: #333333;
background-color: #f8fafc;
line-height: 1.5;
}}
.container {{
max-width: 560px;
margin: 20px auto;
background-color: #ffffff;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}}
.header {{
padding: 24px 0;
text-align: center;
border-bottom: 1px solid #f1f5f9;
}}
.content {{
padding: 32px 40px;
}}
.greeting {{
font-size: 16px;
margin-bottom: 20px;
color: #333333;
}}
.message {{
font-size: 16px;
color: #333333;
margin-bottom: 20px;
}}
.key-container {{
margin: 28px 0;
}}
.key-label {{
font-size: 14px;
font-weight: 500;
margin-bottom: 8px;
color: #4b5563;
}}
.key {{
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
word-break: break-all;
background-color: #f9fafb;
border-radius: 6px;
padding: 16px;
font-size: 14px;
border: 1px solid #e5e7eb;
color: #4338ca;
}}
h2 {{
font-size: 18px;
font-weight: 600;
margin-top: 36px;
margin-bottom: 16px;
color: #333333;
}}
.budget-info {{
background-color: #f0fdf4;
border-radius: 6px;
padding: 14px 16px;
margin: 24px 0;
font-size: 14px;
border: 1px solid #dcfce7;
}}
.code-block {{
background-color: #f8fafc;
color: #334155;
border-radius: 8px;
padding: 20px;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
font-size: 13px;
overflow-x: auto;
margin: 20px 0;
line-height: 1.6;
border: 1px solid #e2e8f0;
}}
.code-comment {{
color: #64748b;
}}
.code-string {{
color: #0369a1;
}}
.code-keyword {{
color: #7e22ce;
}}
.btn {{
display: inline-block;
padding: 8px 20px;
background-color: #6366f1;
color: #ffffff !important;
text-decoration: none;
border-radius: 6px;
font-weight: 500;
margin-top: 24px;
text-align: center;
font-size: 14px;
transition: background-color 0.2s;
}}
.btn:hover {{
background-color: #4f46e5;
color: #ffffff !important;
}}
.separator {{
height: 1px;
background-color: #f1f5f9;
margin: 40px 0 30px;
}}
.footer {{
padding: 24px 40px 32px;
text-align: center;
color: #64748b;
font-size: 13px;
background-color: #f8fafc;
border-top: 1px solid #f1f5f9;
}}
.social-links {{
margin-top: 12px;
}}
.social-links a {{
display: inline-block;
margin: 0 8px;
color: #64748b;
text-decoration: none;
}}
@media only screen and (max-width: 620px) {{
.container {{
width: 100%;
margin: 0;
border-radius: 0;
}}
.content {{
padding: 24px 20px;
}}
.footer {{
padding: 20px;
}}
}}
</style>
</head>
<body>
<div class="container">
<div class="header">
<img src="{email_logo_url}" alt="LiteLLM Logo" style="height: 32px; width: auto;">
</div>
<div class="content">
<div class="greeting">
<p>Hi {recipient_email},</p>
</div>
<div class="message">
<p><strong>Your LiteLLM API key has been rotated</strong> as part of our ongoing commitment to security best practices.</p>
<p style="margin-top: 16px;">Your previous API key has been deactivated and will no longer work. Please update your applications with the new key below.</p>
</div>
<div class="key-container">
<div class="key-label">Your New API Key</div>
<div class="key">{key_token}</div>
</div>
<div class="budget-info">
<p style="margin: 0;"><strong>Monthly Budget:</strong> {key_budget}</p>
</div>
<h2>Action Required</h2>
<p>Update your applications and systems with the new API key. Here's an example:</p>
<div class="code-block">
<span class="code-keyword">import</span> openai<br>
<br>
client = openai.OpenAI(<br>
&nbsp;&nbsp;api_key=<span class="code-string">"{key_token}"</span>,<br>
&nbsp;&nbsp;base_url=<span class="code-string">"{base_url}"</span><br>
)<br>
<br>
response = client.chat.completions.create(<br>
&nbsp;&nbsp;model=<span class="code-string">"gpt-3.5-turbo"</span>, <span class="code-comment"># model to send to the proxy</span><br>
&nbsp;&nbsp;messages = [<br>
&nbsp;&nbsp;&nbsp;&nbsp;{{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="code-string">"role"</span>: <span class="code-string">"user"</span>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="code-string">"content"</span>: <span class="code-string">"this is a test request, write a short poem"</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;}}<br>
&nbsp;&nbsp;]<br>
)
</div>
<div class="separator"></div>
<h2>Security Best Practices</h2>
<p style="margin-bottom: 12px;">To keep your API key secure:</p>
<ul style="margin: 0; padding-left: 20px; color: #333333;">
<li style="margin-bottom: 8px;">Never share your API key publicly or commit it to version control</li>
<li style="margin-bottom: 8px;">Store it securely using environment variables or secret management systems</li>
<li style="margin-bottom: 8px;">Monitor your API usage regularly for any unusual activity</li>
<li style="margin-bottom: 8px;">Rotate your keys periodically as a security best practice</li>
</ul>
<a href="https://docs.litellm.ai/docs/proxy/user_keys" class="btn" style="color: #ffffff;">View Documentation</a>
<div class="separator"></div>
<h2>Need Help?</h2>
<p>If you have any questions or need assistance updating your systems, please contact us at {email_support_contact}.</p>
</div>
{email_footer}
</div>
</body>
</html>
"""

View File

@@ -0,0 +1,134 @@
"""
Email Templates used by the LiteLLM Email Service in slack_alerting.py
"""
KEY_CREATED_EMAIL_TEMPLATE = """
<img src="{email_logo_url}" alt="LiteLLM Logo" width="150" height="50" />
<p> Hi {recipient_email}, <br/>
I'm happy to provide you with an OpenAI Proxy API Key, loaded with ${key_budget} per month. <br /> <br />
<b>
Key: <pre>{key_token}</pre> <br>
</b>
<h2>Usage Example</h2>
Detailed Documentation on <a href="https://docs.litellm.ai/docs/proxy/user_keys">Usage with OpenAI Python SDK, Langchain, LlamaIndex, Curl</a>
<pre>
import openai
client = openai.OpenAI(
api_key="{key_token}",
base_url={{base_url}}
)
response = client.chat.completions.create(
model="gpt-3.5-turbo", # model to send to the proxy
messages = [
{{
"role": "user",
"content": "this is a test request, write a short poem"
}}
]
)
</pre>
If you have any questions, please send an email to {email_support_contact} <br /> <br />
Best, <br />
The LiteLLM team <br />
"""
USER_INVITED_EMAIL_TEMPLATE = """
<img src="{email_logo_url}" alt="LiteLLM Logo" width="150" height="50" />
<p> Hi {recipient_email}, <br/>
You were invited to use OpenAI Proxy API for team {team_name} <br /> <br />
<a href="{base_url}" style="display: inline-block; padding: 10px 20px; background-color: #87ceeb; color: #fff; text-decoration: none; border-radius: 20px;">Get Started here</a> <br /> <br />
If you have any questions, please send an email to {email_support_contact} <br /> <br />
Best, <br />
The LiteLLM team <br />
"""
SOFT_BUDGET_ALERT_EMAIL_TEMPLATE = """
<img src="{email_logo_url}" alt="LiteLLM Logo" width="150" height="50" />
<p> Hi {recipient_email}, <br/>
Your LiteLLM API key has crossed its <b>soft budget limit of {soft_budget}</b>. <br /> <br />
<b>Current Spend:</b> {spend} <br />
<b>Soft Budget:</b> {soft_budget} <br />
{max_budget_info}
<p style="color: #dc2626; font-weight: 500;">
⚠️ Note: Your API requests will continue to work, but you should monitor your usage closely.
If you reach your maximum budget, requests will be rejected.
</p>
You can view your usage and manage your budget in the <a href="{base_url}">LiteLLM Dashboard</a>. <br /> <br />
If you have any questions, please send an email to {email_support_contact} <br /> <br />
Best, <br />
The LiteLLM team <br />
"""
TEAM_SOFT_BUDGET_ALERT_EMAIL_TEMPLATE = """
<img src="{email_logo_url}" alt="LiteLLM Logo" width="150" height="50" />
<p> Hi {team_alias} team member, <br/>
Your LiteLLM team has crossed its <b>soft budget limit of {soft_budget}</b>. <br /> <br />
<b>Current Spend:</b> {spend} <br />
<b>Soft Budget:</b> {soft_budget} <br />
{max_budget_info}
<p style="color: #dc2626; font-weight: 500;">
⚠️ Note: Your API requests will continue to work, but you should monitor your usage closely.
If you reach your maximum budget, requests will be rejected.
</p>
You can view your usage and manage your budget in the <a href="{base_url}">LiteLLM Dashboard</a>. <br /> <br />
If you have any questions, please send an email to {email_support_contact} <br /> <br />
Best, <br />
The LiteLLM team <br />
"""
MAX_BUDGET_ALERT_EMAIL_TEMPLATE = """
<img src="{email_logo_url}" alt="LiteLLM Logo" width="150" height="50" />
<p> Hi {recipient_email}, <br/>
Your LiteLLM API key has reached <b>{percentage}% of its maximum budget</b>. <br /> <br />
<b>Current Spend:</b> {spend} <br />
<b>Maximum Budget:</b> {max_budget} <br />
<b>Alert Threshold:</b> {alert_threshold} ({percentage}%) <br />
<p style="color: #dc2626; font-weight: 500;">
⚠️ Warning: You are approaching your maximum budget limit.
Once you reach your maximum budget of {max_budget}, all API requests will be rejected.
</p>
You can view your usage and manage your budget in the <a href="{base_url}">LiteLLM Dashboard</a>. <br /> <br />
If you have any questions, please send an email to {email_support_contact} <br /> <br />
Best, <br />
The LiteLLM team <br />
"""

View File

@@ -0,0 +1,175 @@
"""
Modern Email Templates for LiteLLM Email Service with professional styling
"""
USER_INVITATION_EMAIL_TEMPLATE = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to LiteLLM</title>
<style>
body, html {{
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
color: #333333;
background-color: #f8f8f8;
line-height: 1.5;
}}
.container {{
max-width: 560px;
margin: 20px auto;
background-color: #ffffff;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}}
.logo {{
padding: 24px 0 0 24px;
text-align: left;
}}
.greeting {{
font-size: 16px;
margin-bottom: 20px;
color: #333333;
}}
.content {{
padding: 24px 40px 32px;
}}
h1 {{
font-size: 24px;
font-weight: 600;
margin-top: 24px;
margin-bottom: 16px;
color: #333333;
}}
p {{
font-size: 16px;
color: #333333;
margin-bottom: 16px;
line-height: 1.5;
}}
.intro-text {{
margin-bottom: 24px;
}}
.link {{
color: #6366f1;
text-decoration: none;
font-weight: 500;
}}
.link:hover {{
text-decoration: underline;
}}
.link-with-arrow {{
display: inline-flex;
align-items: center;
color: #6366f1;
text-decoration: none;
font-weight: 500;
margin-bottom: 20px;
}}
.link-with-arrow:hover {{
text-decoration: underline;
}}
.arrow {{
margin-left: 6px;
}}
.divider {{
height: 1px;
background-color: #f1f1f1;
margin: 24px 0;
}}
.btn {{
display: inline-block;
padding: 12px 24px;
background-color: #5c5ce0;
color: #ffffff !important;
text-decoration: none;
border-radius: 6px;
font-weight: 500;
margin-top: 12px;
text-align: center;
font-size: 15px;
transition: background-color 0.2s ease;
}}
.btn:hover {{
background-color: #4b4bb3;
}}
.btn-container {{
text-align: center;
margin: 24px 0;
}}
.footer {{
padding: 24px 40px 32px;
text-align: left;
color: #666;
font-size: 14px;
}}
.quickstart {{
margin-top: 32px;
}}
</style>
</head>
<body>
<div class="container">
<div class="logo">
<img src="{email_logo_url}" alt="LiteLLM Logo" style="height: 32px; width: auto;">
</div>
<div class="content">
<h1>Welcome to LiteLLM</h1>
<div class="greeting">
<p>Hi {recipient_email},</p>
</div>
<div class="intro-text">
<p>LiteLLM allows you to call 100+ LLM providers in the OpenAI API format. Get started by accepting your invitation.</p>
</div>
<div class="btn-container">
<a href="{base_url}" class="btn">Accept Invitation</a>
</div>
<div class="quickstart">
<p>Here's a quickstart guide to get you started:</p>
</div>
<div class="divider"></div>
<a href="https://docs.litellm.ai/docs/proxy/user_keys" class="link-with-arrow">
Make your first LLM request →
<span class="arrow"></span>
</a>
<p>Making LLM requests with OpenAI SDK, Langchain, LlamaIndex, and more.</p>
<div class="divider"></div>
<a href="https://docs.litellm.ai/docs/supported_endpoints" class="link-with-arrow">
Supported Endpoints →
<span class="arrow"></span>
</a>
<p>View all supported LLM endpoints on LiteLLM (/chat/completions, /embeddings, /responses etc.)</p>
<div class="divider"></div>
<a href="https://docs.litellm.ai/docs/pass_through/vertex_ai" class="link-with-arrow">
Passthrough Endpoints →
<span class="arrow"></span>
</a>
<p>We support calling VertexAI, Anthropic, and other providers in their native API format.</p>
<div class="divider"></div>
<p>Thanks for signing up. We're here to help you and your team. If you have any questions, contact us at {email_support_contact}</p>
</div>
{email_footer}
</div>
</body>
</html>
"""