Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

docs(samples): add Agent Assist code samples #267

Merged
merged 14 commits into from
Mar 25, 2021
Merged

docs(samples): add Agent Assist code samples #267

merged 14 commits into from
Mar 25, 2021

Conversation

rogers140
Copy link
Member

@rogers140 rogers140 commented Mar 22, 2021

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@rogers140 rogers140 requested a review from a team as a code owner March 22, 2021 18:48
@rogers140 rogers140 requested review from engelke and removed request for a team March 22, 2021 18:48
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Mar 22, 2021
@product-auto-label product-auto-label bot added api: dialogflow Issues related to the googleapis/python-dialogflow API. samples Issues that are directly related to samples. labels Mar 22, 2021
@snippet-bot
Copy link

snippet-bot bot commented Mar 22, 2021

Here is the summary of changes.

You are about to add 16 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@rogers140 rogers140 changed the title Add Agent Assist code samples. add Agent Assist code samples. Mar 22, 2021
@rogers140 rogers140 changed the title add Agent Assist code samples. feat(support): add Agent Assist code samples. Mar 22, 2021
@rogers140 rogers140 changed the title feat(support): add Agent Assist code samples. feat(support): add Agent Assist code samples Mar 22, 2021
@engelke engelke added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 22, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 22, 2021
@engelke
Copy link
Contributor

engelke commented Mar 22, 2021

This is a very big PR, well over 1000 lines of new code. It's going to be a while before I can get the time to review it.

@rogers140
Copy link
Member Author

This is a very big PR, well over 1000 lines of new code. It's going to be a while before I can get the time to review it.

Sorry about that. We are actually just migrating private code samples to public for Agent Assist Public Preview Launch. If there is a better way to do this, please let me know.

@engelke engelke added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 23, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 23, 2021
Copy link
Contributor

@engelke engelke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass lint and all tests.
Make sure all functions have tests.
Update copyright dates if anything has been written or first published this year.
Have white space before and after import statements and internally to break code into logical chunks for readability.
Use \n in print statements only when double spacing is needed, and use consistently.

@@ -0,0 +1,144 @@
# Copyright 2019 Google LLC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is newly published, use 2021 for copyright.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -0,0 +1,46 @@
#!/usr/bin/env python

# Copyright 2019 Google LLC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same copyright note

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.



# [START dialogflow_update_answer_record]
def update_anwer_record(project_id, answer_record_id, click):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a typo, or is there a reason not call this update_answer_record?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

def update_anwer_record(project_id, answer_record_id, click):
"""Update the answer record.

Args:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the "click" argument for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments.

project_id: The GCP project linked with the conversation profile.
answer_record_id: The answer record id returned along with the
suggestion."""
from google.cloud import dialogflow_v2 as dialogflow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add leading whitespace

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


Also please contact Google to get credentials of this project and set up the
credential file json locations by running:
export GOOGLE_APPLICATION_CREDENTIALS=<cred_json_file_location>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other environment variables the program expects. If we include these steps (above) we should include them, too.

@@ -0,0 +1,229 @@
# Copyright 2019 Google LLC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a test for this code? I don't see one.

"""

import argparse


# [START dialogflow_list_knowledge_base]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there tests for each method? Where are they?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this function.

print('Reply Text: {}'.format(response.reply_text))

for suggestion_result in response.human_agent_suggestion_results:
if suggestion_result.error is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be is not None, instead of is None. Otherwise the next line will have an exception.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Args:
participant_name: resource name of the participant.
sample_rate_herz: herz rate of the sample.
audio_generator: a sequence of audio data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match the argument list above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@rogers140
Copy link
Member Author

rogers140 commented Mar 23, 2021

Pass lint and all tests.
Make sure all functions have tests.
Update copyright dates if anything has been written or first published this year.
Have white space before and after import statements and internally to break code into logical chunks for readability.
Use \n in print statements only when double spacing is needed, and use consistently.

Fixed the issue you mentioned and better organized the tests. Removed some unnecessary functions and samples.

Ran pytest . under the samples/snippets and all of them passed.

I think I don't know how to update the readme.rst, it seems autogenerated by readme.in but I don't know how it works. Do you know?

@rogers140 rogers140 requested a review from engelke March 24, 2021 22:07
@engelke engelke added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 24, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 24, 2021
@engelke engelke added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 24, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 24, 2021
@engelke engelke assigned engelke and unassigned engelke Mar 25, 2021
@engelke engelke added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 25, 2021
@yoshi-kokoro yoshi-kokoro removed kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Mar 25, 2021
@engelke engelke added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 25, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 25, 2021
@busunkim96 busunkim96 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 25, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 25, 2021
@busunkim96 busunkim96 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 25, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 25, 2021
@busunkim96 busunkim96 changed the title feat(support): add Agent Assist code samples docs(samples): add Agent Assist code samples Mar 25, 2021
@busunkim96 busunkim96 merged commit 0a8cfb9 into googleapis:master Mar 25, 2021
gcf-merge-on-green bot pushed a commit that referenced this pull request Apr 12, 2021
🤖 I have created a release \*beep\* \*boop\*
---
### [2.1.1](https://www.github.com/googleapis/python-dialogflow/compare/v2.1.0...v2.1.1) (2021-04-12)


### Bug Fixes

* remove `input_audio` field from AnalyzeContentRequest from v2/v2beta1 ([06381fc](https://www.github.com/googleapis/python-dialogflow/commit/06381fcc965669e1b3dc8bec22aa567dceb6f935))
* remove proto message CreateCallMatcherRequest, CreateCallMatcherResponse, ListCallMatchersRequest, ListCallMatchersResponse, DeleteCallMatcherRequest, DeleteCallMatcherResponse, CallMatcher, StreamingAnalyzeContentRequest, StreamingAnalyzeContentResponse, AudioInput from v2/v2beta1, TelephonyDtmfEvents, TelephonyDtmf from v2 ([06381fc](https://www.github.com/googleapis/python-dialogflow/commit/06381fcc965669e1b3dc8bec22aa567dceb6f935))
* remove resource_reference for invisible resources ([06381fc](https://www.github.com/googleapis/python-dialogflow/commit/06381fcc965669e1b3dc8bec22aa567dceb6f935))
* Remove resource_reference from UpdateAnswerRecord ([06381fc](https://www.github.com/googleapis/python-dialogflow/commit/06381fcc965669e1b3dc8bec22aa567dceb6f935))
* remove rpc or fields that are unintended to release ([#264](https://www.github.com/googleapis/python-dialogflow/issues/264)) ([06381fc](https://www.github.com/googleapis/python-dialogflow/commit/06381fcc965669e1b3dc8bec22aa567dceb6f935))
* remove StreamingAnalyzeContent, CreateCallMatcher, ListCallMatchers, DeleteCallMatcher rpc from v2/v2beta1 ([06381fc](https://www.github.com/googleapis/python-dialogflow/commit/06381fcc965669e1b3dc8bec22aa567dceb6f935))


### Documentation

* **samples:** add Agent Assist code samples ([#267](https://www.github.com/googleapis/python-dialogflow/issues/267)) ([0a8cfb9](https://www.github.com/googleapis/python-dialogflow/commit/0a8cfb9ac71870df9f69ae518e32a920d08bd170))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: dialogflow Issues related to the googleapis/python-dialogflow API. cla: yes This human has signed the Contributor License Agreement. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants