From f2bb7e77df882408dffb95c4b9f6f4fc21028ec4 Mon Sep 17 00:00:00 2001 From: ahmed531998 Date: Thu, 20 Apr 2023 07:05:13 +0200 Subject: [PATCH] janet --- main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 09b04ad..b9fcaa1 100644 --- a/main.py +++ b/main.py @@ -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')