Skip to content

Commit

Permalink
chore: use gapic-generator-python 0.63.1 (#245)
Browse files Browse the repository at this point in the history
- [x] Regenerate this pull request now.

docs: add autogenerated code snippets
PiperOrigin-RevId: 426256923

Source-Link: googleapis/googleapis@9ebabfa

Source-Link: https://github.com/googleapis/googleapis-gen/commit/a88175263e60a1d45d3a447848652b0f670b2cb8
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTg4MTc1MjYzZTYwYTFkNDVkM2E0NDc4NDg2NTJiMGY2NzBiMmNiOCJ9

Fixes #229
  • Loading branch information
gcf-owl-bot[bot] authored Feb 5, 2022
1 parent 9d3154f commit d5147b8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Dialogflow-CX/create_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
12 changes: 9 additions & 3 deletions Dialogflow-CX/detect_intent_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions Dialogflow-CX/long_running_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
2 changes: 2 additions & 0 deletions Dialogflow-CX/update_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
3 changes: 2 additions & 1 deletion Dialogflow-CX/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -56,4 +56,5 @@ def handle_webhook(request):
# Returns json
return res


# [END dialogflow_cx_webhook]
8 changes: 3 additions & 5 deletions Dialogflow-CX/webhook_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@

# 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__)


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)

0 comments on commit d5147b8

Please sign in to comment.