add_recommend_functionality

This commit is contained in:
ahmed531998 2023-04-06 21:54:35 +02:00
parent fc8a60cc8f
commit bde0f47843
1 changed files with 7 additions and 1 deletions

View File

@ -77,11 +77,17 @@ def predict():
state = nlu.process_utterance(text, dm.get_consec_history(), dm.get_sep_history())
state['help'] = False
state['inactive'] = False
old_user_interests = user.get_user_interests()
old_vre_material = pd.concat([vre.db['paper_db'], vre.db['dataset_db']]).drop_duplicates(keep=False).reset_index(drop=True)
user_interests = []
for entity in state['entities']:
if entity['entity'] == 'TOPIC':
user_interests.append(entity['value'])
user.update_interests(user_interests)
new_user_interests = user.get_user_interests()
new_vre_material = pd.concat([vre.db['paper_db'], vre.db['dataset_db']]).drop_duplicates(keep=False).reset_index(drop=True)
if (new_user_interests() != old_user_interests or old_vre_material != new_vre_material):
rec.generate_recommendations(new_user_interests, new_vre_material)
dm.update(state)
action = dm.next_action()
response = rg.gen_response(action=action, utterance=state['modified_query'], state=dm.get_recent_state(), consec_history=dm.get_consec_history())
@ -167,4 +173,4 @@ if __name__ == "__main__":
'response_intent text NOT NULL);'
)
conn.commit()
app.run(host='0.0.0.0', port=4000)
app.run(host='0.0.0.0')