import streamlit as st import json from datasets import load_dataset st.set_page_config(page_title="Stack-exchange visualization", layout="wide") st.title("Stack-exchange visualization") @st.cache() def load_data(): ds = load_dataset("ArmelR/stack-exchange-sample10000", split="train") return ds def print_question(example): st.markdown("**Question**") st.write(example["question"]) st.markdown("""---""") st.markdown("**Answer**") st.write(example["response_j"]) samples = load_data() col1, _ = st.columns([2, 4]) with col1: index_example = st.number_input(f"Index of the chosen question-answer pair from the existing {len(samples)}", min_value=0, max_value=len(samples)-1, value=0, step=1) print_question(samples[index_example])