Affability
Affability allows for an easy utilization of Google's DialogFlow for natural language understanding. It allows for calling a single function and returning the result from Dialogflow as a class containing all the pertinent data such as detected intent. Communicating with Dialogflow through Affability trades-off features and customizability for simplicity and conciseness.
This can be utilized to understand commands and then perform the relevant tasks based from the detected intent. Affability is ultimately designed to make it easy to integrate DialogFlow in other standalone projects.
Dependencies
As of v1.0.1, affability automatically installs dialogflow. Should speech recognition be needed, the SpeechRecognition pakage needs to be installed.
pip install SpeechRecognition
With an invalid argument, Affability throws an InvalidArgument exception, which requires importing it from the Google API Core exceptions:
from google.api_core.exceptions import InvalidArgument
Installation
pip install affability
Usage
The module can be imported as affability:
import affability
Using the understand function:
The understand function contains 5 parameters: text, credentials, projectID, languageCode, and sessionID. Text is text to be analyzed, credentials is the file path of the authentication key, projectID is the project ID, languageCode is the language, and sessionID is the session ID. All parameters are strings.
affability.understand('textToBeAnalyzed', 'filepath', 'projectIDname', 'en-US', 'me')
The understand function returns the results as an organizer class. This class contains detectedIntent, confidence, reply, action, requiredParamsPresent, and replyParams.
class organizer:
def __init__(self, detectedIntent, confidence, reply, action, requiredParamsPresent, replyParams):
self.detectedIntent = detectedIntent
self.confidence = confidence
self.reply = reply
self.action = action
self.requiredParamsPresent = requiredParamsPresent
self.replyParams = replyParams
For example, to extract and print detected intent:
reply = affability.understand('textToBeAnalyzed', 'filepath', 'projectIDname', 'en-US', 'me')
print(reply.detectedIntent)
Affability throws the InvalidArgument exception when DialogFlow detects invalid arguments. To handle this, it is recommended to use the understand function in a try and except block:
try:
reply = affability.understand('textToBeAnalyzed', 'filepath', 'projectIDname', 'en-US', 'me')
# do something with reply
except InvalidArgument:
# Handle invalid argument error
Sample usage
The sample.py file demonstrates the ease of communicating with Dialogflow through Affability.
Metadata
Release files for affability 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| affability-1.0.3.tar.gz | 2.4 kB | Without provenance | Details for affability-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| affability-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for affability-1.0.3-py3-none-any.whl |
Total release size: 5.5 kB
Release files / affability-1.0.3.tar.gz
| Download URL | affability-1.0.3.tar.gz |
|---|---|
| Size | 2.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b39599943c19c2724355dd0cb1d56f8b9bb68a94e9ae6f3b4b129f9ae7b8be7
|
|
BLAKE2b-256 checksum How to use checksums |
dbac591226faf253955fab9d719f532a777eef0ef14e9a2049325e67561ab71d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.3
|
Release files / affability-1.0.3-py3-none-any.whl
| Download URL | affability-1.0.3-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03b098cd8ce79cf4042838e73a4a603a1e72208810bb3ea5abe647e704021bec
|
|
BLAKE2b-256 checksum How to use checksums |
bc38f63c8facf741c041a7e47a229c580522090febb69d6478485c1911b93831
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.3
|
Security for affability 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.