This commit is contained in:
ahmed531998 2023-04-20 07:05:13 +02:00
parent 34eed5cf3b
commit f2bb7e77df
1 changed files with 7 additions and 5 deletions

12
main.py
View File

@ -133,7 +133,9 @@ def predict():
response = rg.gen_response(action=action, utterance=state['modified_query'], state=dm.get_recent_state(), consec_history=dm.get_consec_history(), chitchat_history=dm.get_chitchat_history(), vrename=vre.name, username=users[token]['username'], name=users[token]['name'].split()[0])
message = {"answer": response, "query": text, "cand": "candidate", "history": dm.get_consec_history(), "modQuery": state['modified_query']}
if state['intent'] == "QA":
response = response.split("_______ \n The answer is: ")[1]
split_response = response.split("_______ \n ")
if len(split_response) > 1:
response = split_response[1]
new_state = {'modified_query': response, 'intent': state['intent']}
dm.update(new_state)
reply = jsonify(message)
@ -150,7 +152,7 @@ def feedback():
print(data)
try:
"""
conn = psycopg2.connect(host="janet-pg", database=os.getenv("POSTGRES_DB"), user=os.getenv("POSTGRES_USER"), password=os.getenv("POSTGRES_PASSWORD"))
cur = conn.cursor()
cur.execute('INSERT INTO feedback_experimental (query, history, janet_modified_query, is_modified_query_correct, user_modified_query, evidence_useful, response, preferred_response, response_length_feedback, response_fluency_feedback, response_truth_feedback, response_useful_feedback, response_time_feedback, response_intent) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
@ -160,7 +162,7 @@ def feedback():
data['speed'], data['intent']))
conn.commit()
cur.close()
"""
reply = jsonify({"status": "done"})
return reply
@ -200,7 +202,7 @@ if __name__ == "__main__":
threading.Thread(target=vre_fetch, name='updatevre').start()
threading.Thread(target=clear_inactive, name='clear').start()
"""
conn = psycopg2.connect(host="janet-pg", database=os.getenv("POSTGRES_DB"), user=os.getenv("POSTGRES_USER"), password=os.getenv("POSTGRES_PASSWORD"))
cur = conn.cursor()
@ -222,5 +224,5 @@ if __name__ == "__main__":
)
conn.commit()
cur.close()
"""
app.run(host='0.0.0.0')