Spaces:
Running
Running
votelog to text connected again
Browse files- app/vote.py +8 -9
app/vote.py
CHANGED
|
@@ -7,20 +7,20 @@ from .init import *
|
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
# Logging
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
def log_text(text):
|
| 12 |
conn = get_db()
|
| 13 |
cursor = conn.cursor()
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
conn.commit()
|
| 18 |
-
else:
|
| 19 |
conn.commit()
|
| 20 |
cursor.close()
|
| 21 |
|
| 22 |
# Vote
|
| 23 |
-
|
| 24 |
def upvote_model(model, uname, battle=False):
|
| 25 |
conn = get_db()
|
| 26 |
cursor = conn.cursor()
|
|
@@ -102,8 +102,7 @@ def is_better(model1, model2, userid, text, chose_a):
|
|
| 102 |
else:
|
| 103 |
upvote_model(model2, str(userid))
|
| 104 |
downvote_model(model1, str(userid))
|
| 105 |
-
log_text(text)
|
| 106 |
-
# log_text(text, votelogid)
|
| 107 |
|
| 108 |
return reload(model1, model2, userid, chose_a=chose_a, chose_b=(not chose_a))
|
| 109 |
|
|
|
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
# Logging
|
| 10 |
+
def log_text(text, voteid):
|
| 11 |
+
# log only hardcoded sentences
|
| 12 |
+
if (text not in sents):
|
| 13 |
+
return
|
| 14 |
|
|
|
|
| 15 |
conn = get_db()
|
| 16 |
cursor = conn.cursor()
|
| 17 |
+
# TODO: multilang
|
| 18 |
+
cursor.execute('INSERT INTO spokentext (spokentext, lang, votelog_id) VALUES (?,?,?)', (text,'en',voteid))
|
| 19 |
+
with scheduler.lock:
|
|
|
|
|
|
|
| 20 |
conn.commit()
|
| 21 |
cursor.close()
|
| 22 |
|
| 23 |
# Vote
|
|
|
|
| 24 |
def upvote_model(model, uname, battle=False):
|
| 25 |
conn = get_db()
|
| 26 |
cursor = conn.cursor()
|
|
|
|
| 102 |
else:
|
| 103 |
upvote_model(model2, str(userid))
|
| 104 |
downvote_model(model1, str(userid))
|
| 105 |
+
log_text(text, votelogid)
|
|
|
|
| 106 |
|
| 107 |
return reload(model1, model2, userid, chose_a=chose_a, chose_b=(not chose_a))
|
| 108 |
|