File size: 1,252 Bytes
f9f24ec
 
 
50b49a8
f9f24ec
6f6391b
2319432
6f6391b
f9f24ec
f698f3c
3231898
f698f3c
 
f9f24ec
6f6391b
 
f9f24ec
 
6f6391b
 
f698f3c
0974549
 
6f6391b
 
 
50b49a8
 
72db41e
50b49a8
72db41e
 
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
28
29
30
31
32
33
import streamlit as st
import json
from datasets import load_dataset
import sqlparse

st.set_page_config(page_title="BIRD SQL inspection", layout="wide")

st.markdown("<h1 style='text-align: center; color: #00BFFF;'>BIRD SQL inspection 🔍</h1>", unsafe_allow_html=True)

st.markdown("""
Here you can inspect BIRD SQL data with schemas from [BIRD-Bench](https://bird-bench.github.io/).
""")

@st.cache()
def load_data():
    ds = load_dataset("xu3kev/BIRD-SQL-data", split="train")
    return ds


samples = load_data()
st.sidebar.header('Sample Selection')
index_example = st.sidebar.number_input(f"Choose a sample from the existing {len(samples)} notebooks:", min_value=0, max_value=max(0, len(samples)-1), value=0, step=1)

db_id = samples[index_example]["db_id"]
st.markdown(f'<h2 style="color:blue;">{index_example} Question:</h2>', unsafe_allow_html=True)
st.code(samples[index_example]["question"])
sql_str = samples[index_example]["SQL"]
sql_str_pretty = sqlparse.format(sql_str, reindent=True, keyword_case='upper')
st.markdown(f'<h2 style="color:blue;">SQL:</h2>', unsafe_allow_html=True)
st.code(sql_str_pretty)
st.markdown(f'<h2 style="color:blue;">Database schema:</h2>', unsafe_allow_html=True)
st.code(samples[index_example]["schema"])