【问题标题】:Module 'dialogflow_v2.types' has no 'QueryInput' member模块“dialogflow_v2.types”没有“QueryInput”成员
【发布时间】:2019-06-07 06:51:41
【问题描述】:

我尝试使用 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")

【问题讨论】:

  • 这个问题有什么更新吗?我也面临同样的问题。

标签: python dialogflow-es


【解决方案1】:

这是您问题的解决方案 而不是

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)

【讨论】:

    【解决方案2】:

    此错误是由于名为 pylint 的 linter 包引起的。您只需键入以下内容即可将其卸载:

        pip uninstall pylint 
    

    【讨论】:

    • pylint 未安装
    • 我尝试重现您的问题,但我只能找到导致它的几个原因。 1)。使用 lint/linter 工具。因此,卸载它解决了问题。 (尽管这似乎不适用于您的情况。) 2)。在第一次安装这个包时,pip 获取了以前的稳定版本,这造成了一些兼容性问题,所以一个简单的更新解决了这个问题。 pip install --upgrade dialogflow 你可以通过运行pip freeze' The following version should be there in the list: dialogflow==0.6.0`来检查你的模块版本`
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-10
    • 2021-03-25
    • 2021-05-26
    • 2020-09-01
    • 2020-03-08
    • 2021-08-24
    • 1970-01-01
    相关资源
    最近更新 更多