python - 模块“dialogflow_v2.types”没有“QueryInput”成员
问题描述
我尝试使用 python 调用 dialogflow api,但出现错误
模块“dialogflow_v2.types”没有“QueryInput”成员
请帮帮我。
import dialogflow
def detect_intent_texts(project_id, session_id, texts, language_code):
session_client = dialogflow.SessionsClient()
session = session_client.session_path(project_id, session_id)
print('Session path: {}\n'.format(session))
for text in texts:
text_input = dialogflow.types.TextInput(text=text, language_code=language_code)
query_input = dialogflow.types.QueryInput(text=text_input)
response = session_client.detect_intent(session=session, query_input=query_input)
print('Fulfillment text: {}\n'.format(response.query_result.fulfillment_text))
detect_intent_texts("upcl-b0ba9","abcd",["hello"],"en-US")
解决方案
这是您的问题的解决方案,而不是
import dialogflow_v2 as dialogflow
text_input = dialogflow.types.TextInput(text=text, language_code=language_code)
query_input = dialogflow.types.QueryInput(text=text_input)
试试这样
from dialogflow_v2.types import TextInput, QueryInput
text_input = TextInput(text=text, language_code=language_code)
query_input = QueryInput(text=text_input)
推荐阅读
- javascript - 如何从 JavaScript 中的其他方法/函数获取值
- ms-access - MS Access 使用带有组合框的 Macro Builder 中的 ApplyFilter 显示输入参数框
- javascript - Textarea动态高度调整大小滚动问题
- javascript - 如何使用 ng2-pdf-viewer 和 cdk 拖动将元素拖动到 pdf 并粘贴元素?
- aem - 无法将图标添加到 aem 中的新自定义 RTE 插件
- python - 从 Tkinter 保存后无法打开 Excel 文件
- kendo-ui - 有没有办法在 Kendo Grid 中像这样编辑单个单元格?
- regex - Splunk rex 表达式以删除 json 文件中存在的逗号
- java - Firebase Android(Java)无需登录即可创建新帐户
- php - codeigniter base_url 未在 XAMPP 中更新