Commit
•
6571b31
0
Parent(s):
Duplicate from awacke1/Human.Feedback.Dynamic.JSONL.Dataset.Download
Browse filesCo-authored-by: Aaron C Wacker <[email protected]>
- .gitattributes +34 -0
- README.md +14 -0
- app.py +89 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Human.Feedback.Dynamic.JSONL.Dataset.Download
|
3 |
+
emoji: 📈
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: yellow
|
6 |
+
sdk: streamlit
|
7 |
+
sdk_version: 1.17.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: mit
|
11 |
+
duplicated_from: awacke1/Human.Feedback.Dynamic.JSONL.Dataset.Download
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
import base64
|
4 |
+
import streamlit as st
|
5 |
+
|
6 |
+
FIELDS = [
|
7 |
+
"CodeValue",
|
8 |
+
"CodeType",
|
9 |
+
"Context",
|
10 |
+
"Question",
|
11 |
+
"AnswerText",
|
12 |
+
"UpVoteCount",
|
13 |
+
"DownVoteCount",
|
14 |
+
"VoteComment",
|
15 |
+
]
|
16 |
+
|
17 |
+
IO_PATTERN = "*.jsonl"
|
18 |
+
|
19 |
+
|
20 |
+
def read_jsonl_file(file_path):
|
21 |
+
if not os.path.exists(file_path):
|
22 |
+
return []
|
23 |
+
with open(file_path, "r") as f:
|
24 |
+
lines = f.readlines()
|
25 |
+
records = [json.loads(line) for line in lines]
|
26 |
+
return records
|
27 |
+
|
28 |
+
|
29 |
+
def write_jsonl_file(file_path, records):
|
30 |
+
with open(file_path, "w") as f:
|
31 |
+
for record in records:
|
32 |
+
f.write(json.dumps(record) + "\n")
|
33 |
+
|
34 |
+
|
35 |
+
def list_files():
|
36 |
+
return [f for f in os.listdir() if f.endswith(".jsonl")]
|
37 |
+
|
38 |
+
|
39 |
+
def download_link(file_path):
|
40 |
+
with open(file_path, "rb") as f:
|
41 |
+
contents = f.read()
|
42 |
+
b64 = base64.b64encode(contents).decode()
|
43 |
+
href = f'<a href="data:application/octet-stream;base64,{b64}" download="{file_path}">Download</a>'
|
44 |
+
return href
|
45 |
+
|
46 |
+
|
47 |
+
def main():
|
48 |
+
jsonl_files = list_files()
|
49 |
+
|
50 |
+
if not jsonl_files:
|
51 |
+
st.warning("No JSONL files found. Creating new file.")
|
52 |
+
jsonl_files.append("data.jsonl")
|
53 |
+
write_jsonl_file("data.jsonl", [])
|
54 |
+
|
55 |
+
selected_file = st.sidebar.text_input("Enter file name", value=jsonl_files[0])
|
56 |
+
if selected_file != jsonl_files[0]:
|
57 |
+
os.rename(jsonl_files[0], selected_file)
|
58 |
+
jsonl_files[0] = selected_file
|
59 |
+
|
60 |
+
st.sidebar.write("JSONL files:")
|
61 |
+
selected_file_index = st.sidebar.selectbox("", range(len(jsonl_files)))
|
62 |
+
for i, file_name in enumerate(jsonl_files):
|
63 |
+
if i == selected_file_index:
|
64 |
+
selected_file = file_name
|
65 |
+
st.sidebar.write(f"> {file_name}")
|
66 |
+
else:
|
67 |
+
st.sidebar.write(file_name)
|
68 |
+
|
69 |
+
st.sidebar.markdown(download_link(selected_file), unsafe_allow_html=True)
|
70 |
+
|
71 |
+
records = read_jsonl_file(selected_file)
|
72 |
+
|
73 |
+
for field in FIELDS:
|
74 |
+
value = st.text_input(field, key=field)
|
75 |
+
st.write(f"{field}: {value}")
|
76 |
+
|
77 |
+
if st.button("Add Record"):
|
78 |
+
record = {field: st.session_state[field] for field in FIELDS}
|
79 |
+
records.append(record)
|
80 |
+
write_jsonl_file(selected_file, records)
|
81 |
+
st.success("Record added!")
|
82 |
+
|
83 |
+
st.write(f"Current contents of {selected_file}:")
|
84 |
+
for record in records:
|
85 |
+
st.write(record)
|
86 |
+
|
87 |
+
|
88 |
+
if __name__ == "__main__":
|
89 |
+
main()
|