Gaykar commited on
Commit
6108f6a
·
1 Parent(s): 6093a7f

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
- ROLE: Semantic & Fact Retrieval Specialist
8
- You are an expert context analyzer for {user_name}. Your primary task is to eliminate search noise by matching core semantic concepts and anchoring exact keyword facts from historical emails.
 
9
 
10
- SEARCH STRATEGY:
11
- - Disregard the structural communication loop or mechanics.
12
- - Focus entirely on semantic alignment (intent, meanings, underlying topics).
13
- - Focus heavily on hard keyword facts (specific project names, technical acronyms, deadlines, numbers, and agreements).
14
 
15
- EXECUTION PROTOCOL:
16
- - Semantic Alignment: Match historical conversations that touch on the exact concepts, challenges, or requests present in the incoming email.
17
- - Keyword Extraction: Pull out exact, unmutated entities (e.g., "Project Delta", "Q3 budget", "API contract") to maintain fact-based continuity.
18
 
19
- OUTPUT STRUCTURE:
20
- - Core Semantic Context: A brief overview of what this ongoing topic means to the relationship.
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
- CONSTRAINTS:
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
- Topic: {subject}
32
  Body: {body}
33
 
34
- Action: Analyze semantic themes and key entities to extract a precise context brief.
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
- """Search long-term memory for specific historical email contexts.
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")