DrishtiSharma commited on
Commit
012fbad
·
verified ·
1 Parent(s): 7054888

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  import json
3
  import operator
4
  import streamlit as st
 
5
  from typing import TypedDict, Annotated, Sequence
6
  from langchain_openai import ChatOpenAI
7
  from langchain_core.tools import tool
@@ -52,10 +53,19 @@ def router(state):
52
  graph.add_conditional_edges("agent", router, {"multiply": "tool", "end": END})
53
  app_graph = graph.compile()
54
 
 
 
 
 
 
 
55
  # Streamlit Interface
56
- st.title("Multiplication Tool")
 
 
 
57
 
58
- tab1, tab2 = st.tabs(["Tool Showcase", "Ask General Queries"])
59
 
60
  with tab1:
61
  st.subheader("Try Multiplication")
@@ -84,4 +94,4 @@ with tab2:
84
  except Exception as e:
85
  st.error("Something went wrong. Try again!")
86
  else:
87
- st.warning("Please enter a valid input.")
 
2
  import json
3
  import operator
4
  import streamlit as st
5
+ import tempfile
6
  from typing import TypedDict, Annotated, Sequence
7
  from langchain_openai import ChatOpenAI
8
  from langchain_core.tools import tool
 
53
  graph.add_conditional_edges("agent", router, {"multiply": "tool", "end": END})
54
  app_graph = graph.compile()
55
 
56
+ # Save graph visualization as an image
57
+ with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmpfile:
58
+ graph_viz = app_graph.get_graph(xray=True)
59
+ tmpfile.write(graph_viz.draw_mermaid_png()) # Write binary image data to file
60
+ graph_image_path = tmpfile.name
61
+
62
  # Streamlit Interface
63
+ st.title("Simple Tool Calling Demo")
64
+
65
+ # Display the workflow graph
66
+ st.image(graph_image_path, caption="LangGraph Workflow Visualization")
67
 
68
+ tab1, tab2 = st.tabs(["Try Multiplication", "Ask General Queries"])
69
 
70
  with tab1:
71
  st.subheader("Try Multiplication")
 
94
  except Exception as e:
95
  st.error("Something went wrong. Try again!")
96
  else:
97
+ st.warning("Please enter a valid input.")