jstoppa commited on
Commit
b155bfe
·
verified ·
1 Parent(s): ec2cc5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -1,6 +1,7 @@
1
  from langgraph.graph import StateGraph
2
  from typing import TypedDict, Annotated
3
  from langgraph.graph.message import add_messages
 
4
 
5
  class State(TypedDict):
6
  messages: Annotated[list[str], add_messages]
@@ -42,6 +43,7 @@ workflow.add_edge("collect", "process")
42
 
43
  # Set entry and finish points
44
  workflow.set_entry_point("collect")
 
45
 
46
  app = workflow.compile()
47
 
@@ -49,4 +51,10 @@ app = workflow.compile()
49
  print("\nStarting workflow...")
50
  initial_state = State(messages=["Starting"], current_step="collect")
51
  final_state = app.invoke(initial_state)
52
- print(f"\nFinal messages: {final_state['messages']}")
 
 
 
 
 
 
 
1
  from langgraph.graph import StateGraph
2
  from typing import TypedDict, Annotated
3
  from langgraph.graph.message import add_messages
4
+ from langchain_core.runnables.graph import MermaidDrawMethod
5
 
6
  class State(TypedDict):
7
  messages: Annotated[list[str], add_messages]
 
43
 
44
  # Set entry and finish points
45
  workflow.set_entry_point("collect")
46
+ workflow.set_finish_point("process")
47
 
48
  app = workflow.compile()
49
 
 
51
  print("\nStarting workflow...")
52
  initial_state = State(messages=["Starting"], current_step="collect")
53
  final_state = app.invoke(initial_state)
54
+ print(f"\nFinal messages: {final_state['messages']}")
55
+
56
+ # Save the graph visualization as PNG
57
+ png_data = app.get_graph().draw_mermaid_png(draw_method=MermaidDrawMethod.API)
58
+ with open("workflow_graph.png", "wb") as f:
59
+ f.write(png_data)
60
+ print("\nGraph visualization saved as 'workflow_graph.png'")