This commit is contained in:
ahmed531998 2023-04-19 11:23:43 +02:00
parent 310dc23ba3
commit 9d71cdaec9
1 changed files with 24 additions and 21 deletions

45
main.py
View File

@ -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 == "<HELP_ON_START>":
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,'