From f98a6bd10330dfa6f39cf9c20759e433547b1dd9 Mon Sep 17 00:00:00 2001 From: ahmed531998 Date: Wed, 19 Apr 2023 11:23:43 +0200 Subject: [PATCH] up --- main.py | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/main.py b/main.py index d758fe9..6f99cd2 100644 --- a/main.py +++ b/main.py @@ -42,14 +42,18 @@ cur = conn.cursor() users = {} -def vre_fetch(token): +def vre_fetch(): while True: time.sleep(1000) print('getting new material') - users[token]['args']['vre'].get_vre_update() - users[token]['args']['vre'].index_periodic_update() - users[token]['args']['rg'].update_index(vre.get_index()) - users[token]['args']['rg'].update_db(vre.get_db()) + #users[token]['args']['vre'].get_vre_update() + #users[token]['args']['vre'].index_periodic_update() + #users[token]['args']['rg'].update_index(vre.get_index()) + #users[token]['args']['rg'].update_db(vre.get_db()) + vre.get_vre_update() + vre.index_periodic_update() + rg.update_index(vre.get_index()) + rg.update_db(vre.get_db()) def user_interest_decay(token): while True: @@ -83,16 +87,9 @@ def init_dm(): if response.status_code == 200: username = response.json()['result']['username'] name = response.json()['result']['fullname'] - vre = VRE("assistedlab", token, retriever) - vre.init() - index = vre.get_index() - db = vre.get_db() - rg = ResponseGenerator(index,db, rec, generators, retriever) - args = {'vre': vre, 'rg': rg} + + users[token] = {'username': username, 'name': name, 'dm': DM(), 'activity': 0, 'user': User(username, token)} - users[token] = {'username': username, 'name': name, 'dm': DM(), 'activity': 0, 'user': User(username, token), 'args': args} - - threading.Thread(target=vre_fetch, args=(token,), name='updatevre_'+users[token]['username']).start() threading.Thread(target=user_interest_decay, args=(token,), name='decayinterest_'+users[token]['username']).start() message = {"stat": "done"} @@ -108,8 +105,8 @@ def predict(): token = request.get_json().get("token") dm = users[token]['dm'] user = users[token]['user'] - rg = users[token]['args']['rg'] - vre = users[token]['args']['vre'] + #rg = users[token]['args']['rg'] + #vre = users[token]['args']['vre'] message = {} if text == "": state = {'help': True, 'inactive': False, 'modified_query':"", 'intent':""} @@ -152,8 +149,8 @@ def predict(): users[token]['dm'] = dm users[token]['user'] = user users[token]['activity'] = 0 - users[token]['args']['vre'] = vre - users[token]['args']['rg'] = rg + #users[token]['args']['vre'] = vre + #users[token]['args']['rg'] = rg return reply @app.route('/api/feedback', methods = ['POST']) @@ -196,10 +193,16 @@ if __name__ == "__main__": 'chat': chat_generator, 'amb': amb_generator, 'summ': summ_generator} - - - threading.Thread(target=clear_inactive, name='clear').start() rec = Recommender(retriever) + vre = VRE("assistedlab", '2c1e8f88-461c-42c0-8cc1-b7660771c9a3-843339462', retriever) + vre.init() + index = vre.get_index() + db = vre.get_db() + rg = ResponseGenerator(index,db, rec, generators, retriever) + + threading.Thread(target=vre_fetch, name='updatevre').start() + threading.Thread(target=clear_inactive, name='clear').start() + cur.execute('CREATE TABLE IF NOT EXISTS feedback_experimental (id serial PRIMARY KEY,' 'query text NOT NULL,'