Spaces:
Runtime error
Runtime error
chnages in checking
Browse files
app/nodes/check_email_exist_node.py
CHANGED
|
@@ -1,15 +1,15 @@
|
|
| 1 |
-
|
| 2 |
from app.state.state import EmailAgentState
|
| 3 |
from langchain_google_community import GmailToolkit
|
| 4 |
from app.gmail_auth import gmail_toolkit ,api_resource
|
| 5 |
-
|
| 6 |
def check_previous_email_exist_node(state: EmailAgentState):
|
| 7 |
-
# Search for previous interactions
|
| 8 |
search_tool = [t for t in gmail_toolkit.get_tools() if t.name == "search_gmail"][0]
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
if len(results) == 0:
|
| 12 |
-
# No history found - flag this for the conditional edge
|
| 13 |
return {"draft_context": "No relevant past context found."}
|
| 14 |
|
| 15 |
def after_mail_check(state: EmailAgentState):
|
|
|
|
|
|
|
| 1 |
from app.state.state import EmailAgentState
|
| 2 |
from langchain_google_community import GmailToolkit
|
| 3 |
from app.gmail_auth import gmail_toolkit ,api_resource
|
|
|
|
| 4 |
def check_previous_email_exist_node(state: EmailAgentState):
|
| 5 |
+
# Search for previous interactions (both sent and received)
|
| 6 |
search_tool = [t for t in gmail_toolkit.get_tools() if t.name == "search_gmail"][0]
|
| 7 |
+
|
| 8 |
+
# Combined query using Gmail's OR syntax
|
| 9 |
+
query = f"from:{state['sender_email_id']} OR to:{state['sender_email_id']}"
|
| 10 |
+
results = search_tool.invoke(query)
|
| 11 |
|
| 12 |
if len(results) == 0:
|
|
|
|
| 13 |
return {"draft_context": "No relevant past context found."}
|
| 14 |
|
| 15 |
def after_mail_check(state: EmailAgentState):
|