Implements the `question_response`, `new_question_answer` and `new_context` methods
#test
import tempfile
from os import path
with tempfile.TemporaryDirectory() as tmpdirname:
ds = DialogSystem(
faq_data_file=path.join(tmpdirname, 'faq_example.csv'),
context_data_file=path.join(tmpdirname, 'context_example.csv'),
download_models=False
)
ds.question_answer(question='What is Intekglobal?')
assert ds.question == 'What is Intekglobal?'
assert isinstance(ds.responses['squad'], dict)
assert isinstance(ds.responses['faq'], dict)
logging.info(f'{ds.question} \n\n {ds.formatted_responses}')
assert 'This should not be in the current set of responses' not in ds.formatted_responses
logging.info(f' dict of responses: {ds.responses}')
logging.info(f'{ds.question} \n\n {ds.formatted_responses}')
ds.new_question_answer(
question='What day is today?', answer='Today is the day!'
)
ds.question_answer(question='What day is today?')
assert 'Today is the day!' in ds.formatted_responses
context = '''Space Exploration Technologies Corp., trading as SpaceX,
is an American aerospace manufacturer and space transportation services company headquartered
in Hawthorne, California. It was founded in 2002 by Elon Musk with the goal of reducing
space transportation costs to enable the colonization of Mars. SpaceX has developed several launch
vehicles,the Starlink satellite constellation, and the Dragon spacecraft.
'''
ds.new_context(topic='SpaceX', context=context)
ds.question_answer(question='What are SpaceX initials stand for?')
logging.info(f'{ds.question} \n\n {ds.formatted_responses}')
assert 'Space Exploration Technologies Corp.' in ds.formatted_responses
#hide