Giter Club home page Giter Club logo

dialogflow-python-client's Introduction

DEPRECATED api.ai: Python SDK for API.AI

Deprecated
This Dialogflow client library and Dialogflow API V1 have been deprecated and will be shut down on October 23th, 2019. Please migrate to Dialogflow API V2 and the v2 client library

.. image:: https://badge.fury.io/py/apiai.svg :target: http://badge.fury.io/py/apiai

.. image:: https://travis-ci.org/api-ai/api-ai-python.svg :target: https://travis-ci.org/api-ai/api-ai-python

Overview

The API.AI Python SDK makes it easy to integrate speech recognition with API.AI natural language processing API. API.AI allows using voice commands and integration with dialog scenarios defined for a particular agent in API.AI.

Prerequsites

Create an API.AI account <http://api.ai>_.

Running examples

  1. Find examples from 'examples' path.
  2. Insert API key.

.. code-block:: python

>>> CLIENT_ACCESS_TOKEN = '<YOUR_CLIENT_ACCESS_TOKEN>'
...

Features

  • Speech Recognition.
  • Voice Activity Detection.
  • Natural Language Processing.

Installation

To install apiai, simply:

.. code-block:: bash

$ pip install apiai

or install it from repo:

.. code-block:: bash

$ pip install https://github.com/api-ai/api-ai-python.git

You might run into problems because some dependencies in your python environment are missing. You need to install numpy (which is available in almost all package managers). For running the examples you also need python audio.

In ubuntu the following will do the job:

.. code-block:: bash

$ apt-get install python-pyaudio python-numpy
$ pip install apiai

Documentation

Documentation is available at http://api.ai.

How to make contributions?

Please read and follow the steps in the CONTRIBUTING.md.

License

See LICENSE.

Terms

Your use of this sample is subject to, and by using or downloading the sample files you agree to comply with, the Google APIs Terms of Service.

This is not an official Google product.

dialogflow-python-client's People

Contributors

bohdantkachenko avatar dainedanielson avatar jhoelzl avatar mermolenko avatar renepickhardt avatar s4chin avatar terrabakky avatar volnt avatar xvir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dialogflow-python-client's Issues

Issue in creating intent

I am beginner to dialogflow and try to create an intent but having some issue.can anyone please tell me how to solve the following error.

Traceback (most recent call last):
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\google\api_core\grpc_helpers.py", line 54, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\grpc\_channel.py", line 500, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\grpc\_channel.py", line 434, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.INVALID_ARGUMENT, Context ID must not be empty.)>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\django-2.0.5-py3.6.egg\django\core\handlers\exception.py", line 35, in inner
    response = get_response(request)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\django-2.0.5-py3.6.egg\django\core\handlers\base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\django-2.0.5-py3.6.egg\django\core\handlers\base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\django-2.0.5-py3.6.egg\django\views\decorators\csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\django-2.0.5-py3.6.egg\django\views\generic\base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\rest_framework\views.py", line 483, in dispatch
    response = self.handle_exception(exc)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\rest_framework\views.py", line 443, in handle_exception
    self.raise_uncaught_exception(exc)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\rest_framework\views.py", line 480, in dispatch
    response = handler(request, *args, **kwargs)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\rest_framework\decorators.py", line 53, in handler
    return func(*args, **kwargs)
  File "C:\Users\Aakash\Documents\projects\umwelt-project\umwelt-api\api\admin_api\admin_views.py", line 127, in intervention
    message_texts,second_response,input_context,output_context,followup_parent_intent,payload)
  File "C:\Users\Aakash\Documents\projects\umwelt-project\umwelt-api\api\admin_api\intent_management.py", line 159, in create_intent
    response = intents_client.create_intent(parent, intent)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\dialogflow_v2\gapic\intents_client.py", line 408, in create_intent
    request, retry=retry, timeout=timeout, metadata=metadata)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\google\api_core\gapic_v1\method.py", line 139, in __call__
    return wrapped_func(*args, **kwargs)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\google\api_core\retry.py", line 260, in retry_wrapped_func
    on_error=on_error,
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\google\api_core\retry.py", line 177, in retry_target
    return target()
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\google\api_core\timeout.py", line 206, in func_with_timeout
    return func(*args, **kwargs)
  File "C:\Users\Aakash\AppData\Local\Programs\Python\Python36\lib\site-packages\google\api_core\grpc_helpers.py", line 56, in error_remapped_callable
    six.raise_from(exceptions.from_grpc_error(exc), exc)
  File "<string>", line 3, in raise_from
