Spaces:
Runtime error
Runtime error
changes
Browse files- app/agent_memory_store/memory_store.py +0 -20
- app/agents/context_agent.py +2 -2
- app/agents/memory_manager_agent.py +2 -2
- app/database/connection.py +23 -1
- app/graph.py +1 -1
- app/main.py +13 -0
- app/{agent_memory_store → utils}/embeddings.py +0 -0
app/agent_memory_store/memory_store.py
DELETED
|
@@ -1,20 +0,0 @@
|
|
| 1 |
-
from psycopg_pool import ConnectionPool
|
| 2 |
-
from langgraph.store.postgres import PostgresStore
|
| 3 |
-
from langgraph.checkpoint.postgres import PostgresSaver
|
| 4 |
-
from app.agent_memory_store.embeddings import remote_embeddings
|
| 5 |
-
|
| 6 |
-
from app.core.config import settings
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
DB_URL_FOR_CHECKPOINTER_STORE=settings.DB_URL_FOR_CHECKPOINTER_STORE
|
| 10 |
-
|
| 11 |
-
pool = ConnectionPool(
|
| 12 |
-
conninfo=DB_URL_FOR_CHECKPOINTER_STORE,
|
| 13 |
-
min_size=1,
|
| 14 |
-
max_size=10,
|
| 15 |
-
kwargs={"autocommit": True}
|
| 16 |
-
)
|
| 17 |
-
4
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
memory_store = PostgresStore(pool, index={"dims": 384, "embed": remote_embeddings})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/agents/context_agent.py
CHANGED
|
@@ -4,7 +4,7 @@ from langchain_groq import ChatGroq
|
|
| 4 |
from app.prompts.context_agent_prompt import context_agent_template
|
| 5 |
from app.tools.context_agent_tools import context_agent_tools
|
| 6 |
from typing import Any
|
| 7 |
-
from app.agent_memory_store import
|
| 8 |
|
| 9 |
context_agent = create_agent(
|
| 10 |
model=ChatGroq(
|
|
@@ -12,7 +12,7 @@ context_agent = create_agent(
|
|
| 12 |
temperature=0.1,
|
| 13 |
),
|
| 14 |
tools=context_agent_tools,
|
| 15 |
-
store=
|
| 16 |
middleware=[
|
| 17 |
ToolCallLimitMiddleware[Any,None](
|
| 18 |
tool_name="search_memory",
|
|
|
|
| 4 |
from app.prompts.context_agent_prompt import context_agent_template
|
| 5 |
from app.tools.context_agent_tools import context_agent_tools
|
| 6 |
from typing import Any
|
| 7 |
+
from app.agent_memory_store import connection
|
| 8 |
|
| 9 |
context_agent = create_agent(
|
| 10 |
model=ChatGroq(
|
|
|
|
| 12 |
temperature=0.1,
|
| 13 |
),
|
| 14 |
tools=context_agent_tools,
|
| 15 |
+
store=connection,
|
| 16 |
middleware=[
|
| 17 |
ToolCallLimitMiddleware[Any,None](
|
| 18 |
tool_name="search_memory",
|
app/agents/memory_manager_agent.py
CHANGED
|
@@ -2,7 +2,7 @@ import types
|
|
| 2 |
from langchain_groq import ChatGroq
|
| 3 |
from langmem import create_memory_store_manager
|
| 4 |
from app.schemas.memory_agent_schema import EmailMemory
|
| 5 |
-
from app.agent_memory_store import
|
| 6 |
import os
|
| 7 |
from app.core.config import settings
|
| 8 |
|
|
@@ -51,7 +51,7 @@ memory_manager_agent = create_memory_store_manager(
|
|
| 51 |
model,
|
| 52 |
schemas=[EmailMemory],
|
| 53 |
namespace=namespace,
|
| 54 |
-
store=
|
| 55 |
instructions="Extract required info from incoming mail and its reply .",
|
| 56 |
enable_inserts=True,
|
| 57 |
enable_deletes=True,
|
|
|
|
| 2 |
from langchain_groq import ChatGroq
|
| 3 |
from langmem import create_memory_store_manager
|
| 4 |
from app.schemas.memory_agent_schema import EmailMemory
|
| 5 |
+
from app.agent_memory_store import connection
|
| 6 |
import os
|
| 7 |
from app.core.config import settings
|
| 8 |
|
|
|
|
| 51 |
model,
|
| 52 |
schemas=[EmailMemory],
|
| 53 |
namespace=namespace,
|
| 54 |
+
store=connection,
|
| 55 |
instructions="Extract required info from incoming mail and its reply .",
|
| 56 |
enable_inserts=True,
|
| 57 |
enable_deletes=True,
|
app/database/connection.py
CHANGED
|
@@ -1,6 +1,19 @@
|
|
| 1 |
from sqlalchemy import create_engine
|
| 2 |
from sqlalchemy.orm import sessionmaker, Session
|
| 3 |
from app.core.config import settings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
DB_URL_FOR_SQL_AL=settings.DB_URL_FOR_SQL_AL
|
| 6 |
|
|
@@ -14,4 +27,13 @@ engine = create_engine(
|
|
| 14 |
SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False)
|
| 15 |
|
| 16 |
def get_session() -> Session:
|
| 17 |
-
return SessionLocal()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from sqlalchemy import create_engine
|
| 2 |
from sqlalchemy.orm import sessionmaker, Session
|
| 3 |
from app.core.config import settings
|
| 4 |
+
from psycopg_pool import ConnectionPool
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
DB_URL_FOR_CHECKPOINTER_STORE=settings.DB_URL_FOR_CHECKPOINTER_STORE
|
| 9 |
+
|
| 10 |
+
pool = ConnectionPool(
|
| 11 |
+
conninfo=DB_URL_FOR_CHECKPOINTER_STORE,
|
| 12 |
+
min_size=1,
|
| 13 |
+
max_size=10,
|
| 14 |
+
kwargs={"autocommit": True}
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
|
| 18 |
DB_URL_FOR_SQL_AL=settings.DB_URL_FOR_SQL_AL
|
| 19 |
|
|
|
|
| 27 |
SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False)
|
| 28 |
|
| 29 |
def get_session() -> Session:
|
| 30 |
+
return SessionLocal()
|
| 31 |
+
|
| 32 |
+
DB_URL_FOR_CHECKPOINTER_STORE=settings.DB_URL_FOR_CHECKPOINTER_STORE
|
| 33 |
+
|
| 34 |
+
pool = ConnectionPool(
|
| 35 |
+
conninfo=DB_URL_FOR_CHECKPOINTER_STORE,
|
| 36 |
+
min_size=1,
|
| 37 |
+
max_size=10,
|
| 38 |
+
kwargs={"autocommit": True}
|
| 39 |
+
)
|
app/graph.py
CHANGED
|
@@ -2,7 +2,6 @@ from app.state.state import EmailAgentState
|
|
| 2 |
from app.nodes.triage_node import *
|
| 3 |
from langgraph.prebuilt import ToolNode ,tools_condition
|
| 4 |
from app.nodes.archive_node import archive_node
|
| 5 |
-
from app.tools.email_writing_agent_tools import *
|
| 6 |
from app.nodes.email_writing_node import *
|
| 7 |
from langgraph.graph import StateGraph,END,START
|
| 8 |
from app.tools.email_writing_agent_tools import create_gmail_draft, send_draft_by_id
|
|
@@ -16,6 +15,7 @@ from langgraph.types import RetryPolicy
|
|
| 16 |
from app.nodes.summarise_email_body_node import summarise_email_body_node
|
| 17 |
from app.nodes.check_token_count_node import *
|
| 18 |
from psycopg import OperationalError # Or sqlalchemy.exc.OperationalError depending on your driver
|
|
|
|
| 19 |
from IPython.display import Image, display
|
| 20 |
|
| 21 |
|
|
|
|
| 2 |
from app.nodes.triage_node import *
|
| 3 |
from langgraph.prebuilt import ToolNode ,tools_condition
|
| 4 |
from app.nodes.archive_node import archive_node
|
|
|
|
| 5 |
from app.nodes.email_writing_node import *
|
| 6 |
from langgraph.graph import StateGraph,END,START
|
| 7 |
from app.tools.email_writing_agent_tools import create_gmail_draft, send_draft_by_id
|
|
|
|
| 15 |
from app.nodes.summarise_email_body_node import summarise_email_body_node
|
| 16 |
from app.nodes.check_token_count_node import *
|
| 17 |
from psycopg import OperationalError # Or sqlalchemy.exc.OperationalError depending on your driver
|
| 18 |
+
from app.tools.email_writing_agent_tools import email_writing_agent_tools
|
| 19 |
from IPython.display import Image, display
|
| 20 |
|
| 21 |
|
app/main.py
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from app.graph import graph
|
| 2 |
+
from app.database.connection import pool
|
| 3 |
+
from langgraph.checkpoint.postgres import PostgresSaver
|
| 4 |
+
from langgraph.store.postgres import PostgresStore
|
| 5 |
+
from app.utils.embeddings import remote_embeddings
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
checkpointer = PostgresSaver(pool)
|
| 11 |
+
memory_store = PostgresStore(pool, embeddings=remote_embeddings)
|
| 12 |
+
|
| 13 |
+
|
app/{agent_memory_store → utils}/embeddings.py
RENAMED
|
File without changes
|