diff --git a/main.py b/main.py index 230b416..d87bff5 100644 --- a/main.py +++ b/main.py @@ -38,8 +38,6 @@ conn = psycopg2.connect( user=os.getenv("POSTGRES_USER"), password=os.getenv("POSTGRES_PASSWORD")) -cur = conn.cursor() - users = {} def vre_fetch(): @@ -157,7 +155,7 @@ def predict(): def feedback(): data = request.get_json().get("feedback") print(data) - + 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)', (data['query'], data['history'], data['modQuery'], data['queryModCorrect'], data['correctQuery'], data['evidence'], data['janetResponse'], data['preferredResponse'], data['length'], @@ -165,7 +163,7 @@ def feedback(): data['speed'], data['intent']) ) conn.commit() - + cur.close() reply = jsonify({"status": "done"}) return reply @@ -202,7 +200,8 @@ if __name__ == "__main__": threading.Thread(target=vre_fetch, name='updatevre').start() threading.Thread(target=clear_inactive, name='clear').start() - + + cur = conn.cursor() cur.execute('CREATE TABLE IF NOT EXISTS feedback_experimental (id serial PRIMARY KEY,' 'query text NOT NULL,' @@ -220,5 +219,5 @@ if __name__ == "__main__": 'response_intent text NOT NULL);' ) conn.commit() - + cur.close() app.run(host='0.0.0.0')