google.api_core.exceptions.InvalidArgument: 400 Context ID must not be empty

Thanks

AttributeError: 'module' object has no attribute 'UserEntityEntry'

File "tt.py", line 40, in main
apiai.UserEntityEntry('Firefox', ['Firefox']),
AttributeError: 'module' object has no attribute 'UserEntityEntry'

In the example

def main():
ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN,'')

 # some unuque session id for user identification
 session_id = uuid.uuid4().hex

 entries = [
     apiai.UserEntityEntry('Firefox', ['Firefox']),
     apiai.UserEntityEntry('XCode', ['XCode']),
     apiai.UserEntityEntry('Sublime Text', ['Sublime Text'])
 ]

json.loads error string expected not bytes

When I use the json.loads(request.getresponse().read()) function an error pops up " TypeError: the JSON object must be str, not 'bytes' ".
The response.read() function works well and I get a JSON object printed out with the correct intent and action however json.loads isnt working.
I am using this as a part of a Django application.
Is there any other way to access the attributes of the response?

Thanks ,
Gautam.

Code snippet:

    ai = apiai.ApiAI(client_base)
request = ai.text_request()
request.session_id = "xxx...xxxx"
request.query = msg
response = json.loads(request.getresponse().read())
#print("now printing response")
result = response['result']
action = result.get('action')
print(action)

Browser Error Snippet:

TypeError at /Main/
the JSON object must be str, not 'bytes'
Request Method: GET
Request URL: http://127.0.0.1:8000/Main/
Django Version: 1.10.1
Exception Type: TypeError
Exception Value:
the JSON object must be str, not 'bytes'

AttributeError: 'module' object has no attribute 'ApiAI'

I have installed apiai by :
$ apt-get install python-pyaudio python-numpy
$ pip install apiai

When I run "send_text_example.py", I get the following error :

ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN)
AttributeError: 'module' object has no attribute 'ApiAI'

If I clone the repo to my local, I can run it successfully.

Voice

As the voice request is deprecated, how should we send voice from now on?

Error when https_proxy env variable is set, but is empty

In some cases there might be https_proxy env variable set, but empty and in this case the following error appears:

Traceback (most recent call last):
  ...........
  File "/usr/local/lib/python2.7/site-packages/apiai/apiai.py", line 101, in text_request
    self.session_id)
  File "/usr/local/lib/python2.7/site-packages/apiai/requests/query/text.py", line 31, in __init__
    session_id)
  File "/usr/local/lib/python2.7/site-packages/apiai/requests/query/query.py", line 179, in __init__
    {'v': version}
  File "/usr/local/lib/python2.7/site-packages/apiai/requests/request.py", line 46, in __init__
    self._prepare_proxy()
  File "/usr/local/lib/python2.7/site-packages/apiai/requests/request.py", line 66, in _prepare_proxy
    (self.proxy_host, self.proxy_port) = https_proxy.split(":")
ValueError: need more than 1 value to unpack

Remove numpy references from code

I would like to take a stab at replacing the numpy references in code with the corresponding pure python equivalent so that the code is pure python and has a smaller installation footprint. Would this be something of interest?

How can i add a source from the request?

How can i add a source from the request like facebook,for example when someone write a message from facebook messeger the webhook recieves a parameter called originalRequest{ source: "facebook", data: {objects} }, how can i added, i need it for handle a specific client

status code = 200, but no result

{ "id": "be29b06a-84dc-4e86-99dc-20a0ad49a2e9", "timestamp": "2016-04-21T01:10:16.984Z", "result": { "source": "agent", "resolvedQuery": "hello", "contexts": [], "metadata": {}, "fulfillment": { "speech": "" }, "score": 0 }, "status": { "code": 200, "errorType": "success" } }

How to pass the parameters to vad

This is my code:

import sys
from VAD import VAD

