litellm-enterprise 0.1.23__py3-none-any.whl → 0.1.24__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,79 @@
1
+ """
2
+ LiteLLM x SendGrid email integration.
3
+
4
+ Docs: https://docs.sendgrid.com/api-reference/mail-send/mail-send
5
+ """
6
+
7
+ import os
8
+ from typing import List
9
+
10
+ from litellm._logging import verbose_logger
11
+ from litellm.llms.custom_httpx.http_handler import (
12
+ get_async_httpx_client,
13
+ httpxSpecialProvider,
14
+ )
15
+
16
+ from .base_email import BaseEmailLogger
17
+
18
+
19
+ SENDGRID_API_ENDPOINT = "https://api.sendgrid.com/v3/mail/send"
20
+
21
+
22
+ class SendGridEmailLogger(BaseEmailLogger):
23
+ """
24
+ Send emails using SendGrid's Mail Send API.
25
+
26
+ Required env vars:
27
+ - SENDGRID_API_KEY
28
+ """
29
+
30
+ def __init__(self):
31
+ self.async_httpx_client = get_async_httpx_client(
32
+ llm_provider=httpxSpecialProvider.LoggingCallback
33
+ )
34
+ self.sendgrid_api_key = os.getenv("SENDGRID_API_KEY")
35
+ verbose_logger.debug("SendGrid Email Logger initialized.")
36
+
37
+ async def send_email(
38
+ self,
39
+ from_email: str,
40
+ to_email: List[str],
41
+ subject: str,
42
+ html_body: str,
43
+ ):
44
+ """
45
+ Send an email via SendGrid.
46
+ """
47
+ if not self.sendgrid_api_key:
48
+ raise ValueError("SENDGRID_API_KEY is not set")
49
+
50
+ verbose_logger.debug(
51
+ f"Sending email via SendGrid from {from_email} to {to_email} with subject {subject}"
52
+ )
53
+
54
+ payload = {
55
+ "from": {"email": from_email},
56
+ "personalizations": [
57
+ {
58
+ "to": [{"email": email} for email in to_email],
59
+ "subject": subject,
60
+ }
61
+ ],
62
+ "content": [
63
+ {
64
+ "type": "text/html",
65
+ "value": html_body,
66
+ }
67
+ ],
68
+ }
69
+
70
+ response = await self.async_httpx_client.post(
71
+ url=SENDGRID_API_ENDPOINT,
72
+ json=payload,
73
+ headers={"Authorization": f"Bearer {self.sendgrid_api_key}"},
74
+ )
75
+
76
+ verbose_logger.debug(
77
+ f"SendGrid response status={response.status_code}, body={response.text}"
78
+ )
79
+ return
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: litellm-enterprise
3
- Version: 0.1.23
3
+ Version: 0.1.24
4
4
  Summary: Package for LiteLLM Enterprise features
5
5
  License-File: LICENSE.md
6
6
  Author: BerriAI
@@ -102,6 +102,7 @@ litellm_enterprise/enterprise_callbacks/secrets_plugins/zendesk_secret_key.py,sh
102
102
  litellm_enterprise/enterprise_callbacks/send_emails/base_email.py,sha256=w4omD5Z7gMZABxn7DmAlOiCX6f7VwJ1KMKq_NXpdkLc,15523
103
103
  litellm_enterprise/enterprise_callbacks/send_emails/endpoints.py,sha256=hOEpM_q8MJAXlKMOtC9KbgvDVr_YFtF3reu9bjXkpsI,7017
104
104
  litellm_enterprise/enterprise_callbacks/send_emails/resend_email.py,sha256=lLG9W2hEOjn7lvMDKoaZGVCzr72HfreJuScMNOkE7FQ,1426
105
+ litellm_enterprise/enterprise_callbacks/send_emails/sendgrid_email.py,sha256=S6QhqPMX5gOpfG5nwZnZqHXlAOunOzucQ9TOC3SEGVE,2064
105
106
  litellm_enterprise/enterprise_callbacks/send_emails/smtp_email.py,sha256=_K3vGhyALVJWIzIk2oiHQbQPlYARdpPe-GA9hdl0vTg,1130
106
107
  litellm_enterprise/integrations/custom_guardrail.py,sha256=ZLVpqUZq9bR0vEFqVrlTJk0bYCZuFsXlw9XsdyK9t2E,1555
107
108
  litellm_enterprise/litellm_core_utils/litellm_logging.py,sha256=BKkQLPqebFbN-KeCbipGIPgdxHEfQkczImdhhzxKoFg,868
@@ -123,7 +124,7 @@ litellm_enterprise/proxy/vector_stores/endpoints.py,sha256=6Guh6zIH00dh2XXStn6Gb
123
124
  litellm_enterprise/types/enterprise_callbacks/send_emails.py,sha256=XLhpdGvBFxPkV7hcgQ1gELVF0vTs5d2LLOoXPzjr4K4,1929
124
125
  litellm_enterprise/types/proxy/audit_logging_endpoints.py,sha256=oSJVAuRD9r6ZjRCqNBFM-J5HSgOltsXts400b2aynRE,894
125
126
  litellm_enterprise/types/proxy/proxy_server.py,sha256=kdhtxsU2uok6-XO_ebugCv7PzYYmGgv4vh-XemHJnpM,146
126
- litellm_enterprise-0.1.23.dist-info/METADATA,sha256=diEqEOTj7rCVk-AVP3ns6m7_dJgjz4NXNyWpUmj6XQ4,1441
127
- litellm_enterprise-0.1.23.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
128
- litellm_enterprise-0.1.23.dist-info/licenses/LICENSE.md,sha256=nq3D9ZqOvRDT6hLkypQFTc3XsE15kbkg5rkkLJVSqKY,2251
129
- litellm_enterprise-0.1.23.dist-info/RECORD,,
127
+ litellm_enterprise-0.1.24.dist-info/METADATA,sha256=jzt105NYPdSsw24IuIAh4kC6kjUW210Z0rMgcg-AoHQ,1441
128
+ litellm_enterprise-0.1.24.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
129
+ litellm_enterprise-0.1.24.dist-info/licenses/LICENSE.md,sha256=nq3D9ZqOvRDT6hLkypQFTc3XsE15kbkg5rkkLJVSqKY,2251
130
+ litellm_enterprise-0.1.24.dist-info/RECORD,,