模块“ dialogflow_v2.types”没有“ QueryInput”成员

时间:2019-06-07 06:51:41

标签: python dialogflow

我尝试使用python调用dialogflow api,但由于“模块'dialogflow_v2.types'没有'QueryInput'成员”而出错,请帮帮我。

导入对话框流程

def detect_intent_texts(项目ID,会话ID,文本,语言代码):     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”)

2 个答案:

答案 0 :(得分:0)

由于称为pylint的linter软件包而发生此错误。您只需输入以下内容即可将其卸载:

    pip uninstall pylint 

答案 1 :(得分:0)

这是您的问题的解决方案 代替

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)