Team Ai
Apppublic

ArmelR/stack-exchange-visualization

sourceHugging Faceapache-2.0updated 4y agoView on Hugging Face
0likes
app.py27 linesDownload Raw Back to root
1import streamlit as st2import json3from datasets import load_dataset4 5st.set_page_config(page_title="Stack-exchange visualization", layout="wide")6st.title("Stack-exchange visualization")7 8@st.cache()9def load_data():10    ds = load_dataset("ArmelR/stack-exchange-sample10000", split="train")11    return ds12 13def print_question(example):14    st.markdown("**Question**")15    st.write(example["question"])16    st.markdown("""---""")17    st.markdown("**Answer**")18    st.write(example["response_j"])19 20samples = load_data()21col1, _ = st.columns([2, 4])22with col1:23    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)24 25print_question(samples[index_example])26 27