Terry Zhuo commited on
Commit
8e7c697
1 Parent(s): e84ef52

Add application file

Browse files
Files changed (2) hide show
  1. app.py +38 -0
  2. wild-code-bench-v0.1.0.jsonl +0 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import json
4
+
5
+ FILE = "wild-code-bench-v0.1.0.jsonl"
6
+ # Function to load data from a JSONL
7
+ @st.cache_data
8
+ def load_data_from_jsonl(file):
9
+ with open(file, 'r') as f:
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['prompt'].lower() or keyword.lower() in item['instruction'].lower()]
18
+ return filtered_data
19
+
20
+ # Streamlit UI Setup
21
+ st.title('Prompt Viewer')
22
+ data = load_data_from_jsonl(FILE)
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
+
29
+ if filtered_data:
30
+ snippet1 = filtered_data[index]['prompt']
31
+ snippet2 = filtered_data[index]['instruction']
32
+ st.subheader("Code to Code")
33
+ st.code(snippet1, language='python')
34
+
35
+ st.subheader("Natural Language to Code")
36
+ st.code(snippet2, language='python')
37
+ else:
38
+ st.error("No data available. Check the URL or search criteria.")
wild-code-bench-v0.1.0.jsonl ADDED
The diff for this file is too large to render. See raw diff