2025-05-05 01:39:31 -07:00
|
|
|
from langgraph.graph import StateGraph
|
|
|
|
|
|
|
|
|
|
from .configuration import Configuration
|
|
|
|
|
from .nodes import create_merged_podcast_audio, create_podcast_transcript
|
2025-07-24 14:43:48 -07:00
|
|
|
from .state import State
|
2025-05-05 01:39:31 -07:00
|
|
|
|
|
|
|
|
|
2025-05-05 23:18:12 -07:00
|
|
|
def build_graph():
|
|
|
|
|
# Define a new graph
|
|
|
|
|
workflow = StateGraph(State, config_schema=Configuration)
|
2025-05-05 01:39:31 -07:00
|
|
|
|
2025-05-05 23:18:12 -07:00
|
|
|
# Add the node to the graph
|
|
|
|
|
workflow.add_node("create_podcast_transcript", create_podcast_transcript)
|
|
|
|
|
workflow.add_node("create_merged_podcast_audio", create_merged_podcast_audio)
|
2025-05-05 01:39:31 -07:00
|
|
|
|
2025-05-05 23:18:12 -07:00
|
|
|
# Set the entrypoint as `call_model`
|
|
|
|
|
workflow.add_edge("__start__", "create_podcast_transcript")
|
|
|
|
|
workflow.add_edge("create_podcast_transcript", "create_merged_podcast_audio")
|
|
|
|
|
workflow.add_edge("create_merged_podcast_audio", "__end__")
|
|
|
|
|
|
|
|
|
|
# Compile the workflow into an executable graph
|
|
|
|
|
graph = workflow.compile()
|
|
|
|
|
graph.name = "Surfsense Podcaster" # This defines the custom name in LangSmith
|
2025-07-24 14:43:48 -07:00
|
|
|
|
2025-05-05 23:18:12 -07:00
|
|
|
return graph
|
|
|
|
|
|
2025-07-24 14:43:48 -07:00
|
|
|
|
2025-05-05 23:18:12 -07:00
|
|
|
# Compile the graph once when the module is loaded
|
|
|
|
|
graph = build_graph()
|