vad = VAD()
f = open('worker_2.pcm')
fr = f.read()
result = vad.processFrame(fr)
print(result)

invoke like this?
But it met error.

frame = np.array(frame_input).astype(np.float32) ValueError: could not convert string to float:

Can you give a demo show how to use?

thanks!

How to access user entity values submitted by `send_user_entities_example.py` on api.ai platform?

Hello,

I am trying to access set some User Entities for my session using the python-client. Then use ai.api insert the Value of the User Entity in the text response.

I have successfully ran the user entity sample code send_user_entities_example.py.

However I am unsure of how to simply access the submitted entity value from api.ai to insert it into my text response.

All documentation I have found regarding the use of ai.api UserEntites has been quite vague. Code comments refer to https://api.ai/docs/reference/agent/userentities which states:

A good scenario could be when you have a playlist entity that has generic playlist. As playlists are user-specific, playlist entity could be defined in a request or for a given session.

This is the only source of information I could find online about UserEntites, it does not explain how to access user entity values from the api.ai platform agent.

Further instruction/documentation about "how to access the user entity values submitted by send_user_entities_example.py on the api.ai platform agent" would be greatly appreciated.

access tokens in examples

While looking through the examples I noticed that both the send_file_example and the send_text_example contain an access token, instead of the 'YOUR_ACCESS_TOKEN' string. Is this intended or a mistake?

Incomplete API ?

It seems that this Python SDK only supports the 'query' and 'userEntity' parts of the API, what about the rest ? Is it possible to add new entities or intents ?

Thanks!

Couldn't return the response

Hi there,

There is a weird response behavior that i could't understand, when i try to send a query that matches one of my custom intents, i get the following error

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
CloudFront attempted to establish a connection with the origin, but either the attempt failed or the origin closed the connection.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: YeniHRaduRn5dVzhK3L0cLTc2tMeqLaoPNhby3N9Zk6j-PQkOF8lPg==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
CloudFront attempted to establish a connection with the origin, but either the attempt failed or the origin closed the connection.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: JAJeScxuDj-X97YHn_piTfMWNak8XxVvI7EScppuwUgJO4IkwwMo8Q==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>

Note that:

  • I get the json response if the query is assigned to one of the predefined domains (eg: Smalltalk)
  • I'm sending the request from within an HTTP method

Any ideas ?

Documentation

You've done a great work.That's awesome, but can you make documentation more informative. Consider following:
1.)List of methods available
2.)Intuitive

setup.py tries to open README.rst which doesn't exist

I ran into this error when I tried to pip install the package using the command in the README.md
(this one: pip install https://github.com/api-ai/api-ai-python.git, I actually had to prepend git+ to the URL so maybe that should be added to the README as well).

Here's the exact error that I got:

$ pip install git+https://github.com/api-ai/api-ai-python.git
Collecting git+https://github.com/api-ai/api-ai-python.git
  Cloning https://github.com/api-ai/api-ai-python.git to /private/var/folders/8x/xnhc28b96zz1_k8_sdfdkjzr0000gn/T/pip-EW675N-build
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/8x/xnhc28b96zz1_k8_sdfdkjzr0000gn/T/pip-EW675N-build/setup.py", line 51, in <module>
        with open('README.rst', 'r') as f:
    IOError: [Errno 2] No such file or directory: 'README.rst'

I went ahead and cloned the repository and changed README.rst to README.md and ran python setup.py and the package installed properly.

As far as I can tell, this should be a really easy fix -- just switch out README.rst with READM.md. Please let me know if I'm missing anything though and if this isn't actually and issue with the package but an issue on my side.

How do you convert google.cloud.dialogflow_v2.types.QueryResult to a python dictionary?

I'm trying to convert a google.cloud.dialogflow_v2.types.QueryResult object to a simple python dictionary. I've got a fairly large custom payload coming through the webhook_payload attribute. Needless to say, when I simply call dict() on this object, I'm getting a lot of nested objects. I'm trying to avoid 1) writing a function to extract all the data from these nested objects, and 2) using the REST API.

Thanks for any help in advance.

response = session_client.detect_intent(session=session, query_input=query_input)
type(response.query_result.webhook_payload)
# google.cloud.dialogflow_v2.types.Struct

