Spaces:
Runtime error
Runtime error
Commit
·
60bd4b0
1
Parent(s):
b75f4af
Update app.py
Browse files
app.py
CHANGED
@@ -36,7 +36,7 @@ def identity(index, split):
|
|
36 |
return ds["prompt"], ds["completion"]
|
37 |
|
38 |
def save(index, language, split, prompt, completion):
|
39 |
-
with open("
|
40 |
fout.write(
|
41 |
json.dumps(
|
42 |
{
|
@@ -48,7 +48,7 @@ def save(index, language, split, prompt, completion):
|
|
48 |
)+"\n"
|
49 |
)
|
50 |
next_index = min(1+index, len(samples[split])-1)
|
51 |
-
return next_index, samples[split][next_index]["prompt"], samples[split][next_index]["completion"]
|
52 |
|
53 |
with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
|
54 |
gr.HTML("""<h1 align="center">MT💫</h1>""")
|
@@ -76,6 +76,6 @@ with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
|
|
76 |
|
77 |
split.change(caller_split, inputs=[split], outputs=[index_example, prompt, completion])
|
78 |
index_example.release(identity, inputs=[index_example, split], outputs=[prompt, completion])
|
79 |
-
button.click(save, inputs=[index_example, language, split, translated_prompt, translated_completion], outputs=[index_example, prompt, completion])
|
80 |
|
81 |
demo.launch(debug=True)
|
|
|
36 |
return ds["prompt"], ds["completion"]
|
37 |
|
38 |
def save(index, language, split, prompt, completion):
|
39 |
+
with open("/home/user/app/output.jsonl", "a") as fout :
|
40 |
fout.write(
|
41 |
json.dumps(
|
42 |
{
|
|
|
48 |
)+"\n"
|
49 |
)
|
50 |
next_index = min(1+index, len(samples[split])-1)
|
51 |
+
return next_index, samples[split][next_index]["prompt"], samples[split][next_index]["completion"], "", ""
|
52 |
|
53 |
with gr.Blocks(analytics_enabled=False, css=custom_css) as demo:
|
54 |
gr.HTML("""<h1 align="center">MT💫</h1>""")
|
|
|
76 |
|
77 |
split.change(caller_split, inputs=[split], outputs=[index_example, prompt, completion])
|
78 |
index_example.release(identity, inputs=[index_example, split], outputs=[prompt, completion])
|
79 |
+
button.click(save, inputs=[index_example, language, split, translated_prompt, translated_completion], outputs=[index_example, prompt, completion, translated_prompt, translated_completion])
|
80 |
|
81 |
demo.launch(debug=True)
|