Spaces:
Runtime error
Runtime error
import streamlit as st | |
import json | |
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']}") | |