dict(response.query_result.webhook_payload)
# {u'hangouts': fields {
#   key: "cards"
#   value {
#     list_value {
#       values {
#         struct_value {
#           fields {
#             key: "header"
#             value {
#               struct_value {
#                 fields {
#                   key: "imageStyle"
#                   value {
#                     string_value: "IMAGE"

Getting an invalid token access [404:ERROR] for test example

Hi there,

There is a weird response behavior that i could't understand, when i try to send a client access token that does not matches with any of my custom intents, i get the following error

import os.path
import sys

try:
import apiai
except ImportError:
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(file)), os.pardir))
import apiai

CLIENT_ACCESS_TOKEN = 'EAACbVYVA6zcBALOf6UlyEuS8vVTZCPVxHHbBZCZCkVkZA26OZAJMgWERZBF8ldKpRFVTD9A0LnP6zDNRVPlgWJetCkldZAYEJTqpZCP8iVPCMPXBbGsFZBtZBZCUaaMhKAS8FQtZBUnwc5sCq8ZAKn55gfbjTAUF9Bj3kzfirMNeq3g3wAAz5feWL1nAE'

def main():
ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN)

request = ai.text_request()

request.lang = 'de'  # optional, default value equal 'en'

request.session_id = "170791610149687"

request.query = "Hello"

response = request.getresponse()

print(response.read())

if name == 'main':
main()

the error is as follows

b'{"status":{"code":401,"errorType":"unauthorized","errorDetails":"You are not authorized for this operation. Invalid access token: EAACbVYVA6zcBALOf6UlyEuS8vVTZCPVxHHbBZCZCkVkZA26OZAJMgWERZBF8ldKpRFVTD9A0LnP6zDNRVPlgWJetCkldZAYEJTqpZCP8iVPCMPXBbGsFZBtZBZCUaaMhKAS8FQtZBUnwc5sCq8ZAKn55gfbjTAUF9Bj3kzfirMNeq3g3wAAz5feWL1nAE"}}'

Managing Entities

I've had a look at the Python client, and I can't find a way of creating or updating entities. There's only code for user entities. Does the client support this, and is there an example that we can look at?

Thanks

ImportError: No module named 'apiai'

I am getting the following error while trying to run the example for text input

Traceback (most recent call last):
File "/home/vpr/mysite/flask_app.py", line 2, in
import apiai
ImportError: No module named 'apiai'

I think there is a mistake in the module, could it be checked?

Example code gives json request parse error

As the old voice_request is marked deprecated, I'm using a text_request to send audio data as instructed here, using a wav file (Unsigned 8 bit, or Signed 16 bit Little Endian, Rate 16000 Hz). However, this gives me the following result:

{
  "error": {
    "code": "002",
    "errorId": "ab6473fe-a57a-49ed-8a08-21a58570be78",
    "message": "json request parse error"
  }
}

What am I doing wrong?

ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN)

Happens direct when i try to add the Token

Traceback (most recent call last):
File "send_user.py", line 66, in
main()
File "send_user.py", line 34, in main
ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN)
TypeError: init() takes exactly 3 arguments (2 given)

How to disable ssl verification for ai.text_request()

In the python text examples

request = ai.text_request()
request.lang = 'de' # optional, default value equal 'en'
request.session_id = "<SESSION ID, UNIQUE FOR EACH USER>"
request.query = "Hello"
response = request.getresponse()

Is there any way to omit ssl verification for the text_request() and getresponse() methods.
As, I am using HTTPS, in the server side all the requests require ssl verification.

I need something like the request

requests.get('https://kennethreitz.com', verify=False)

So, text request and response going through api.ai will not check for any ssl certificate.

docs location

the README says docs are on api.ai but the link there just comes back to this page.
feedback loop!

how to train through python

I saw examples here, But could not find how to create an agent, how to train it with my own data through program.

Please help.

Unable to install numpy on Heroku

Messages from Heroku
remote: ! Hello! It looks like you're trying to use scipy on Heroku.
remote: ! Unfortunately, at this time, we do not directly support this library.
remote: ! There is, however, a buildpack available that makes it possible to use it on Heroku.
remote: ! You can learn more here: https://devcenter.heroku.com/articles/python-c-deps
remote: ! Sorry for the inconvenience. -- Much Love, Heroku.
remote: ! Push rejected, failed to compile Python app.

