python - Dialogflow api检测意图在Windows上不起作用
问题描述
我创建了一个 dialogflow 代理,并且在我的 mac 上使用 dialogflow api 已经有一段时间了。当我开始在 Windows 上工作时,出现了这个问题。基本上我的代码执行直到它到达该行
response = session_client.detect_intent(session=session, query_input=query_input)
它不会抛出错误或存在。它只是卡在那里,根据我的代理的历史记录,没有发送任何请求。我不知道这是操作系统问题还是缺少其他东西。您可以在下面查看我的代码:
import dialogflow
from google.api_core.exceptions import InvalidArgument
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = 'private-key.json'
DIALOGFLOW_PROJECT_ID = 'campus-guide-xetlpf'
DIALOGFLOW_LANGUAGE_CODE = 'en'
SESSION_ID = 'me'
text_to_be_analyzed = "Hello"
session_client = dialogflow.SessionsClient()
session = session_client.session_path(DIALOGFLOW_PROJECT_ID, SESSION_ID)
text_input = dialogflow.types.TextInput(text=text_to_be_analyzed, language_code=DIALOGFLOW_LANGUAGE_CODE)
query_input = dialogflow.types.QueryInput(text=text_input)
try:
print(query_input)
print(session)
response = session_client.detect_intent(session=session, query_input=query_input)
except InvalidArgument:
raise
print("Query text:", response.query_result.query_text)
print("Detected intent:", response.query_result.intent.display_name)
print("Detected intent confidence:", response.query_result.intent_detection_confidence)
print("Fulfillment text:", response.query_result.fulfillment_text)
输出:
文本 { 文本:“你好” 语言代码:“en” }
项目/校园指南-xetlpf/代理/会话/我
更新: 当我调试时,我得到了这个,它看起来像是 grpc 请求中的错误。任何线索为什么?
解决方案
推荐阅读
- react-native - 未找到 React/RCTDefines.h' 文件 (RN0.61)
- bash - 在 Mac os 中执行 Bash 脚本:目录不存在错误
- spring-cloud-stream - Spring Cloud Stream 多个函数定义
- javascript - 将值直接传递给 http 请求与之前定义之间的区别
- python-3.x - 将字符串转换为python中的字典列表
- vue.js - 如何在 Vuejs 中测试受保护的路由保护的访问?
- react-native - 如果值更改,图标会更改
- google-apis-explorer - 在 Cloud AutoML Vision 中将图像导入 Google 存储时出错
- javascript - 如何在对象中深入了解此 JSON 对象
- c# - web.config 中到一个 SQL DB 的两个连接字符串在调试时工作,但在发布时不工作