File size: 1,833 Bytes
6477be9
 
bc171c3
 
 
 
6477be9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc171c3
 
 
 
 
 
 
 
 
 
6477be9
 
 
 
 
 
bc171c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import streamlit as st
import graphviz as gv
import json
import os

FILE_NAME = 'saved_data.json'

# Function to create the Graphviz graph
def create_graph():
    g = gv.Digraph('G', engine='dot', format='png')
    
    # Create the first box
    box1_label = 'Source Sequence: Question{s1,s2,s3}\nContext: {sx,sy,sz}\nAnswer: {s1,s2,s3}'
    g.node('box1', label=box1_label, shape='box', style='rounded')
    
    # Create the second box
    box2_label = 'Target Sequence: The answer to the question given the context is yes.'
    g.node('box2', label=box2_label, shape='box', style='rounded')
    
    # Add the line connecting the two boxes
    g.edge('box1', 'box2')

    return g

def save_data(data):
    with open(FILE_NAME, 'w') as f:
        json.dump(data, f)

def load_data():
    if not os.path.exists(FILE_NAME):
        return {}
    with open(FILE_NAME, 'r') as f:
        return json.load(f)

# Create the graph
graph = create_graph()

# Streamlit app
st.title("In Context Learning - Prompt Targeting QA Pattern")
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.")
st.graphviz_chart(graph)

data = load_data()

# Input fields
st.header("Enter your data")
question = st.text_input("Question:")
context = st.text_input("Context:")
answer = st.text_input("Answer:")
target_sequence = st.text_input("Target Sequence:")

if st.button("Save"):
    if question and context and answer and target_sequence:
        data["question"] = question
        data["context"] = context
        data["answer"] = answer
        data["target_sequence"] = target_sequence
        save_data(data)
        st.success("Data saved successfully.")
    else:
        st.error("Please fill in all fields.")

st.header("Saved data")
st.write(data)