コード例 #1
0
ファイル: test_utils.py プロジェクト: lesalami/rasa
def test_warning_for_base_paths_with_trailing_slash(caplog):
    test_path = "base/"

    with caplog.at_level(logging.DEBUG, logger="rasa.utils.endpoints"):
        assert concat_url(test_path, None) == test_path

    assert len(caplog.records) == 1
    def get_model_server_url(tag: Text = DEFAULT_RASA_ENVIRONMENT) -> Text:
        """Creates the model server url for a given tag."""

        model_server_host = os.environ.get("RASA_X_HOST", "http://rasa-x:5002")
        model_server_url = endpoints.concat_url(
            model_server_host, "/api/projects/default/models/tags/{}")

        return model_server_url.format(tag)
コード例 #3
0
    def _duckling_parse(self, text: Text,
                        reference_time: int) -> List[Dict[Text, Any]]:
        """Sends the request to the duckling server and parses the result.

        Args:
            text: Text for duckling server to parse.
            reference_time: Reference time in milliseconds.

        Returns:
            JSON response from duckling server with parse data.
        """
        parse_url = endpoints_utils.concat_url(self._url(), "/parse")
        try:
            payload = self._payload(text, reference_time)
            headers = {
                "Content-Type":
                "application/x-www-form-urlencoded; charset=UTF-8"
            }
            response = requests.post(
                parse_url,
                data=payload,
                headers=headers,
                timeout=self.component_config.get("timeout"),
            )
            if response.status_code == 200:
                return response.json()
            else:
                logger.error(
                    f"Failed to get a proper response from remote "
                    f"duckling at '{parse_url}. Status Code: {response.status_code}. Response: {response.text}"
                )
                return []
        except (
                requests.exceptions.ConnectionError,
                requests.exceptions.ReadTimeout,
        ) as e:
            logger.error(
                "Failed to connect to duckling http server. Make sure "
                "the duckling server is running/healthy/not stale and the proper host "
                "and port are set in the configuration. More "
                "information on how to run the server can be found on "
                "github: "
                "https://github.com/facebook/duckling#quickstart "
                "Error: {}".format(e))
            return []
コード例 #4
0
ファイル: test_utils.py プロジェクト: lesalami/rasa
def test_concat_url(base, subpath, expected_result):
    assert concat_url(base, subpath) == expected_result
コード例 #5
0
def test_concat_url(base, subpath, expected_result):
    assert endpoint_utils.concat_url(base, subpath) == expected_result