From 38a1d614cfd91f84d0f26fa788baccf428ce54b9 Mon Sep 17 00:00:00 2001 From: ahmed531998 Date: Mon, 17 Apr 2023 08:55:23 +0200 Subject: [PATCH] fixes --- main.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 076b3ae..f6ee6a8 100644 --- a/main.py +++ b/main.py @@ -29,7 +29,7 @@ cors = CORS(app, resources={r"/api/predict": {"origins": url}, r"/api/dm": {"origins": url}, r"/health": {"origins": "*"} }) - +""" conn = psycopg2.connect( host="janet-pg", database=os.getenv("POSTGRES_DB"), @@ -37,7 +37,7 @@ conn = psycopg2.connect( password=os.getenv("POSTGRES_PASSWORD")) cur = conn.cursor() - +""" users = {} def vre_fetch(): @@ -58,10 +58,10 @@ def user_interest_decay(user): def clear_inactive(): while True: time.sleep(1) - for user in users: - if user['activity'] > 3600: - del users[user['username']] - user['activity'] += 1 + for username in users: + if users[username]['activity'] > 3600: + del users[username] + users[username]['activity'] += 1 @app.route("/health", methods=['GET']) def health(): @@ -133,7 +133,7 @@ def predict(): def feedback(): data = request.get_json().get("feedback") print(data) - + """ 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'], @@ -141,7 +141,7 @@ def feedback(): data['speed'], data['intent']) ) conn.commit() - + """ reply = jsonify({"status": "done"}) return reply @@ -185,7 +185,7 @@ if __name__ == "__main__": rg = ResponseGenerator(index,db, rec, generators, retriever) - + """ cur.execute('CREATE TABLE IF NOT EXISTS feedback_experimental (id serial PRIMARY KEY,' 'query text NOT NULL,' 'history text NOT NULL,' @@ -202,5 +202,5 @@ if __name__ == "__main__": 'response_intent text NOT NULL);' ) conn.commit() - + """ app.run(host='0.0.0.0')