Spaces:
Runtime error
Runtime error
change
Browse files- app/prompts/context_agent_prompt.py +34 -0
- app/prompts/prompts.py +0 -0
- app/prompts/triage_agent_prompt.py +63 -0
- app/schemas/memory_agent_schema.py +20 -0
- app/schemas/pydanticschema.py +0 -4
- requirements.txt +1 -0
app/prompts/context_agent_prompt.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain_core.messages import SystemMessage, HumanMessage,ToolMessage,AIMessage,BaseMessage
|
| 2 |
+
from langchain_core.prompts import ChatPromptTemplate
|
| 3 |
+
|
| 4 |
+
context_agent_template = ChatPromptTemplate([
|
| 5 |
+
("system", """
|
| 6 |
+
ROLE: Situational Awareness Agent
|
| 7 |
+
You are the lead Intelligence Officer for {user_name}. Your mission is to eliminate information asymmetry by synthesizing past interactions into a concise tactical brief.
|
| 8 |
+
|
| 9 |
+
TOOLS
|
| 10 |
+
1. search_memory(query): Target the {senders_email} ↔ {user_email_id} loop.
|
| 11 |
+
2. give_previous_context(memory_summary): Submit your synthesized findings.
|
| 12 |
+
|
| 13 |
+
EXECUTION PROTOCOL
|
| 14 |
+
- Pattern Recognition: Identify recurring project milestones, specific commitments, and unresolved friction points.
|
| 15 |
+
- Sentiment Mapping: Analyze the historical tone (e.g., "Historically collaborative but currently urgent").
|
| 16 |
+
|
| 17 |
+
OUTPUT STRUCTURE
|
| 18 |
+
- Current Brief: Tactical summary of the last relevant exchange.
|
| 19 |
+
- Intelligence Points: Bulleted facts extracted from deep memory.
|
| 20 |
+
- Recommended Stance: Suggested tone (Formal/Casual/Direct) based on relationship history.
|
| 21 |
+
|
| 22 |
+
CONSTRAINTS
|
| 23 |
+
- Zero History: If no records exist, return: "No relevant past context found."
|
| 24 |
+
- Minimalist: Do not explain your search process.
|
| 25 |
+
"""),
|
| 26 |
+
("human", """
|
| 27 |
+
[INCOMING SIGNAL]
|
| 28 |
+
Sender: {senders_email}
|
| 29 |
+
Topic: {subject}
|
| 30 |
+
Body: {body}
|
| 31 |
+
|
| 32 |
+
Action: Prepare situational brief.
|
| 33 |
+
"""),
|
| 34 |
+
])
|
app/prompts/prompts.py
DELETED
|
File without changes
|
app/prompts/triage_agent_prompt.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain_core.messages import SystemMessage, HumanMessage,ToolMessage,AIMessage,BaseMessage
|
| 2 |
+
from langchain_core.prompts import ChatPromptTemplate
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
TRIAGE_SYSTEM_PROMPT = """
|
| 6 |
+
<role>
|
| 7 |
+
You are an expert email triage assistant for {user_name}. Your primary goal is to identify if an email requires a drafted response.
|
| 8 |
+
</role>
|
| 9 |
+
|
| 10 |
+
<classification_rules>
|
| 11 |
+
1. Any email requiring an action, a decision, a confirmation, or a reply must be labeled as 'FOLLOW_UP_REQUIRED'.
|
| 12 |
+
2. Use the 'priority_score' to distinguish between immediate crises (5) and standard tasks (3).
|
| 13 |
+
3. If the email is just for information (e.g., "The meeting is moved to Room 4") with no reply needed, use 'READ_LATER' or 'FYI_NOTIFICATION'.
|
| 14 |
+
</classification_rules>
|
| 15 |
+
|
| 16 |
+
<examples>
|
| 17 |
+
<input>
|
| 18 |
+
Subject: URGENT: Production Server is Down
|
| 19 |
+
Body: Atharva, the API is returning 500 errors for all users. We need you to check the logs immediately.
|
| 20 |
+
</input>
|
| 21 |
+
<output>
|
| 22 |
+
{{
|
| 23 |
+
"triage_label": "FOLLOW_UP_REQUIRED",
|
| 24 |
+
"requires_reply": true,
|
| 25 |
+
"priority_score": 5,
|
| 26 |
+
"triage_notes": "Production outage requires immediate technical intervention and status update."
|
| 27 |
+
}}
|
| 28 |
+
</output>
|
| 29 |
+
|
| 30 |
+
<input>
|
| 31 |
+
Subject: Project Update: SkillBridgeAI
|
| 32 |
+
Body: Hi Atharva, just wanted to check if you've had a chance to look at the new frontend components. No rush.
|
| 33 |
+
</input>
|
| 34 |
+
<output>
|
| 35 |
+
{{
|
| 36 |
+
"triage_label": "FOLLOW_UP_REQUIRED",
|
| 37 |
+
"requires_reply": true,
|
| 38 |
+
"priority_score": 3,
|
| 39 |
+
"triage_notes": "Routine check-in on project progress, requires a standard status update."
|
| 40 |
+
}}
|
| 41 |
+
</output>
|
| 42 |
+
|
| 43 |
+
<input>
|
| 44 |
+
Subject: Newsletter: Deep Learning Weekly
|
| 45 |
+
Body: Here are the top 10 papers from this week in AI...
|
| 46 |
+
</input>
|
| 47 |
+
<output>
|
| 48 |
+
{{
|
| 49 |
+
"triage_label": "READ_LATER",
|
| 50 |
+
"requires_reply": false,
|
| 51 |
+
"priority_score": 2,
|
| 52 |
+
"triage_notes": "Informational newsletter with no actionable request."
|
| 53 |
+
}}
|
| 54 |
+
</output>
|
| 55 |
+
</examples>
|
| 56 |
+
"""
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
triage_agent_template = ChatPromptTemplate([
|
| 60 |
+
|
| 61 |
+
("system", TRIAGE_SYSTEM_PROMPT),
|
| 62 |
+
("human","<subject>{sender_subject}</subject><body>{sender_body}</body>")]
|
| 63 |
+
)
|
app/schemas/memory_agent_schema.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pydantic import BaseModel, Field
|
| 2 |
+
from typing import Optional
|
| 3 |
+
|
| 4 |
+
class EmailMemory(BaseModel):
|
| 5 |
+
"""Memory entry representing a specific email interaction between users."""
|
| 6 |
+
|
| 7 |
+
user_email_id: str = Field(
|
| 8 |
+
..., # Use ... to indicate it is required
|
| 9 |
+
description="The users email_id"
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
receiver_email_id: str = Field(
|
| 13 |
+
...,
|
| 14 |
+
description="The email address of the person with whom user is communicating."
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
content: str = Field(
|
| 18 |
+
...,
|
| 19 |
+
description="A concise summary of the key information, intent, and decisions found in the emails.The content should be stored using user name"
|
| 20 |
+
)
|
app/schemas/pydanticschema.py
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
from pydantic import BaseModel, Field
|
| 2 |
-
from typing import List, Optional, Literal
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
|
@@ -5,3 +5,4 @@ langchain-groq==1.1.1
|
|
| 5 |
fastapi==0.118.1
|
| 6 |
uvicorn
|
| 7 |
langmem
|
|
|
|
|
|
| 5 |
fastapi==0.118.1
|
| 6 |
uvicorn
|
| 7 |
langmem
|
| 8 |
+
SQLAlchemy==2.0.41
|