File size: 1,322 Bytes
d50630f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import json

@st.cache_data
def load_data(file_path):
    with open(file_path, 'r') as file:
        return json.load(file)

data = load_data('out.json')

# Sidebar for plot selection
plot_ids = [item["plot_id"] for item in data]
selected_plot_id = st.sidebar.selectbox('Select a Plot ID', plot_ids)
selected_plot = next(item for item in data if item["plot_id"] == selected_plot_id)

# Display plot details
st.header('Plot Details')
st.markdown(f"```\n{selected_plot['plot']}\n```")
# st.write(selected_plot['plot']) 

# Display conversation
st.header('Conversation')
with st.expander("Show Conversation", expanded=False):
    for line in selected_plot['conversation']:
        if line.startswith("User:"):
            line.split(':', 1)[1].strip()
            with st.chat_message("user"):
                st.markdown(line.split(':', 1)[1].strip())
        else:
            with st.chat_message("assistant"):
                st.markdown(line.split(':', 1)[1].strip())

# Display evaluation
st.header('Evaluation')
evaluation = json.loads(selected_plot['evaluation'])
# for key, value in evaluation.items():
#     st.markdown(f"```\n{key}: {value}\n```")
st.json(evaluation)

# Error handling
if 'error' in selected_plot:
    st.error(f"Error in plot {selected_plot_id}: {selected_plot['error']}")