Skip to main content

Python bindings for Snips Hermes Protocol

Project description

# Hermes Python
[![Build Status](https://travis-ci.org/snipsco/hermes-protocol.svg?branch=hermes-python-ffi)](https://travis-ci.org/snipsco/hermes-protocol)
[![PyPI version](https://badge.fury.io/py/hermes-python.svg)](https://badge.fury.io/py/hermes-python)

The `hermes-python` library provides python bindings for the Hermes protocol that snips components use to communicate together.
`hermes-python` allows you to interface seamlessly with the Snips platform and quick start development of Voice applications.

`hermes-python` abstracts away the connection to the MQTT bus and the parsing of incoming and outcoming messages from and to the components of the snips platform.

## Installation
The library is packaged as a pre-compiled platform wheel, available on [PyPi](https://pypi.org/project/hermes-python/).
It can be installed with :
```
pip install hermes-python
```

Or you can add it to your `requirements.txt` file.

### Requirements
The wheel is available for Python 2.7+ and Python 3.5

The wheel supports the following platform tags :
- `manylinux1_x86_64`
- `armv7l`, `armv6`
- `macos`

## Usage

The lifecycle of a script using `hermes-python` has the following steps :
- Initiating a connection to the MQTT broker
- Registering callback functions to handle incoming intent parsed by the snips platform
- Listening to incoming intents
- Closing the connection

Let's quickly dive into an example : Let's write an app for a Weather Assistant !
This code implies that you created a weather assistant using the [snips Console](https://console.snips.ai), and that it has a *`searchWeatherForecast`* intent.

Here is a code example for `python2.7` :

```
from hermes_python.hermes import Hermes

MQTT_ADDR = "localhost:1883" # Specify host and port for the MQTT broker

def subscribe_weather_forecast_callback(hermes, intentMessage): # Defining callback functions to handle an intent that asks for the weather.
print("Parsed intent : {}".format(intentMessage.intent.intent_name))


with Hermes(MQTT_ADDR) as h: # Initialization of a connection to the MQTT broker
h.subscribe_intent("searchWeatherForecast", subscribe_weather_forecast_callback) \ # Registering callback functions to handle the searchWeatherForecast intent
.start()

# We get out of the with block, which closes and releases the connection.

```

### Examples
#### Handling the `intent_message` object
*Coming soon.*

#### Providing TTS feedback for a voice application
*Coming soon.*

## Documentation
### Hermes protocol documentation
If you want to dive deeper into how Snips components communicate together, check out the specification of the `hermes-protocol` [here](https://docs.snips.ai/ressources/hermes-protocol).
You can also check this repository for other language bindings.

### API
*Coming soon.*

## History
### 0.1.26 (2019-01-02)
* LICENSING : This wheel now has the same licenses as the parent project : APACHE-MIT.
* Subscription to not recognized intent messages is added to the API. You can now write your own callbacks to handle unrecognized intents.
* Adds send_intent_not_recognized flag to continue session : indicate whether the dialogue manager should handle non recognized intents by itself or sent them as an `IntentNotRecognizedMessage` for the client to handle.

### 0.1.25 (2018-12-13)
* Better error handling : Errors from wrapped C library throw a LibException with detailled errors.




Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

hermes_python-0.1.26-cp37-cp37m-manylinux1_x86_64.whl (2.8 MB view hashes)

Uploaded CPython 3.7m

hermes_python-0.1.26-cp37-cp37m-macosx_10_13_x86_64.whl (3.7 MB view hashes)

Uploaded CPython 3.7m macOS 10.13+ x86-64

hermes_python-0.1.26-cp36-cp36m-manylinux1_x86_64.whl (2.8 MB view hashes)

Uploaded CPython 3.6m

hermes_python-0.1.26-cp36-cp36m-macosx_10_9_x86_64.whl (3.7 MB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

hermes_python-0.1.26-cp35-cp35m-manylinux1_x86_64.whl (2.8 MB view hashes)

Uploaded CPython 3.5m

hermes_python-0.1.26-cp35-cp35m-linux_armv7l.whl (2.7 MB view hashes)

Uploaded CPython 3.5m

hermes_python-0.1.26-cp35-cp35m-linux_armv6l.whl (2.7 MB view hashes)

Uploaded CPython 3.5m

hermes_python-0.1.26-cp34-cp34m-manylinux1_x86_64.whl (2.8 MB view hashes)

Uploaded CPython 3.4m

hermes_python-0.1.26-cp27-cp27mu-manylinux1_x86_64.whl (2.8 MB view hashes)

Uploaded CPython 2.7mu

hermes_python-0.1.26-cp27-cp27mu-linux_armv7l.whl (2.7 MB view hashes)

Uploaded CPython 2.7mu

hermes_python-0.1.26-cp27-cp27mu-linux_armv6l.whl (2.7 MB view hashes)

Uploaded CPython 2.7mu

hermes_python-0.1.26-cp27-cp27m-manylinux1_x86_64.whl (2.8 MB view hashes)

Uploaded CPython 2.7m

hermes_python-0.1.26-cp27-cp27m-macosx_10_13_x86_64.whl (3.7 MB view hashes)

Uploaded CPython 2.7m macOS 10.13+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page