1

I'm trying to integrate a chatbot on my Pepper robot using Dialogflow API. Everything works fine except the latency for getting responses from Dialogflow agent is very high (about 10 seconds to execute the following line according to my time log):

response = self.detect_intent_texts(project_id,session_id,question,language_code)

Also, there are warnings about this request:

/home/nao/.local/lib/python2.7/site-packages/urllib3/util/ssl_.py:365: SNIMissingWarning: An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings SNIMissingWarning

/home/nao/.local/lib/python2.7/site-packages/urllib3/util/ssl_.py:149: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings InsecurePlatformWarning

I'm not sure if this is related to the latency, but it seems that I need to update the python version of my Pepper (2.7.6 for now). However I don't know if the python version on Pepper is updatable or if everything will still work if I do update the python version.

Apart from this, do you have other ideas about reducing the latency?

3 Answers3

2

Have you tried another connection? E.g. mobile hotspot?

So you can find out if it is some issue with your network.

Also check this post on how to get rid of InsecurePlatformWarning Or this.

It would also be helpful if you provide context of you function call.

I assume detect_intent_texts implementation is this ?

Please note that this method also imports dialogflow_v2, creates the SessionsClient object and the session path. But this is not neccessary for every utterance. So if call this method for each utterance, you conversation will have a bigger latency.

How do you measure your lacency? do you do something like:

start = time.time()
detect_intent_texts(
print("recognition took: " + str(time.time() - start)[:5])

better measure the query only in the for loop of detect_intent_texts:

for text in texts:
    start = time.time()
    [...]
    print("querytook: " + str(time.time() - start)[:5])

I dont think a python update will be possible since you dont have root access.

TVK
  • 1,042
  • 7
  • 21
  • Here's my code for the function: project_id = "xxxxxxxxxxxxx" session_id = "yyyyyyyyyyyyy" message = "zzzzzzzzz" language_code = "en" response = self.detect_intent_texts(project_id,session_id,message,language_code) – user10819593 Sep 18 '19 at 14:56
  • Actually I'm not using a loop for detect_intent_texts. I just send one single message to the agent and get one single answer for one time. – user10819593 Sep 18 '19 at 15:03
  • Please get used to add informations to your question, rather to comments. Also message should be an array. So here might be the cause for your latency. If you pass a string each char will be send in a separate message. In your example there will be 9 querys for "z". So please try message=["zzzzzzzzz"] instead of message = "zzzzzzzzz" – TVK Sep 19 '19 at 11:42
  • btw: In my network 9 "z" querys took 5.5s, one "zzzzzzzzz" query took 3.2s – TVK Sep 19 '19 at 11:49
  • Thank you for your suggestions. Actually I've already deleted the loop for treating the array in the function and just send one text to the agent at a time. Since the reponse I get is always right, so I suppose the query is not seperated. – user10819593 Sep 19 '19 at 13:46
  • However I moved the code for the creation of the session out of my function as you said and now the latency is largely reduced from the second request. Thank you very much for your help! – user10819593 Sep 19 '19 at 14:08
1

There is a huge Latency when initial access validation is performed. The documentation says it is normal to have multiple seconds for validation: https://cloud.google.com/dialogflow/docs/best-practices

Sorry, I don't think it is normal such LONG validation time and it completely destroys the initial user experience waiting so much.

I'm sure Google engineers can solve it to make it under 1 second. Please do!

Thanks, Francisco

0

You may want to try puting your system on the right timezone and the right time. TLS certificates use the system time to validate. And your response time may be a lot quicker.

  • Thank you, this is a good point. But the timezone and time of my system do correspond with those of my Dialogflow agent. – user10819593 Sep 17 '19 at 13:57