File size: 769 Bytes
25903c8
 
 
 
8ca88f2
 
25903c8
 
 
8ca88f2
25903c8
 
8ca88f2
20242f4
8ca88f2
20242f4
 
8ca88f2
25903c8
 
 
 
8ca88f2
25903c8
8ca88f2
25903c8
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
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])