remote: config = setup_module.configuration(*args)
remote: File "scipy/setup.py", line 12, in configuration
remote: config.add_subpackage('integrate')
remote: File "/app/.heroku/python/lib/python3.6/site-packages/numpy/distutils/misc_util.py", line 966, in add_subpackage
remote: caller_level = 2)
remote: File "/app/.heroku/python/lib/python3.6/site-packages/numpy/distutils/misc_util.py", line 935, in get_subpackage
remote: caller_level = caller_level + 1)
remote: File "/app/.heroku/python/lib/python3.6/site-packages/numpy/distutils/misc_util.py", line 872, in _get_configuration_from_setup_py
remote: config = setup_module.configuration(*args)
remote: File "scipy/integrate/setup.py", line 12, in configuration
remote: blas_opt = get_info('blas_opt',notfound_action=2)
remote: File "/app/.heroku/python/lib/python3.6/site-packages/numpy/distutils/system_info.py", line 350, in get_info
remote: return cl().get_info(notfound_action)
remote: File "/app/.heroku/python/lib/python3.6/site-packages/numpy/distutils/system_info.py", line 509, in get_info
remote: raise self.notfounderror(self.notfounderror.doc)
remote: numpy.distutils.system_info.BlasNotFoundError:
remote: Blas (http://www.netlib.org/blas/) libraries not found.
remote: Directories to search for the libraries can be specified in the
remote: numpy/distutils/site.cfg file (section [blas]) or by setting
remote: the BLAS environment variable.
remote:
remote: ----------------------------------------
remote: Command "/app/.heroku/python/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-81516mi4/scipy/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-sy5tyxb3-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-81516mi4/scipy/
remote:
remote: ! Hello! It looks like you're trying to use scipy on Heroku.
remote: ! Unfortunately, at this time, we do not directly support this library.
remote: ! There is, however, a buildpack available that makes it possible to use it on Heroku.
remote: ! You can learn more here: https://devcenter.heroku.com/articles/python-c-deps
remote: ! Sorry for the inconvenience. -- Much Love, Heroku.
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to.
remote:

! [remote rejected] master -> master (pre-receive hook declined)

Preserve Api.ai SessionId for Dialog Mode

Hello,

i use the example script to send a text request. However, i have a Api.ai Intent that includes a required value, so after the first request i got a question back from Api.ai to specify the value for that intent.

To answer the question, i have to make a new request by using the session_id of the first request. Otherwise the context is reseted: https://docs.api.ai/docs/query

On each request, the example script generates a new session_id.

I tried to specify the session_id on my own, such as:

ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN, SUBSCRIPTION_KEY)
request = ai.text_request()
request.lang = lang
request.session_id = "c8819d00-9145-48af-8171-b0489448cded"
request.query = inputtext
response = request.getresponse()
api_resp = response.read()

But the additional parameter session_id is not used. I think the code in https://github.com/api-ai/api-ai-python/blob/master/apiai/apiai.py#L95 has to be modified.

Can somebody help me?
Thanks!

Rename apiai to dialogflow

As api.ai is now dialogflow, I would like to change all references of api.ai to dialogflow in the code and make a major release since this would break the existing implementations. Let me know if I can start working on this.

cannot attach new context

Seems I cannot attach a new context.

apiai_req = ai.text_request()
apiai_req.lang = 'en'
print("attaching context " + str(session['contexts']))
apiai_req.contexts = session['contexts']
apiai_req.query = from_human_message

bot_response = json.loads(apiai_req.getresponse().read().decode('utf-8'))

apiai_req.contexts = session['contexts'] <<< this line is the problem. it cannot modify the context.

there's a method for reseting contexts, but what shoudl I do if I want to modify the contexts ?

Speech Recognition - Deprecation

The speech recognition seems to have been deprecated, hence it should also be marked so in the README.md file to avoid confusion.

use .decode('utf-8') after the .read()

Python 3.5

if you don't use:

.decode("utf-8") after you ask getresponse().read() ->

this you'll get:

  File "/usr/lib/python3.5/http/client.py", line 1187, in getresponse
    raise ResponseNotReady(self.__state)
