Welcome to api.ai’s documentation!¶
Contents:
api_ai¶
API.ai Python client
- Free software: ISC license
- Documentation: https://apiai.readthedocs.org.
Features¶
- Make queries
- Create Entities
- Create and update Intents
Installation¶
pip install api.ai
Quickstart¶
from api.ai import Agent
agent = Agent(
'<subscription-key>',
'<client-access-token>',
'<developer-access-token>',
)
response = agent.query("Hello there")
Credits¶
- Fulfil.IO Inc
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Installation¶
At the command line:
$ easy_install api.ai
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv api_ai
$ pip install api.ai
Usage¶
To use api_ai in a project:
from api.ai import Agent
Configure the agent:
agent = Agent(
'<subscription-key>',
'<client-access-token>',
'<developer-access-token>',
)
Query:
agent.query("hello there")
Entities¶
List all entities:
agent.entities.all()
Create a new Entity:
agent.entities.create(
'Languages', [
{'value': 'Python', 'synonyms': ['python', 'py']},
{'value': 'Golang', 'synonyms': ['go', 'google go language']},
]
)
Update an entity with new entries:
agent.entities.update(
'entity-id-uuid',
[
{'value': 'Python', 'synonyms': ['python', 'py']},
{'value': 'Golang', 'synonyms': ['go', 'google go language']},
],
)
Intents¶
List all intents:
agent.intents.all()
Create a new Intent:
agent.intents.create(
'name',
'templates': [
"Who am I?"
]
)
API Reference¶
-
class
api.ai.
Agent
(sub_key, client_token, dev_token, session=None, timezone=None)[source]¶ Agent interface for an API.AI agent
-
entities
¶ Return an entities handler object
-
intents
¶ Return an intents handler object
-
query
(query, confidence=None, lang='en', contexts=None, resetContexts=False, entities=None, timezone=None, session=None)[source]¶ Use when you want to make a single query.
For multiple queries use multi_query (TODO)
Parameters: - query – The natural language text to be processed.
- confidence – The confidence of the corresponding query parameter having been correctly recognized by a speech recognition system. 0 represents no confidence and 1 represents the highest confidence.
-
-
class
api.ai.
Entities
(client)[source]¶ An entity is a data type that contains mappings between a set of synonyms
-
all
()¶ return all the records in the endpoint
-
create
(name, entries)[source]¶ Create a new entity with the name
Parameters: - name – Name of the entity
- entries – List of dictionaries
agent.entities.create( 'EntityName', [{ "value": "Coffee Maker", "synonyms": ["coffee maker", "coffee machine"] }, { "value": "Thermostat", "synonyms": ["Thermostat", "heat", "air conditioning"] }, { "value": "Lights", "synonyms": ["lights", "light", "lamps"] }, { "value": "Garage door", "synonyms": ["garage door", "garage"] }] )
-
-
class
api.ai.
Intents
(client)[source]¶ Intents convert a number of user expressions or patterns into an action.
-
all
()¶ return all the records in the endpoint
-
create
(name, contexts=None, templates=None, responses=None)[source]¶ For explanation of the params read: https://docs.api.ai/docs/intents#intent-object
-
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/fulfilio/api_ai/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.
Write Documentation¶
api_ai could always use more documentation, whether as part of the official api_ai docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/fulfilio/api_ai/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up api_ai for local development.
Fork the api_ai repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/api_ai.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv api_ai $ cd api_ai/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 api_ai tests $ python setup.py test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check https://travis-ci.org/fulfilio/api_ai/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Fulfil.IO Inc. <hello@fulfil.io>
Contributors¶
None yet. Why not be the first?