Skip to content

Commit

Permalink
edit passing context
Browse files Browse the repository at this point in the history
Took 33 minutes
  • Loading branch information
SirojiddinSaidmurodov committed Oct 18, 2021
1 parent 04476a3 commit 1a860f3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
RESULTS = {}


def get_context(user_id):
def get_context(user_id) -> str:
try:
return CONTEXT[user_id]
except KeyError:
Expand All @@ -33,7 +33,8 @@ def get_context(user_id):
@bot.message_handler(commands=['help'])
def handle_help(message):
bot.send_message(message.from_user.id,
"""Этот бот предназначен для демонстрации работы вопросно-ответной системы на основе модели BERT. Команды:
"""Этот бот предназначен для демонстрации работы вопросно-ответной системы на основе модели BERT.
Команды:
/c контекст - задать текст, в котором будет производиться поиск ответов на вопросы.
/q вопрос - задать вопрос по тексту
/wiki - искать статью в Википедии
Expand All @@ -52,7 +53,7 @@ def answer_question(message):
if len(get_context(message.from_user.id)) > 0:
question: str = message.text[1:]
logging.debug(get_context(message.from_user.id))
answers = model([get_context(message.from_user.id)], [question])
answers = model(get_context(message.from_user.id).split(". "), [question])
logging.info(answers)
bot.send_message(message.from_user.id, answers)
else:
Expand Down

0 comments on commit 1a860f3

Please sign in to comment.