awacke1 commited on
Commit
bc171c3
·
1 Parent(s): 6477be9

Update backup.app.py

Browse files
Files changed (1) hide show
  1. backup.app.py +38 -5
backup.app.py CHANGED
@@ -1,9 +1,9 @@
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
- # modify the example not to use filename
3
-
4
- # Import required libraries
5
  import streamlit as st
6
  import graphviz as gv
 
 
 
 
7
 
8
  # Function to create the Graphviz graph
9
  def create_graph():
@@ -22,10 +22,43 @@ def create_graph():
22
 
23
  return g
24
 
 
 
 
 
 
 
 
 
 
 
25
  # Create the graph
26
  graph = create_graph()
27
 
28
  # Streamlit app
29
  st.title("In Context Learning - Prompt Targeting QA Pattern")
30
  st.subheader("The Question / Answer pattern below can be used in concert with a LLM to do real time in context learning using general intelligence.")
31
- st.graphviz_chart(graph)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import graphviz as gv
3
+ import json
4
+ import os
5
+
6
+ FILE_NAME = 'saved_data.json'
7
 
8
  # Function to create the Graphviz graph
9
  def create_graph():
 
22
 
23
  return g
24
 
25
+ def save_data(data):
26
+ with open(FILE_NAME, 'w') as f:
27
+ json.dump(data, f)
28
+
29
+ def load_data():
30
+ if not os.path.exists(FILE_NAME):
31
+ return {}
32
+ with open(FILE_NAME, 'r') as f:
33
+ return json.load(f)
34
+
35
  # Create the graph
36
  graph = create_graph()
37
 
38
  # Streamlit app
39
  st.title("In Context Learning - Prompt Targeting QA Pattern")
40
  st.subheader("The Question / Answer pattern below can be used in concert with a LLM to do real time in context learning using general intelligence.")
41
+ st.graphviz_chart(graph)
42
+
43
+ data = load_data()
44
+
45
+ # Input fields
46
+ st.header("Enter your data")
47
+ question = st.text_input("Question:")
48
+ context = st.text_input("Context:")
49
+ answer = st.text_input("Answer:")
50
+ target_sequence = st.text_input("Target Sequence:")
51
+
52
+ if st.button("Save"):
53
+ if question and context and answer and target_sequence:
54
+ data["question"] = question
55
+ data["context"] = context
56
+ data["answer"] = answer
57
+ data["target_sequence"] = target_sequence
58
+ save_data(data)
59
+ st.success("Data saved successfully.")
60
+ else:
61
+ st.error("Please fill in all fields.")
62
+
63
+ st.header("Saved data")
64
+ st.write(data)