Dialogflow v2 api завершается неудачно при аутентификации в Python - PullRequest
0 голосов
/ 18 сентября 2018

Итак, мой код работает на консоли, но если я пытаюсь импортировать модуль или запустить код в Интернете, я получаю ошибку google.api_core.exceptions.ServiceUnavailable: 503 Deadline Exceeded.

def detect_intent_texts(project_id, session_id, texts, language_code):
    """Returns the result of detect intent with texts as inputs.

    Using the same `session_id` between requests allows continuation
    of the conversaion."""
    import dialogflow_v2 as dialogflow
    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('=' * 20)
        print('Query text: {}'.format(response.query_result.query_text))
        print('Detected intent: {} (confidence: {})\n'.format(
            response.query_result.intent.display_name,
            response.query_result.intent_detection_confidence))


print (detect_intent_texts('newagent-38239', '12121211', ['Hi there'], 'en-US'))

У меня есть настройки аутентификации и переменная env GOOGLE_APPLICATION_CREDENTIALS настроить.Как я уже говорил ранее, код работает на консоли или, если я пытаюсь запустить программу, как python main.py.Если я пытаюсь импортировать модуль или запустить его на веб-сервере, он не работает:

...