예제 #1
0
    def learn(self, train):
        h = pd.read_csv('./app/database/hello_skill.csv')
        hello = PatternMatchingSkill(responses=[
            x for x in h['responses'].tolist() if x != ' ' and x == x
        ],
                                     patterns=[
                                         x for x in h['patterns'].tolist()
                                         if x != ' ' and x == x
                                     ])

        b = pd.read_csv('./app/database/bye_skill.csv')
        bye = PatternMatchingSkill(responses=[
            x for x in b['responses'].tolist() if x != ' ' and x == x
        ],
                                   patterns=[
                                       x for x in b['patterns'].tolist()
                                       if x != ' ' and x == x
                                   ])

        f = pd.read_csv('./app/database/fallback_skill.csv')
        fallback = PatternMatchingSkill(responses=[
            x for x in f['responses'].tolist() if x != ' ' and x == x
        ],
                                        default_confidence=0.1)
        faq = SimilarityMatchingSkill(data_path=self.DATANAME,
                                      x_col_name='Question',
                                      y_col_name='Answer',
                                      save_load_path=self.MODELNAME,
                                      config_type='tfidf_autofaq',
                                      train=train)

        self.d = DefaultAgent([hello, bye, faq, fallback],
                              skills_selector=HighestConfidenceSelector())
예제 #2
0
 def setup(self):
     # print(configs.aiml_skill)
     config_ref = configs.skills.rasa_skill
     install_from_config(config_ref)
     # rasa_skill = build_model(
     #     "/home/alx/Workspace/DeepPavlov/deeppavlov/configs/aiml_skill/rasa_skill.json",
     #     download=True)
     rasa_skill = build_model(config_ref, download=True)
     self.agent = DefaultAgent([rasa_skill],
                               skills_selector=HighestConfidenceSelector())
예제 #3
0
 def __init__(self,
              skills: List[Skill],
              skills_processor: Optional[Processor] = None,
              skills_filter: Optional[Filter] = None,
              *args,
              **kwargs) -> None:
     super(DefaultAgent, self).__init__(skills=skills)
     self.skills_filter: Filter = skills_filter or TransparentFilter(
         len(skills))
     self.skills_processor: Processor = skills_processor or HighestConfidenceSelector(
     )
예제 #4
0
def make_hello_bot_agent() -> DefaultAgent:
    """Builds agent based on PatternMatchingSkill and HighestConfidenceSelector.

    This is agent building tutorial. You can use this .py file to check how hello-bot agent works.

    Returns:
        agent: Agent capable of handling several simple greetings.
    """
    skill_hello = PatternMatchingSkill(['Hello world'],
                                       patterns=['hi', 'hello', 'good day'])
    skill_bye = PatternMatchingSkill(['Goodbye world', 'See you around'],
                                     patterns=['bye', 'chao', 'see you'])
    skill_fallback = PatternMatchingSkill(
        ['I don\'t understand, sorry', 'I can say "Hello world"'])

    agent = DefaultAgent([skill_hello, skill_bye, skill_fallback],
                         skills_processor=HighestConfidenceSelector())

    return agent
예제 #5
0
 def setup(self):
     config_ref = configs.skills.aiml_skill
     install_from_config(config_ref)
     aiml_skill = build_model(config_ref, download=True)
     self.agent = DefaultAgent([aiml_skill],
                               skills_selector=HighestConfidenceSelector())
예제 #6
0
from deeppavlov.skills.pattern_matching_skill import PatternMatchingSkill
from deeppavlov.agents.default_agent.default_agent import DefaultAgent 
from deeppavlov.agents.processors.highest_confidence_selector import HighestConfidenceSelector

hello = PatternMatchingSkill(responses=['Hello world!'], patterns=["hi", "hello", "good day"])
bye = PatternMatchingSkill(['Goodbye world!', 'See you around'], patterns=["bye", "chao", "see you"])
fallback = PatternMatchingSkill(["I don't understand, sorry", 'I can say "Hello world!"'])

HelloBot = DefaultAgent([hello, bye, fallback], skills_selector=HighestConfidenceSelector())

print(HelloBot(['Hello!', 'Boo...', 'Bye.']))

예제 #7
0
from deeppavlov.agents.default_agent.default_agent import DefaultAgent
from deeppavlov.agents.processors.highest_confidence_selector import HighestConfidenceSelector
from deeppavlov.skills.pattern_matching_skill import PatternMatchingSkill

if __name__ == '__main__':
    bye = PatternMatchingSkill(['Goodbye world!', 'See you around'],
                               patterns=['bye', 'ciao', 'see you'])
    hello = PatternMatchingSkill(responses=['Hello world!'],
                                 patterns=['good day', 'hello', 'hi'])
    fallback = PatternMatchingSkill(['I\'m sorry; I don\'t understand.'])
    agent = DefaultAgent([hello, bye, fallback],
                         skills_selector=HighestConfidenceSelector())
    for query in ['Hello', 'Bye', 'Or not']:
        response = agent([query])
        print('Q: {} A: {}'.format(query, response[0]))