mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-29 10:56:24 +02:00
feat: message history and PostgreSQL checkpointer integration
This commit is contained in:
parent
3906ba52e0
commit
73f0f772a8
11 changed files with 434 additions and 115 deletions
|
|
@ -10,6 +10,7 @@ from collections.abc import Sequence
|
|||
from deepagents import create_deep_agent
|
||||
from langchain_core.tools import BaseTool
|
||||
from langchain_litellm import ChatLiteLLM
|
||||
from langgraph.types import Checkpointer
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.agents.new_chat.context import SurfSenseContextSchema
|
||||
|
|
@ -27,6 +28,7 @@ def create_surfsense_deep_agent(
|
|||
search_space_id: int,
|
||||
db_session: AsyncSession,
|
||||
connector_service: ConnectorService,
|
||||
checkpointer: Checkpointer,
|
||||
user_instructions: str | None = None,
|
||||
enable_citations: bool = True,
|
||||
additional_tools: Sequence[BaseTool] | None = None,
|
||||
|
|
@ -39,6 +41,8 @@ def create_surfsense_deep_agent(
|
|||
search_space_id: The user's search space ID
|
||||
db_session: Database session
|
||||
connector_service: Initialized connector service
|
||||
checkpointer: LangGraph checkpointer for conversation state persistence.
|
||||
Use AsyncPostgresSaver for production or MemorySaver for testing.
|
||||
user_instructions: Optional user instructions to inject into the system prompt.
|
||||
These will be added to the system prompt to customize agent behavior.
|
||||
enable_citations: Whether to include citation instructions in the system prompt (default: True).
|
||||
|
|
@ -61,7 +65,7 @@ def create_surfsense_deep_agent(
|
|||
if additional_tools:
|
||||
tools.extend(additional_tools)
|
||||
|
||||
# Create the deep agent with user-configurable system prompt
|
||||
# Create the deep agent with user-configurable system prompt and checkpointer
|
||||
agent = create_deep_agent(
|
||||
model=llm,
|
||||
tools=tools,
|
||||
|
|
@ -70,6 +74,7 @@ def create_surfsense_deep_agent(
|
|||
enable_citations=enable_citations,
|
||||
),
|
||||
context_schema=SurfSenseContextSchema,
|
||||
checkpointer=checkpointer, # Enable conversation memory via thread_id
|
||||
)
|
||||
|
||||
return agent
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue