示例#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)
示例#2
0
文件: bot.py 项目: ml-ds-data/chiron
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}}
示例#3
0
文件: bot.py 项目: Leothorn/Chiron
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}}
示例#4
0
文件: bot.py 项目: ml-ds-data/chiron
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}}
示例#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)
示例#6
0
 def test_get_agent_from_cache(self):
     agent = AgentProcessor.get_agent("tests")
     assert isinstance(agent, Agent)
示例#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}}