Skip to main content

Python bindings for Snips Hermes Protocol

Project description

Hermes Python

Build Status PyPI version

The hermes-python library provides python bindings for the Hermes protocol that snips components use to communicate together over MQTT. hermes-python allows you to interface seamlessly with the Snips platform and kickstart 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.

hermes-python supports the snips-platform at version 1.1.0 - 0.61.1.

Installation

The library is packaged as a pre-compiled platform wheel, available on PyPi. 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, 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. 

Initialization

The connection to your MQTT broker can be configured with the hermes_python.ffi.utils.MqttOptions class.

The Hermes client uses the options specified in the MqttOptions class when establishing the connection to the MQTT broker.

Here is a code example :

from hermes_python.hermes import Hermes
from hermes_python.ffi.utils import MqttOptions

mqtt_opts = MqttOptions()

def simple_intent_callback(hermes, intent_message):
    print("I received an intent !")

with Hermes(mqtt_options=mqtt_opts) as h:
    h.subscribe_intents().loop_forever()

Here are the options you can specify in the MqttOptions class :

  • broker_address: The address of the MQTT broker. It should be formatted as ip:port.
  • username: Username to use on the broker. Nullable
  • password: Password to use on the broker. Nullable
  • tls_hostname: Hostname to use for the TLS configuration. Nullable, setting a value enables TLS
  • tls_ca_file: CA files to use if TLS is enabled. Nullable
  • tls_ca_path: CA path to use if TLS is enabled. Nullable
  • tls_client_key: Client key to use if TLS is enabled. Nullable
  • tls_client_cert: Client cert to use if TLS is enabled. Nullable
  • tls_disable_root_store: Boolean indicating if the root store should be disabled if TLS is enabled.

Let's connect to an external MQTT broker that requires a username and a password :

from hermes_python.hermes import Hermes
from hermes_python.ffi.utils import MqttOptions

mqtt_opts = MqttOptions(username="user1", password="password", broker_address="my-mqtt-broker.com:18852")

def simple_intent_callback(hermes, intent_message):
    print("I received an intent !")

with Hermes(mqtt_options=mqtt_opts) as h:
    h.subscribe_intents().loop_forever()

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. You can also check this repository for other language bindings.

API

Coming soon.

Release Checklist

Everytime you need to perform a release, do the following steps :

  • Commit all changes to the project for said release
  • Write all the changes introduced in the Changelog (HISTORY.rst file) and commit it
  • Run tests
  • Bump the version and commit it
  • Upload to PyPI

Building from sources

Creating macOS wheels

The build script : build_scripts/build_macos_wheels.sh uses pyenv to generate hermes-python wheels for different versions of python.

To be able to run it, you need to :

  • install pyenv : brew install pyenv. Then follow the additional steps (detailled here).
  • you then have to install python at different versions: pyenv install --list to list the available version to install.
  • Before installing and building the different python version from sources, install the required dependencies : https://github.com/pyenv/pyenv/wiki. (This was told in the first step).

You should be good to go !

History

0.3.1 (2019-02-25)

  • Fixes import bug with templates, the hermes_python.ffi.utils module now re-exports MqttOptions

0.3.0 (2019-02-25)

  • IntentClassifierResult's probability field has been renamed to confidence_score.
  • Introduces support for snips-platform 1.1.0 - 0.61.1.

0.2.0 (2019-02-04)

  • Introduces options to connect to the MQTT broker (auth + TLS are now supported).

0.1.29 (2019-01-29)

  • Fixes bug when deserializing TimeIntervalValue that used wrong encode method instead of decode.

0.1.28 (2019-01-14)

  • Fixes bug when the __exit__ method was called twice on the Hermes class.
  • Introduces two methods to the public api : connect and disconnect that should bring more flexibility

0.1.27 (2019-01-07)

  • Fixed broken API introduced in 0.1.26 with the publish_continue_session method of the Hermes class.
  • Cast any string that goes in the mqtt_server_adress parameter in the constructor of the Hermes class to be a 8-bit string.

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

If you're not sure about the file name format, learn more about wheel file names.

