Exemplo n.º 1
0
    def test_get_agent(self, monkeypatch):
        def mongo_store(*arge, **kwargs):
            return None

        monkeypatch.setattr(Utility, "get_local_mongo_store", mongo_store)
        agent = AgentProcessor.get_agent("tests")
        assert isinstance(agent, Agent)
Exemplo n.º 2
0
async def chat(request_data: TextData,
               current_user: User = Depends(auth.get_current_user)):
    """ This function returns a bot response for a given text/query. It is basically
        used to test the chat functionality of the bot """
    model = AgentProcessor.get_agent(current_user.get_bot())
    response = await model.handle_text(request_data.data,
                                       sender_id=current_user.get_user())
    return {"data": {"response": response[0]["text"] if response else None}}
Exemplo n.º 3
0
async def predict_intent(request_data: TextData,
                         current_user: User = Depends(auth.get_current_user)):
    model = AgentProcessor.get_agent(current_user.get_bot())
    response = await model.parse_message_using_nlu_interpreter(
        request_data.data)
    intent = response.get("intent").get("name") if response else None
    confidence = response.get("intent").get("confidence") if response else None
    return {"data": {"intent": intent, "confidence": confidence}}
Exemplo n.º 4
0
async def predict_intent(request_data: TextData,
                         current_user: User = Depends(auth.get_current_user)):
    """ This function returns the predicted intent of the entered text by using the trained
        rasa model of the chatbot """
    model = AgentProcessor.get_agent(current_user.get_bot())
    response = await model.parse_message_using_nlu_interpreter(
        request_data.data)
    intent = response.get("intent").get("name") if response else None
    confidence = response.get("intent").get("confidence") if response else None
    return {"data": {"intent": intent, "confidence": confidence}}
Exemplo n.º 5
0
 def test_get_agent_from_cache_does_not_exists(self):
     with pytest.raises(AppException):
         agent = AgentProcessor.get_agent("test")
         assert isinstance(agent, Agent)
Exemplo n.º 6
0
 def test_get_agent_from_cache(self):
     agent = AgentProcessor.get_agent("tests")
     assert isinstance(agent, Agent)
Exemplo n.º 7
0
async def chat(request_data: TextData,
               current_user: User = Depends(auth.get_current_user)):
    model = AgentProcessor.get_agent(current_user.get_bot())
    response = await model.handle_text(request_data.data)
    return {"data": {"response": response[0]["text"] if response else None}}