Add memory

This commit is contained in:
Lance Martin
2025-02-05 12:54:30 -08:00
parent c811b382c8
commit 57bd306d4c
7 changed files with 808 additions and 28 deletions
+4 -2
View File
@@ -14,7 +14,7 @@
"\n",
"We'll start with a simple implementation - one that uses hard-coded rules to handle emails.\n",
"\n",
"![Memory Course App](img/memory_course_email.png)\n",
"![Memory Course App](./img/memory_course_email.png)\n",
"\n",
"First, install the prerequisite packages:"
]
@@ -233,7 +233,8 @@
"### Build agent\n",
"\n",
"Combine triage with tool calling agent\n",
"\n"
"\n",
"TODO: Explain `Command`\n"
]
},
{
@@ -280,6 +281,7 @@
" triage_no=profile[\"triage_rules\"][\"ignore\"],\n",
" triage_notify=profile[\"triage_rules\"][\"notify\"],\n",
" triage_email=profile[\"triage_rules\"][\"respond\"],\n",
" examples=None\n",
" )\n",
"\n",
" user_prompt = triage_user_prompt.format(\n",
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+18
View File
@@ -0,0 +1,18 @@
[project]
name = "memory-course"
version = "0.1.0"
description = "LangGraph Memory Course"
requires-python = ">=3.8"
dependencies = [
"langchain",
"langchain-anthropic",
"langgraph",
"langmem"
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/memory_course"]
View File
+27
View File
@@ -17,6 +17,33 @@ Use these tools when appropriate to help manage {name}'s tasks efficiently.
</ Instructions >
"""
# Agent prompt semantic memory
agent_system_prompt_semantic = """
< Role >
You are {full_name}'s executive assistant. You are a top-notch executive assistant who cares about {name} performing as well as possible.
</ Role >
< Tools >
You have access to the following tools to help manage {name}'s communications and schedule:
1. write_email(to, subject, content) - Send emails to specified recipients
2. schedule_meeting(attendees, subject, duration_minutes, preferred_day) - Schedule calendar meetings
3. check_calendar_availability(day) - Check available time slots for a given day
4. manage_memory("email_assistant", user, "collection") - Store any relevant information about contacts, actions, discussion, etc. in memory for future reference
5. manage_memory("email_assistant", user, "user_profile") - Store any relevant information about the recipient, {name}, in the user profile for future reference the current user profile is shown below
6. search_memory("email_assistant", user, "collection") - Search memory for detail from previous emails
</ Tools >
< User profile >
{profile}
</ User profile >
< Instructions >
Use these tools when appropriate to help manage {name}'s tasks efficiently.
If updating the user profile, do not omit past information. Simply it with new information from the email that that fits within the profile schema.
</ Instructions >
"""
# Triage prompt
triage_system_prompt = """
< Role >
+1
View File
@@ -19,4 +19,5 @@ class Router(BaseModel):
class State(TypedDict):
email_input: str
routing_decision: str
human_feedback: Literal["ignore", "respond", "notify"]
messages: Annotated[list, add_messages]