hermes_python-0.3.1-cp37-cp37m-manylinux1_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.7m

hermes_python-0.3.1-cp37-cp37m-macosx_10_14_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

hermes_python-0.3.1-cp36-cp36m-manylinux1_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.6m

hermes_python-0.3.1-cp36-cp36m-macosx_10_14_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

hermes_python-0.3.1-cp35-cp35m-manylinux1_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.5m

hermes_python-0.3.1-cp35-cp35m-macosx_10_14_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.5mmacOS 10.14+ x86-64

hermes_python-0.3.1-cp35-cp35m-linux_armv7l.whl (2.8 MB view details)

Uploaded CPython 3.5m

hermes_python-0.3.1-cp35-cp35m-linux_armv6l.whl (2.8 MB view details)

Uploaded CPython 3.5m

hermes_python-0.3.1-cp34-cp34m-manylinux1_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.4m

hermes_python-0.3.1-cp27-cp27mu-manylinux1_x86_64.whl (2.9 MB view details)

Uploaded CPython 2.7mu

hermes_python-0.3.1-cp27-cp27mu-linux_armv7l.whl (2.8 MB view details)

Uploaded CPython 2.7mu

hermes_python-0.3.1-cp27-cp27mu-linux_armv6l.whl (2.8 MB view details)

Uploaded CPython 2.7mu

hermes_python-0.3.1-cp27-cp27m-manylinux1_x86_64.whl (2.9 MB view details)

Uploaded CPython 2.7m

hermes_python-0.3.1-cp27-cp27m-macosx_10_14_x86_64.whl (2.1 MB view details)

Uploaded CPython 2.7mmacOS 10.14+ x86-64

File details

Details for the file hermes_python-0.3.1-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 64b780c27c6f53d9d63cd9aba260bad2f2bb380cbf9bb66543ef090666f19c8a
MD5 2bd299aa68efaee19572d1d57bdad538
BLAKE2b-256 7f06221af88bf52604139b25fc63223e996bdc52903f73f345887a998296d550

See more details on using hashes here.

File details

Details for the file hermes_python-0.3.1-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 e06c34a4cab51543e55414404fe10ec2bd5b5ee41f27810d52d647a11086b398
MD5 1eb1f7191a8572101284bb2b53ace2a7
BLAKE2b-256 512804965d6e0eaa61099b12f836a9a78a9833703ff063e5685cfc74e6c1fd6f

See more details on using hashes here.

File details

Details for the file hermes_python-0.3.1-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 378d859e933755d1f104cc83a04142e7b5476b077f1549d3e1884bef77f1a599
MD5 ecf0e5036a807edcae6273bbcdfbb6ef
BLAKE2b-256 11d2f653d7a9d5047e506a83eeaff91fc7c769408eeb4dc10185fa6117694569

See more details on using hashes here.

File details

Details for the file hermes_python-0.3.1-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 912987b8a39daa3b1287f7ad4d4da1aba2c57b7f094d2e421f15eb7977e6db4f
MD5 39b98152653e48ef6ebf8ddabd72657a
BLAKE2b-256 f1694034e77a2f8c0ab1c372fa7b3238328b24ed0605c55424c816d7c17f5812

See more details on using hashes here.

File details

Details for the file hermes_python-0.3.1-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a3872263cd0810db43441a12ed41e62bfde8a966f766ff3836f84386da9783bd
MD5 ca1cf770fe0d9c92722a723e960c0ecd
BLAKE2b-256 c0994754b0cbad2dd104a72b3505a457763037b2b8854a4ccbabbdec6131eb79

See more details on using hashes here.

File details

Details for the file hermes_python-0.3.1-cp35-cp35m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp35-cp35m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.5m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp35-cp35m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 96009ddec779b6bcfcc45edc293a9f0939fa18687ce0c51cd0a4f73568752f55
MD5 34745b67fec046930f594663c78fc343
BLAKE2b-256 de82a6f055844af3cf44e1e6d67080a8ac71e8746567e128c06a959e4031cb95

See more details on using hashes here.

File details

