routeur_ia_api / graphs /workflows /conversation_with_summary.py
Cyril Dupland
Enhance conversation workflows by introducing summarization and classification agents. Implement retrieval nodes for document fetching, and update settings for Supabase integration. Add Markdown to PDF conversion utilities and improve agent service to handle document metadata. Refactor agent registry to support orchestrated workflows.
0ef1224
raw
history blame
1.34 kB
"""Workflow: retrieve -> chat_agent -> summarizer -> END."""
from langgraph.graph import StateGraph, END
from langchain_core.language_models.chat_models import BaseChatModel
from graphs.state import AgentState
from graphs.nodes.retrieval import retrieve_both_types
from graphs.agents.chat_agent import chat_node
from graphs.agents.summarizer_agent import summarizer_llm_node, summarizer_export_node
from tools.markdown import markdown_to_html
from tools.pdf import html_to_pdf
from tools.storage import upload_pdf_to_supabase
def create_conversation_with_summary_graph(llm: BaseChatModel):
workflow = StateGraph(AgentState)
# Nodes
workflow.add_node("retrieve", retrieve_both_types)
workflow.add_node("agent", chat_node(llm))
workflow.add_node("summarizer_llm", summarizer_llm_node(llm))
workflow.add_node(
"summarizer_export",
summarizer_export_node(
md_to_html=markdown_to_html,
html_to_pdf=html_to_pdf,
upload_pdf=upload_pdf_to_supabase,
),
)
# Entry and edges
workflow.set_entry_point("retrieve")
workflow.add_edge("retrieve", "agent")
workflow.add_edge("agent", "summarizer_llm")
workflow.add_edge("summarizer_llm", "summarizer_export")
workflow.add_edge("summarizer_export", END)
return workflow.compile()