syntax_fix_new_intents

This commit is contained in:
ahmed531998 2023-04-20 03:54:29 +02:00
parent a25ca844c8
commit f186889f03
2 changed files with 13 additions and 7 deletions

View File

@ -91,7 +91,8 @@ class ResponseGenerator:
def gen_response(self, action, utterance=None, name=None, username=None, vrename=None, state=None, consec_history=None, chitchat_history=None): def gen_response(self, action, utterance=None, name=None, username=None, vrename=None, state=None, consec_history=None, chitchat_history=None):
if action == "Help": if action == "Help":
commands = " You can choose between using one of the supported commands to explore the environment or you can use natural language to find resourcesand get answers and summaries. \n " commands = " You can choose between using one of the supported commands to explore the environment or you can use natural language to find resourcesand get answers and summaries. \n "
return "Hey " + name + "! it's Janet! I am here to help you make use of the datasets and papers in the catalogue of the " + vrename +" VRE. I can answer questions whose answers may be inside the papers. I can summarize papers for you. I can also chat with you. So, whichever it is, I am ready to chat!" + commands + self.gen_response(action="listCommands") listofcommands = self.gen_response(action="listCommands")
return "Hey " + name + "! it's Janet! I am here to help you make use of the datasets and papers in the catalogue of the " + vrename +" VRE. I can answer questions whose answers may be inside the papers. I can summarize papers for you. I can also chat with you. So, whichever it is, I am ready to chat!" + commands + listofcommands
elif action == "Recommend": elif action == "Recommend":
prompt = self.recommender.make_recommendation(username, name) prompt = self.recommender.make_recommendation(username, name)
if prompt != "": if prompt != "":
@ -103,7 +104,7 @@ class ResponseGenerator:
return "I am sorry, I cannot answer to this kind of language" return "I am sorry, I cannot answer to this kind of language"
elif action == "getHelp": elif action == "getHelp":
commands = self.gen_response(action="listCommands") commands = self.gen_response(action="listCommands")
return "I can answer questions related to the papers in the VRE's catalogue. I can also get you the posts, papers and datasets from the catalogue if you specify a topic or an author. I am also capable of small talk and summarizing papers to an extent. Just write to me what you want and I will do it. Alternatively, you may use one of the commands Janet supports. " + commands return "I can answer questions related to the papers in the VRE's catalogue. I can also get you the posts, papers and datasets from the catalogue if you specify a topic or an author. I am also capable of small talk and summarizing papers to an extent. Just write to me what you want in natural language and I will try to do it. Alternatively, you may use one of the commands Janet supports. " + commands
elif action == "findPost": elif action == "findPost":
for entity in state['entities']: for entity in state['entities']:
@ -211,14 +212,18 @@ class ResponseGenerator:
return "According to the following evidence: " + evidence + " \n _______ \n " + "The answer is: " + answer return "According to the following evidence: " + evidence + " \n _______ \n " + "The answer is: " + answer
elif action == "listPapers": elif action == "listPapers":
answer = vrename + " has the following papers: \n" answer = vrename + " has the following papers: \n"
for i, pap in self.db['paper_db']: j = 1
answer = answer + ' ' + str(i) + ') ' + pap['title'] + ': ' + pap['notes'] + ' \n ' for i, pap in self.db['paper_db'].iterrows():
answer = answer + ' ' + str(j) + ') ' + pap['title'] + ': ' + pap['notes'] + ' \n '
j+=1
return answer return answer
elif action == "listDatasets": elif action == "listDatasets":
j = 1
answer = vrename + " has the following datasets: \n" answer = vrename + " has the following datasets: \n"
for i, datase in self.db['dataset_db']: for i, datase in self.db['dataset_db'].iterrows():
answer = answer + ' ' + str(i) + ') ' + datase['title'] + ': ' +datase['notes'] + ' \n ' answer = answer + ' ' + str(j) + ') ' + datase['title'] + ': ' +datase['notes'] + ' \n '
j+=1
return answer return answer
elif action == "listCommands": elif action == "listCommands":
@ -226,7 +231,7 @@ class ResponseGenerator:
elif action == "listTopics": elif action == "listTopics":
topics = {} topics = {}
for i, pos in self.db['post_db']: for i, pos in self.db['post_db'].iterrows():
for tag in pos['tags']: for tag in pos['tags']:
topics[tag] = topics[tag]+1 if tag in topics else 1 topics[tag] = topics[tag]+1 if tag in topics else 1
topics = sorted(topics, reverse=True) topics = sorted(topics, reverse=True)

View File

@ -150,6 +150,7 @@ def feedback():
print(data) print(data)
try: try:
conn = psycopg2.connect(host="janet-pg", database=os.getenv("POSTGRES_DB"), user=os.getenv("POSTGRES_USER"), password=os.getenv("POSTGRES_PASSWORD")) conn = psycopg2.connect(host="janet-pg", database=os.getenv("POSTGRES_DB"), user=os.getenv("POSTGRES_USER"), password=os.getenv("POSTGRES_PASSWORD"))
cur = conn.cursor() 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)', 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)',