-
Notifications
You must be signed in to change notification settings - Fork 6.6k
feat(discoveryengine): Add user pseudo id to answer query sample #13514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @holtskinner, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a minor but significant enhancement to the existing answer_query_sample.py
script. The primary goal is to demonstrate how to include a user_pseudo_id
when making an answer query, which is useful for tracking or personalization, aligning the sample with broader documentation for the Discovery Engine's answer functionality.
Highlights
- Sample Code Enhancement: The
answer_query_sample
function call indiscoveryengine/answer_query_sample.py
has been updated to include an optionaluser_pseudo_id
parameter.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds the user_pseudo_id
parameter to the answer_query
sample. The hardcoded value could be improved to better guide developers on its intended use. I've provided a suggestion to use a more descriptive placeholder and a more informative comment to encourage the use of unique identifiers, which is the best practice for this field.
@@ -85,6 +85,7 @@ def answer_query_sample( | |||
session=None, # Optional: include previous session ID to continue a conversation | |||
query_understanding_spec=query_understanding_spec, | |||
answer_generation_spec=answer_generation_spec, | |||
user_pseudo_id="user-pseudo-id", # Optional: Add user pseudo-identifier for queries. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user_pseudo_id
field is intended to be a unique identifier for each end-user to enable analytics and personalization. Using a static, hardcoded string like "user-pseudo-id"
in a sample is misleading because developers might copy this non-unique value, which would defeat the purpose of the field.
To align with best practices, I recommend using a more descriptive placeholder and an improved comment to guide users towards providing a unique value, such as a UUID.
user_pseudo_id="user-pseudo-id", # Optional: Add user pseudo-identifier for queries. | |
user_pseudo_id="a-unique-user-id", # Optional: A unique identifier for the end user. We recommend using a randomly generated UUID. |
@@ -15,17 +15,20 @@ | |||
|
|||
import os | |||
|
|||
from discoveryengine import import_documents_sample |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the changes you added to this file are related to the original file's linting errors.
At a guess you ran black on the entire folder, and black doesn't abide by google's import sorting (through flake8-import-order
).
project_id = os.environ["GOOGLE_CLOUD_PROJECT"] | ||
location = "global" | ||
data_store_id = "test-structured-data-engine" | ||
|
||
|
||
@pytest.mark.skip(reason="Table deleted.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is unrelated to the description of this PR. If you need to make this change, please create a separate PR and a related issue/bug if this is a temporary issue that needs to be tracked.
Description
For documentation https://cloud.google.com/generative-ai-app-builder/docs/answer#search-answer-basic-python