Spaces:
Runtime error
Runtime error
Commit
·
b198cf7
1
Parent(s):
03889a3
Update app.py
Browse files
app.py
CHANGED
@@ -36,20 +36,23 @@ def identity(index, split):
|
|
36 |
return ds["prompt"], ds["completion"]
|
37 |
|
38 |
def save(index, language, split, prompt, completion):
|
39 |
-
|
40 |
-
|
41 |
-
fout
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
53 |
|
54 |
with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
|
55 |
gr.HTML("""<h1 align="center">MT💫</h1>""")
|
|
|
36 |
return ds["prompt"], ds["completion"]
|
37 |
|
38 |
def save(index, language, split, prompt, completion):
|
39 |
+
if len(prompt) != 0 and len(completion) != 0 :
|
40 |
+
print("Saving ...")
|
41 |
+
with open("/home/user/app/output.jsonl", "a") as fout :
|
42 |
+
fout.write(
|
43 |
+
json.dumps(
|
44 |
+
{
|
45 |
+
"prompt" : prompt,
|
46 |
+
"completion" : completion,
|
47 |
+
"language" : language,
|
48 |
+
"index" : index
|
49 |
+
}
|
50 |
+
)+"\n"
|
51 |
+
)
|
52 |
+
next_index = min(1+index, len(samples[split])-1)
|
53 |
+
return next_index, samples[split][next_index]["prompt"], samples[split][next_index]["completion"], "", ""
|
54 |
+
else :
|
55 |
+
return index, samples[split][index]["prompt"], samples[split][index]["completion"], "", ""
|
56 |
|
57 |
with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
|
58 |
gr.HTML("""<h1 align="center">MT💫</h1>""")
|