google-cloud-platform - Dialogflow:未找到 agentId 的代理元数据
问题描述
我正在尝试detect_intent
在 Python 中使用 Dialogflow,但我不断得到:
404 com.google.apps.framework.request.NotFoundException:找不到 agentId 的代理元数据:####-####-####-####-####
这是我的代码片段:
import google.cloud.dialogflow as dialogflow
from CONFIG import DIALOGFLOW_PROJECT_ID
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = 'credentials/dialogflow.json'
def predict_intent(text, language):
session_client = dialogflow.SessionsClient()
session = session_client.session_path(DIALOGFLOW_PROJECT_ID, SESSION_ID)
text_input = dialogflow.TextInput(text=text, language_code=language)
query_input = dialogflow.QueryInput(text=text_input)
response = session_client.detect_intent(session=session, query_input=query_input) # ERROR
return response.query_result.intent.display_name
我尝试多次运行该函数,其中一些成功,但大多数都属于异常。
我可以使用相同的界面训练机器人,而且效果很好。
我正在使用 Python 3.7 和以下 Google Cloud 模块:google-api-core==2.0.1、google-auth==2.0.2、google-cloud-dialogflow==2.7.1、googleapis-common-protos= =1.53.0。
解决方案
推荐阅读
- python - 问题我的子弹没有射向玩家
- c++ - 当基数为浮点数/双精度时,二进制求幂无法正常工作
- react-native - 在本机反应中未从 Firestore 获取数据
- php - Laravel 模型 created_at 显示不一致
- web - 浏览器未为部署在 aws cloudfront 上的 fetch api 设置 cookie
- python - 如何从用户接受逗号分隔的数字序列并生成列表和元组?
- python-3.x - python中循环的可变宽度
- php - PHP 或 cURL 是否以某种方式缓存其 Web 响应?
- angular - 我在 FormArray 上做错了什么?
- ssh - 如何在 dropbear ssh 中进行端口转发?