Apprentice
Apprentice is a library for deploying and developing actions via Dialogflow and Google Cloud Functions.
Installation
Use the package manager pip to install Apprentice.
pip install apprentice
Quickstart
A Google Action project will consist of two things:
- A Dialogflow defined action
- An endpoint that your Dialogflow Action can talk to.
To generate a Hello World application, you can run:
$ apprentice init
This will create a file structure:
hello_world_agent/
main.py
requirements.txt
main.py is the file that gcloud looks for to upload the function.
It is important that the name, main.py, remains in order to use gcloud cli.
Testing
To make local development quicker, you can run a local server with
$ apprentice run
Deployment
Note
gcloud cli must be installed and authorized for the following command
to work. If you wish to not have gcloud cli installed, you can copy the file contents via the gcloud
function dashboard.
$ apprentice -f hello_world -s hello_world_agent -e hello_world
This will generate the command to execute a gcloud function deploy via the cli.
Example Project
import random
import requests
from apprentice import format_response, generate_intent_response
def cool_fact_generator(*args, **kwargs):
data = _fact_response()
formatted_data = generate_intent_response(data)
return format_response(formatted_data)
def _fact_response():
res = requests.get('https://history.muffinlabs.com/date')
data = res.json().get('data')
fact = random.choice(data['Events'])
year = fact['year']
text = fact['text']
phrase = f'Today, in the year {year} {text}'
return phrase
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Metadata
Release files for apprentice 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| apprentice-0.1.6.tar.gz | 18.3 kB | Details |
Release files / apprentice-0.1.6.tar.gz
| Download URL | apprentice-0.1.6.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f44ee36aa9b91caf433d26ea75ffaf94844f0bece3af00a3f501a97628dbbb3a
|
|
BLAKE2b-256 checksum How to use checksums |
b4b1c69ce815eb92d22ed6c18775e8c64f339b36f776e6927df353d8c5dc7542
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3
|