Spaces:
Sleeping
Sleeping
Update src/agents/tools.py
Browse files- src/agents/tools.py +12 -12
src/agents/tools.py
CHANGED
|
@@ -8,17 +8,6 @@ from langchain_google_community.gmail.utils import (
|
|
| 8 |
)
|
| 9 |
import os
|
| 10 |
|
| 11 |
-
# Gmail Send Helper
|
| 12 |
-
|
| 13 |
-
def send_email_function(input_data):
|
| 14 |
-
if isinstance(input_data, str):
|
| 15 |
-
input_data = {"message": input_data}
|
| 16 |
-
|
| 17 |
-
input_data.setdefault("to", "default_advisor@gmail.com")
|
| 18 |
-
input_data.setdefault("subject", "Meeting Request")
|
| 19 |
-
input_data.setdefault("message", "Dear Advisor, the student would like to book a meeting with you.")
|
| 20 |
-
|
| 21 |
-
return gmail_send_tool(input_data)
|
| 22 |
|
| 23 |
def get_gmail_tool():
|
| 24 |
creds = Credentials(
|
|
@@ -58,12 +47,23 @@ def get_tools(rag_chain):
|
|
| 58 |
# === Gmail Tool via Hugging Face Secrets ===
|
| 59 |
try:
|
| 60 |
toolkit = get_gmail_tool()
|
| 61 |
-
global gmail_send_tool
|
| 62 |
gmail_send_tool = next(
|
| 63 |
(tool for tool in toolkit.get_tools() if tool.__class__.__name__ == "GmailSendMessage"),
|
| 64 |
None
|
| 65 |
)
|
| 66 |
if gmail_send_tool:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
tools.append(
|
| 68 |
Tool(
|
| 69 |
name="Gmail",
|
|
|
|
| 8 |
)
|
| 9 |
import os
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
def get_gmail_tool():
|
| 13 |
creds = Credentials(
|
|
|
|
| 47 |
# === Gmail Tool via Hugging Face Secrets ===
|
| 48 |
try:
|
| 49 |
toolkit = get_gmail_tool()
|
|
|
|
| 50 |
gmail_send_tool = next(
|
| 51 |
(tool for tool in toolkit.get_tools() if tool.__class__.__name__ == "GmailSendMessage"),
|
| 52 |
None
|
| 53 |
)
|
| 54 |
if gmail_send_tool:
|
| 55 |
+
# Gmail Send Helper
|
| 56 |
+
|
| 57 |
+
def send_email_function(input_data):
|
| 58 |
+
if isinstance(input_data, str):
|
| 59 |
+
input_data = {"message": input_data}
|
| 60 |
+
|
| 61 |
+
input_data.setdefault("to", "default_advisor@gmail.com")
|
| 62 |
+
input_data.setdefault("subject", "Meeting Request")
|
| 63 |
+
input_data.setdefault("message", "Dear Advisor, the student would like to book a meeting with you.")
|
| 64 |
+
|
| 65 |
+
return gmail_send_tool(input_data)
|
| 66 |
+
|
| 67 |
tools.append(
|
| 68 |
Tool(
|
| 69 |
name="Gmail",
|