Spaces:
Runtime error
Runtime error
prompt chnages context
Browse files
app/prompts/context_agent_prompt.py
CHANGED
|
@@ -1,36 +1,30 @@
|
|
| 1 |
from langchain_core.messages import SystemMessage, HumanMessage,ToolMessage,AIMessage,BaseMessage
|
| 2 |
from langchain_core.prompts import ChatPromptTemplate
|
| 3 |
|
| 4 |
-
|
| 5 |
context_agent_template = ChatPromptTemplate([
|
| 6 |
("system", """
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
- Keyword Extraction: Pull out exact, unmutated entities (e.g., "Project Delta", "Q3 budget", "API contract") to maintain fact-based continuity.
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
- Hard Intelligence Points: Bulleted, unmutated keyword facts, decisions, and dates extracted from deep memory.
|
| 22 |
-
- Recommended Stance: Suggested tone (Formal/Casual/Direct) based on relationship history.
|
| 23 |
|
| 24 |
-
|
| 25 |
-
- Zero History: If no records match semantically or factually, return: "No relevant past context found."
|
| 26 |
-
- Noise Minimization: Do not narrate your search or reference your internal mechanics.
|
| 27 |
"""),
|
| 28 |
("human", """
|
| 29 |
-
[INCOMING SIGNAL]
|
| 30 |
Sender: {senders_email}
|
| 31 |
-
|
| 32 |
Body: {body}
|
| 33 |
|
| 34 |
-
|
| 35 |
"""),
|
| 36 |
-
])
|
|
|
|
| 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 |
+
You are a context retrieval agent for {user_name}.
|
| 7 |
+
|
| 8 |
+
Your job is to search past memory for relevant background on an incoming email and return a concise summary.
|
| 9 |
|
| 10 |
+
STEPS:
|
| 11 |
+
1. Identify what facts would help reply — prior commitments, open questions, shared context.
|
| 12 |
+
2. Search using `search_sender_memory_tool` with specific queries. Run multiple searches if needed.
|
| 13 |
+
3. Call `give_previous_context` with a brief factual summary. If nothing relevant found, pass exactly: "No relevant past context found."
|
| 14 |
|
| 15 |
+
EXAMPLE:
|
| 16 |
+
Email — Subject: "Updated proposal?" Body: "Hey, did you ever send the revised pricing proposal we discussed?"
|
|
|
|
| 17 |
|
| 18 |
+
search_sender_memory_tool("pricing proposal")
|
| 19 |
+
→ "User sent Alice a revised SaaS pricing proposal on June 3rd, pending her approval."
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
give_previous_context("Alice is waiting on a revised pricing proposal sent June 3rd.")
|
|
|
|
|
|
|
| 22 |
"""),
|
| 23 |
("human", """
|
|
|
|
| 24 |
Sender: {senders_email}
|
| 25 |
+
Subject: {subject}
|
| 26 |
Body: {body}
|
| 27 |
|
| 28 |
+
Search memory and return any relevant past context.
|
| 29 |
"""),
|
| 30 |
+
])
|
app/tools/context_agent_tools.py
CHANGED
|
@@ -16,8 +16,7 @@ def search_sender_memory_tool(
|
|
| 16 |
# 2. Inject the compiled graph storage layer
|
| 17 |
store: Annotated[BaseStore, InjectedState("store")] = InjectedState("store")
|
| 18 |
) -> str:
|
| 19 |
-
"""
|
| 20 |
-
This tool automatically scopes the search to the active sender interaction.
|
| 21 |
"""
|
| 22 |
|
| 23 |
active_user = state.get("user_id")
|
|
|
|
| 16 |
# 2. Inject the compiled graph storage layer
|
| 17 |
store: Annotated[BaseStore, InjectedState("store")] = InjectedState("store")
|
| 18 |
) -> str:
|
| 19 |
+
"""Accepts a SINGLE string query to search the sender's history. Execute this tool multiple times if you need to search for different facts
|
|
|
|
| 20 |
"""
|
| 21 |
|
| 22 |
active_user = state.get("user_id")
|