File size: 1,244 Bytes
8e7c697
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
34
35
36
37
38
39
import streamlit as st
import requests
import json

FILE = "wild-code-bench-v0.1.0.jsonl"
# Function to load data from a JSONL
@st.cache_data
def load_data_from_jsonl(file):
    with open(file, 'r') as f:
        jsonl_data = f.readlines()
    return [json.loads(line) for line in jsonl_data]

# Function to filter data based on search keyword
def filter_data(data, keyword):
    if not keyword:
        return data
    filtered_data = [item for item in data if keyword.lower() in item['prompt'].lower() or keyword.lower() in item['instruction'].lower()]
    return filtered_data

# Streamlit UI Setup
st.title('Prompt Viewer')
data = load_data_from_jsonl(FILE)

search_keyword = st.sidebar.text_input('Search by keyword', '')
filtered_data = filter_data(data, search_keyword)

index = st.sidebar.number_input('Select Index', min_value=0, max_value=len(filtered_data)-1, value=0, step=1)

if filtered_data:
    snippet1 = filtered_data[index]['prompt']
    snippet2 = filtered_data[index]['instruction']
    st.subheader("Code to Code")
    st.code(snippet1, language='python')
    
    st.subheader("Natural Language to Code")
    st.code(snippet2, language='python')
else:
    st.error("No data available. Check the URL or search criteria.")