AWS Beanstalk 上的 Dialogflow 超时
Dialogflow time out on AWS Beanstalk
我正在尝试使用 Python SDK 集成 DialogFlow。代码:
def detect_action_from_phrase(self, phrase):
"""Returns the result of detect intent with texts as inputs.
Using the same `session_id` between requests allows continuation
of the conversaion."""
print("Called intent detection")
session_client = dialogflow.SessionsClient()
session = session_client.session_path(self.project_id, self.session_id)
text_input = dialogflow.types.TextInput(
text=phrase, language_code=self.language_code)
query_input = dialogflow.types.QueryInput(text=text_input)
print("NLP getting resp")
response = session_client.detect_intent(
session=session, query_input=query_input)
print("Received resp")
intent = response.query_result.intent
action = response.query_result.action
print('=' * 20)
print('Query text: {}'.format(response.query_result.query_text))
print('Detected intent: {} (confidence: {})\n'.format(
response.query_result.intent.display_name,
response.query_result.intent_detection_confidence))
print("Action: {}\n".format(action))
print('Fulfillment text: {}\n'.format(
response.query_result.fulfillment_text))
return action
我将 session_id 设置为“1”。
我有一个帐户凭据 JSON 文件,环境变量指向该文件,如文档中所述。
在本地一切正常,但当我在 AWS Elastic Beanstalk 上使用它时,出于某种原因,它有时会工作,有时会完全超时。脚本在打印 "NLP getting resp".
后开始超时
我不明白这个。关于为什么会发生这种情况的任何提示或调试它的好方法?
我正在使用 v2 API 和 SDK。
我通过添加
解决了这个问题
WSGIApplicationGroup %{GLOBAL}
到etc/httpd/conf.d/wsgi.conf
您可以通过创建 .ebextensions 配置来自动执行此过程
vim.ebextensions/dialogflow-fix.config
将以下内容添加到 dialogflow-fix.config
"/etc/httpd/conf.d/wsgi_custom.conf":
mode: "000644"
owner: root
group: root
content: |
WSGIApplicationGroup %{GLOBAL}
添加到 git
git 添加 .ebextensions/.config
git commit -m 'message here'
部署到 beantalk
eb 部署
我正在尝试使用 Python SDK 集成 DialogFlow。代码:
def detect_action_from_phrase(self, phrase):
"""Returns the result of detect intent with texts as inputs.
Using the same `session_id` between requests allows continuation
of the conversaion."""
print("Called intent detection")
session_client = dialogflow.SessionsClient()
session = session_client.session_path(self.project_id, self.session_id)
text_input = dialogflow.types.TextInput(
text=phrase, language_code=self.language_code)
query_input = dialogflow.types.QueryInput(text=text_input)
print("NLP getting resp")
response = session_client.detect_intent(
session=session, query_input=query_input)
print("Received resp")
intent = response.query_result.intent
action = response.query_result.action
print('=' * 20)
print('Query text: {}'.format(response.query_result.query_text))
print('Detected intent: {} (confidence: {})\n'.format(
response.query_result.intent.display_name,
response.query_result.intent_detection_confidence))
print("Action: {}\n".format(action))
print('Fulfillment text: {}\n'.format(
response.query_result.fulfillment_text))
return action
我将 session_id 设置为“1”。
我有一个帐户凭据 JSON 文件,环境变量指向该文件,如文档中所述。
在本地一切正常,但当我在 AWS Elastic Beanstalk 上使用它时,出于某种原因,它有时会工作,有时会完全超时。脚本在打印 "NLP getting resp".
后开始超时我不明白这个。关于为什么会发生这种情况的任何提示或调试它的好方法?
我正在使用 v2 API 和 SDK。
我通过添加
解决了这个问题WSGIApplicationGroup %{GLOBAL}
到etc/httpd/conf.d/wsgi.conf
您可以通过创建 .ebextensions 配置来自动执行此过程
vim.ebextensions/dialogflow-fix.config
将以下内容添加到 dialogflow-fix.config
"/etc/httpd/conf.d/wsgi_custom.conf":
mode: "000644"
owner: root
group: root
content: |
WSGIApplicationGroup %{GLOBAL}
添加到 git
git 添加 .ebextensions/.config git commit -m 'message here'
部署到 beantalk
eb 部署