2025-06-03 00:10:35 -07:00
|
|
|
from langgraph.graph import StateGraph
|
2025-07-24 14:43:48 -07:00
|
|
|
|
2025-06-03 00:10:35 -07:00
|
|
|
from .configuration import Configuration
|
2025-07-24 14:43:48 -07:00
|
|
|
from .nodes import answer_question, rerank_documents
|
|
|
|
|
from .state import State
|
2025-06-03 00:10:35 -07:00
|
|
|
|
|
|
|
|
# Define a new graph
|
|
|
|
|
workflow = StateGraph(State, config_schema=Configuration)
|
|
|
|
|
|
|
|
|
|
# Add the nodes to the graph
|
|
|
|
|
workflow.add_node("rerank_documents", rerank_documents)
|
|
|
|
|
workflow.add_node("answer_question", answer_question)
|
|
|
|
|
|
|
|
|
|
# Connect the nodes
|
|
|
|
|
workflow.add_edge("__start__", "rerank_documents")
|
|
|
|
|
workflow.add_edge("rerank_documents", "answer_question")
|
|
|
|
|
workflow.add_edge("answer_question", "__end__")
|
|
|
|
|
|
|
|
|
|
# Compile the workflow into an executable graph
|
|
|
|
|
graph = workflow.compile()
|
|
|
|
|
graph.name = "SurfSense QnA Agent" # This defines the custom name in LangSmith
|