diff --git a/Dialogflow-CX/create_agent.py b/Dialogflow-CX/create_agent.py index 8b116812a8be..daff5ff6aef8 100644 --- a/Dialogflow-CX/create_agent.py +++ b/Dialogflow-CX/create_agent.py @@ -35,4 +35,6 @@ def create_agent(project_id, display_name): response = agents_client.create_agent(request={"agent": agent, "parent": parent}) return response + + ## [END dialogflow_cx_create_agent_sample] diff --git a/Dialogflow-CX/detect_intent_stream.py b/Dialogflow-CX/detect_intent_stream.py index ebe715150c00..388246466f27 100644 --- a/Dialogflow-CX/detect_intent_stream.py +++ b/Dialogflow-CX/detect_intent_stream.py @@ -79,17 +79,23 @@ def request_generator(): # Sets the voice name and gender voice_selection.name = "en-GB-Standard-A" - voice_selection.ssml_gender = audio_config.SsmlVoiceGender.SSML_VOICE_GENDER_FEMALE + voice_selection.ssml_gender = ( + audio_config.SsmlVoiceGender.SSML_VOICE_GENDER_FEMALE + ) synthesize_speech_config.voice = voice_selection # Sets the audio encoding - output_audio_config.audio_encoding = audio_config.OutputAudioEncoding.OUTPUT_AUDIO_ENCODING_UNSPECIFIED + output_audio_config.audio_encoding = ( + audio_config.OutputAudioEncoding.OUTPUT_AUDIO_ENCODING_UNSPECIFIED + ) output_audio_config.synthesize_speech_config = synthesize_speech_config # The first request contains the configuration. yield session.StreamingDetectIntentRequest( - session=session_path, query_input=query_input, output_audio_config=output_audio_config + session=session_path, + query_input=query_input, + output_audio_config=output_audio_config, ) # Here we are reading small chunks of audio data from a local diff --git a/Dialogflow-CX/long_running_operation.py b/Dialogflow-CX/long_running_operation.py index 0eb540c80101..7dea25439e9e 100644 --- a/Dialogflow-CX/long_running_operation.py +++ b/Dialogflow-CX/long_running_operation.py @@ -22,18 +22,22 @@ def export_long_running_agent(project_id, agent_id, location): - api_endpoint = f'{location}-dialogflow.googleapis.com:443' + api_endpoint = f"{location}-dialogflow.googleapis.com:443" client_options = {"api_endpoint": api_endpoint} agents_client = AgentsClient(client_options=client_options) export_request = ExportAgentRequest() - export_request.name = f'projects/{project_id}/locations/{location}/agents/{agent_id}' + export_request.name = ( + f"projects/{project_id}/locations/{location}/agents/{agent_id}" + ) # export_agent returns a long running operation operation = agents_client.export_agent(request=export_request) # Returns the result of the operation when the operation is done return operation.result() + + ## [END dialogflow_cx_long_running_snippet] diff --git a/Dialogflow-CX/update_intent.py b/Dialogflow-CX/update_intent.py index 9ba552a48c96..ba7f5588ef9a 100644 --- a/Dialogflow-CX/update_intent.py +++ b/Dialogflow-CX/update_intent.py @@ -28,4 +28,6 @@ def update_intent(project_id, agent_id, intent_id, location, displayName): update_mask = field_mask_pb2.FieldMask(paths=["display_name"]) response = intents_client.update_intent(intent=intent, update_mask=update_mask) return response + + # [END dialogflow_cx_update_intent] diff --git a/Dialogflow-CX/webhook.py b/Dialogflow-CX/webhook.py index 143f11ee91ef..098718470dbe 100644 --- a/Dialogflow-CX/webhook.py +++ b/Dialogflow-CX/webhook.py @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -''' handle_webhook will return the correct fullfilment response dependong the tag that is sent in the request''' +""" handle_webhook will return the correct fullfilment response dependong the tag that is sent in the request""" # [START dialogflow_cx_webhook] @@ -56,4 +56,5 @@ def handle_webhook(request): # Returns json return res + # [END dialogflow_cx_webhook] diff --git a/Dialogflow-CX/webhook_test.py b/Dialogflow-CX/webhook_test.py index dee58ddf3d70..fd91a17bc59c 100644 --- a/Dialogflow-CX/webhook_test.py +++ b/Dialogflow-CX/webhook_test.py @@ -20,12 +20,10 @@ # Create a fake 'app' for generating test request contexts. -request = { - "fulfillmentInfo": {"tag": "Default Welcome Intent"} -} +request = {"fulfillmentInfo": {"tag": "Default Welcome Intent"}} -@pytest.fixture(scope='module') +@pytest.fixture(scope="module") def app(): return flask.Flask(__name__) @@ -33,4 +31,4 @@ def app(): def test_handle_webhook(app): with app.test_request_context(json=request): res = handle_webhook(flask.request) - assert 'Hi from a GCF Webhook' in str(res) + assert "Hi from a GCF Webhook" in str(res)