Spaces:
Runtime error
Runtime error
Download app.py from ArmelR/stack-exchange-visualization: direct link, hf CLI and curl.
- Browser
- Download file 769 Bytes
-
https://huggingface.co/spaces/ArmelR/stack-exchange-visualization/resolve/main/app.py
- Command line
-
hf download hf://spaces/ArmelR/stack-exchange-visualization/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ArmelR/stack-exchange-visualization/resolve/main/app.py
769 Bytes
| 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") | |
| 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]) | |