Exemple #1
0
async def test_agent_with_model_server_in_thread(model_server, tmpdir,
                                                 zipped_moodbot_model,
                                                 moodbot_domain,
                                                 moodbot_metadata):
    model_endpoint_config = EndpointConfig.from_dict({
        "url":
        model_server.make_url('/model'),
        "wait_time_between_pulls":
        2
    })

    agent = Agent()
    agent = await rasa.core.agent.load_from_server(
        agent, model_server=model_endpoint_config)

    await asyncio.sleep(3)

    assert agent.fingerprint == "somehash"

    assert agent.domain.as_dict() == moodbot_domain.as_dict()

    agent_policies = {
        utils.module_path_from_instance(p)
        for p in agent.policy_ensemble.policies
    }
    moodbot_policies = set(moodbot_metadata["policy_names"])
    assert agent_policies == moodbot_policies
    assert model_server.app.number_of_model_requests == 1
    jobs.kill_scheduler()
Exemple #2
0
async def test_nlg(http_nlg, default_agent_path):
    sender = str(uuid.uuid1())

    nlg_endpoint = EndpointConfig.from_dict({"url": http_nlg})
    agent = Agent.load(default_agent_path, None, generator=nlg_endpoint)

    response = await agent.handle_text("/greet", sender_id=sender)
    assert len(response) == 1
    assert response[0] == {"text": "Hey there!", "recipient_id": sender}
Exemple #3
0
def test_tracker_store_endpoint_config_loading():
    cfg = utils.read_endpoint_config(DEFAULT_ENDPOINTS_FILE, "tracker_store")

    assert cfg == EndpointConfig.from_dict({
        "type": "redis",
        "url": "localhost",
        "port": 6379,
        "db": 0,
        "password": "******",
        "timeout": 30000
    })
Exemple #4
0
async def test_wait_time_between_pulls_without_interval(
        model_server, monkeypatch):

    monkeypatch.setattr("rasa.core.agent.schedule_model_pulling",
                        lambda *args: 1 / 0)  # will raise an exception

    model_endpoint_config = EndpointConfig.from_dict({
        "url":
        model_server.make_url('/model'),
        "wait_time_between_pulls":
        None
    })

    agent = Agent()
    # schould not call schedule_model_pulling, if it does, this will raise
    await rasa.core.agent.load_from_server(agent,
                                           model_server=model_endpoint_config)
    jobs.kill_scheduler()
Exemple #5
0
def test_nlg_endpoint_config_loading():
    cfg = utils.read_endpoint_config(DEFAULT_ENDPOINTS_FILE, "nlg")

    assert cfg == EndpointConfig.from_dict(
        {"url": "http://localhost:5055/nlg"})
Exemple #6
0
 def from_credentials(cls, credentials):
     return cls(EndpointConfig.from_dict(credentials))