http.client.ResponseNotReady: Idle

so it might be a good idea to update the sample code for the people not to dig into stackoverflow...etc.

I have a problem with api-ai-python

*Hi, I have a problem, I can not find a solution,

Can you help me?

When I run the example file:

Say! Press enter for stop audio recording.
Traceback (most recent call last):
File "C:\Users\HP\workspace\audior\audior\raudio.py", line 48, in callback
request.send(data)
File "C:\Users\HP\Anaconda2\lib\site-packages\apiai\requests\query\voice.py", line 56, in send
super(VoiceRequest, self).send(b(newChunk))
File "C:\Users\HP\Anaconda2\lib\site-packages\apiai\requests\request.py", line 112, in send
self.connect()
File "C:\Users\HP\Anaconda2\lib\site-packages\apiai\requests\request.py", line 103, in connect
begin = self._prepage_begin_request_data()
File "C:\Users\HP\Anaconda2\lib\site-packages\apiai\requests\query\voice.py", line 80, in _prepage_begin_request_data
'entities': self._prepare_entities()
File "C:\Users\HP\Anaconda2\lib\json__init.py", line 244, in dumps
return _default_encoder.encode(obj)
File "C:\Users\HP\Anaconda2\lib\json\encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\Users\HP\Anaconda2\lib\json\encoder.py", line 270, in iterencode
return _iterencode(o, 0)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xed in position 13: invalid continuation byte
Traceback (most recent call last):
File "C:\Users\HP\workspace\audior\audior\raudio.py", line 91, in
main()
File "C:\Users\HP\workspace\audior\audior\raudio.py", line 83, in main
p.terminate()
File "C:\Users\HP\Anaconda2\lib\site-packages\pyaudio.py", line 688, in terminate
for stream in self._streams.copy():
TypeError: function takes exactly 5 arguments (0 given)**

Create an agent through the lib.

Hello,

Could you please help me understand, how I can create a new agent object though this lib and if it's even possible?

Thanks!

Regards,
Andrew.

import error in apiai module

I am getting the following error while trying to run the example for text input

File "/Library/Python/2.7/site-packages/apiai/init.py", line 36, in
from .requests.query import Entry
ImportError: No module named requests.query

I think there is a mistake in the module, could it be checked?

SSL error

This the error that i have:

Traceback (most recent call last):
File "/home/osmc/alfred/robot/stt/api.py", line 50, in callback
request.send(data)
File "/usr/local/lib/python2.7/dist-packages/apiai/requests/query/voice.py", line 56, in send
super(VoiceRequest, self).send(b(newChunk))
File "/usr/local/lib/python2.7/dist-packages/apiai/requests/request.py", line 112, in send
self._connect()
File "/usr/local/lib/python2.7/dist-packages/apiai/requests/request.py", line 78, in _connect
self._connection.connect()
File "/usr/lib/python2.7/httplib.py", line 1212, in connect
server_hostname=server_hostname)
File "/usr/lib/python2.7/ssl.py", line 350, in wrap_socket
_context=self)
File "/usr/lib/python2.7/ssl.py", line 566, in init
self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 788, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)

Pip list :
apiai (1.0.2)
requests (2.4.3)
urllib3 (1.9.1)

Thanking in advance for any help

examples

the examples use next to a key also a session_id. they don't show how to retrieve it but apparently there is a session id when apiai is initialized.
anyway with i use the session id that returned by initialising the module but just get an "code":401,"errorType":"unauthorized
{"status":{"code":401,"errorType":"unauthorized","errorDetails":"You are not authorized for this operation. Invalid access token: \u003capiai.apiai.ApiAI object at 0x10067df90\u003e"}}

Unable to connect via the proxy [407 AuthorizedOnly]

Getting the following error when connecting to API AI via proxy.
socket.error: Tunnel connection failed: 407 AuthorizedOnly

When I looked into request.py I could see HTTPConnection being used which only considers proxy server and port and not the username and password.

Do you plan to support requests module or another fix so that username and password can also be passed to authenticate against proxies.

Ideally should take username/password from environment with the pattern:
https://<username>:<password>@<proxy_server>:<port>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.