Details for the file hermes_python-0.3.1-cp35-cp35m-linux_armv7l.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp35-cp35m-linux_armv7l.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp35-cp35m-linux_armv7l.whl
Algorithm Hash digest
SHA256 754850d978f3ba1c83f352a5732a28dc16bfd5a2d5ada359c8e833ef9c1ff08e
MD5 066a962292f0a2452bf26e12f769a23b
BLAKE2b-256 b0d8a11c9cd45833078101080a350769ed72e9134976790a086f41171815aa0c

See more details on using hashes here.

File details

Details for the file hermes_python-0.3.1-cp35-cp35m-linux_armv6l.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp35-cp35m-linux_armv6l.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp35-cp35m-linux_armv6l.whl
Algorithm Hash digest
SHA256 8c4190a7ec38ea4666b1f894be365be604dbc84c41266a463c5923a53abe5dd3
MD5 ce38183ee8ee774cadd39afb6bb30322
BLAKE2b-256 317d4db3c989236973b9b0d5403c0960d16aa9602340ce70641f27ba0cd3d6ca

See more details on using hashes here.

File details

Details for the file hermes_python-0.3.1-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp34-cp34m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.4m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 07b28793f9ca7d9889bd9728a03f88b0271ab035924e3d49b5e84951ecbfcb87
MD5 b04af425b549362e9f6466b71229faf9
BLAKE2b-256 cea620b41a50e63294a2e216101a7fd26d54d03c52c26901cc2c6557cf6c73e4

See more details on using hashes here.

File details

Details for the file hermes_python-0.3.1-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp27-cp27mu-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 2.7mu
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5143b08275e7a749679f34bc95d10637d7ddf68f7b501aac36407fddf23a0b89
MD5 6c949998d87c664f1302c440d05a5b22
BLAKE2b-256 1d1152ad5e1f165216e01ecc52b805bb6db9b87d18909aaf359d3cba3df6890a

See more details on using hashes here.

File details

Details for the file hermes_python-0.3.1-cp27-cp27mu-linux_armv7l.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp27-cp27mu-linux_armv7l.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 2.7mu
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp27-cp27mu-linux_armv7l.whl
Algorithm Hash digest
SHA256 80e37e26a98595a85abafa5d173f74a8f2f376dc590461800bf933b6e484277e
MD5 a955f0e1bdf04c5a3c7772a5ffc11aac
BLAKE2b-256 5c6e328b8a80999dad7274ff6c3849c6e9f71f956d8380d9c46998a5b21a7182

See more details on using hashes here.

File details

Details for the file hermes_python-0.3.1-cp27-cp27mu-linux_armv6l.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp27-cp27mu-linux_armv6l.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 2.7mu
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp27-cp27mu-linux_armv6l.whl
Algorithm Hash digest
SHA256 9c37aacfd86f919f2b836b1b245cf006c0be4bc5774634c141750ee0f66825b2
MD5 1d97ec4252d57a265187bf207d106b4b
BLAKE2b-256 7e19fdf70f78879c0dd8ddb4e8b24ace4379755a6d3727598b5ae1095ad46e28

See more details on using hashes here.

File details

Details for the file hermes_python-0.3.1-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp27-cp27m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 2.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 26fe133cae5752d6958928e93f89cfff6e54620e44e3d650627d84cd83ab9344
MD5 f1fb84161c8fc484cefe95b46199ef69
BLAKE2b-256 deec7fe99ca645e636ba932bb5b268c045a45f5c5bdcaedadfeb63409464e95b

See more details on using hashes here.

File details

Details for the file hermes_python-0.3.1-cp27-cp27m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: hermes_python-0.3.1-cp27-cp27m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 2.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14

File hashes

Hashes for hermes_python-0.3.1-cp27-cp27m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ffd0ffa561e1a84f7df5d40a6e9d4a1955358e27a9a0add2ed4ba7f5e6c70c9d
MD5 387ac07803d90647acdeca2a56bb5fd5
BLAKE2b-256 658b936d1994464609b61587193d904b6a5575fca9dd0afb089db9024c15689e

See more details on using hashes here.

Supported by

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