Spaces:
Running
Running
Terry Zhuo
commited on
Commit
•
d409298
1
Parent(s):
35ac379
fix: update data loader
Browse files- app.py +13 -17
- wild-code-bench-v0.1.0.jsonl +0 -0
app.py
CHANGED
@@ -1,39 +1,35 @@
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
-
import
|
|
|
4 |
|
5 |
-
|
6 |
-
# Function to load data from a JSONL
|
7 |
@st.cache_data
|
8 |
-
def
|
9 |
-
|
10 |
-
jsonl_data = f.readlines()
|
11 |
-
return [json.loads(line) for line in jsonl_data]
|
12 |
|
13 |
# Function to filter data based on search keyword
|
14 |
def filter_data(data, keyword):
|
15 |
if not keyword:
|
16 |
return data
|
17 |
-
filtered_data = [item for item in data if keyword.lower() in item['
|
18 |
return filtered_data
|
19 |
|
20 |
# Streamlit UI Setup
|
21 |
st.title('BigCodeBench Viewer')
|
22 |
-
data =
|
23 |
|
24 |
search_keyword = st.sidebar.text_input('Search by keyword', '')
|
25 |
filtered_data = filter_data(data, search_keyword)
|
26 |
-
|
27 |
-
index = st.sidebar.number_input('Select Index', min_value=0, max_value=len(filtered_data)-1, value=0, step=1)
|
28 |
-
show_solution = st.sidebar.checkbox("Show Solution")
|
29 |
-
|
30 |
if filtered_data:
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
34 |
st.code(snippet1, language='python')
|
35 |
|
36 |
-
st.subheader("Natural Language to Code")
|
37 |
st.code(snippet2, language='python')
|
38 |
|
39 |
if show_solution:
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
+
from datasets import load_dataset
|
4 |
+
NAME='bigcode/bigcodebench'
|
5 |
|
6 |
+
# Function to load data
|
|
|
7 |
@st.cache_data
|
8 |
+
def load_data(file):
|
9 |
+
return load_dataset('bigcode/bigcodebench', split='train')
|
|
|
|
|
10 |
|
11 |
# Function to filter data based on search keyword
|
12 |
def filter_data(data, keyword):
|
13 |
if not keyword:
|
14 |
return data
|
15 |
+
filtered_data = [item for item in data if keyword.lower() in item['complete_prompt'].lower()]
|
16 |
return filtered_data
|
17 |
|
18 |
# Streamlit UI Setup
|
19 |
st.title('BigCodeBench Viewer')
|
20 |
+
data = load_data(NAME)
|
21 |
|
22 |
search_keyword = st.sidebar.text_input('Search by keyword', '')
|
23 |
filtered_data = filter_data(data, search_keyword)
|
|
|
|
|
|
|
|
|
24 |
if filtered_data:
|
25 |
+
index = st.sidebar.number_input('Select Index', min_value=0, max_value=len(filtered_data)-1, value=0, step=1)
|
26 |
+
show_solution = st.sidebar.checkbox('Show Solution')
|
27 |
+
snippet1 = filtered_data[index]['complete_prompt']
|
28 |
+
snippet2 = filtered_data[index]['instruct_prompt']
|
29 |
+
st.subheader("Code Completion")
|
30 |
st.code(snippet1, language='python')
|
31 |
|
32 |
+
st.subheader("Natural Language Instruction to Code")
|
33 |
st.code(snippet2, language='python')
|
34 |
|
35 |
if show_solution:
|
wild-code-bench-v0.1.0.jsonl
DELETED
The diff for this file is too large to render.
See raw diff
|
|