awacke1 commited on
Commit
d35b749
·
1 Parent(s): 6c62de2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Write a streamlit graphviz python program that creates a graph with two boxes and a line between them. The first box should have an outline with this information: Source Sequence: Question{s1,s2,s3}, Context: {sx,sy,sz}, and Answer: {s1,s2,s3}. The second box should have: Target Sequence: The answer to the question given the context is yes.
2
+
3
+ # Import required libraries
4
+ import streamlit as st
5
+ import graphviz as gv
6
+
7
+ # Function to create the Graphviz graph
8
+ def create_graph():
9
+ g = gv.Digraph('G', filename='graph.gv', engine='dot', format='png')
10
+
11
+ # Create the first box
12
+ box1_label = 'Source Sequence: Question{s1,s2,s3}\nContext: {sx,sy,sz}\nAnswer: {s1,s2,s3}'
13
+ g.node('box1', label=box1_label, shape='box', style='rounded')
14
+
15
+ # Create the second box
16
+ box2_label = 'Target Sequence: The answer to the question given the context is yes.'
17
+ g.node('box2', label=box2_label, shape='box', style='rounded')
18
+
19
+ # Add the line connecting the two boxes
20
+ g.edge('box1', 'box2')
21
+
22
+ return g
23
+
24
+ # Create the graph
25
+ graph = create_graph()
26
+
27
+ # Streamlit app
28
+ st.title("Graphviz Example")
29
+ st.subheader("A simple graph with two boxes and a line connecting them.")
30
+ st.graphviz_chart(graph)