-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(genaisdk): update samples nested objects for better readability #5318
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.
Hello @CadillacBurgess1, 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!
Summary of Changes
This pull request focuses on improving the readability of the content cache samples in the genaisdk
by adjusting the structure of nested objects within the code. Specifically, the changes involve reformatting the cacheContents
and SystemInstruction
configurations in contentcache_create_with_txt_gcs_pdf.go
to enhance clarity. Additionally, a minor update was made to the license URL in contentcache_delete.go
.
Highlights
- Code Readability: The primary focus is to enhance the readability of the code by restructuring nested objects, particularly within the
createContentCache
function. - Configuration Changes: The
cacheContents
andSystemInstruction
configurations incontentcache_create_with_txt_gcs_pdf.go
have been modified to improve clarity. - License URL Update: A minor update was made to the license URL in
contentcache_delete.go
to ensure it points to the correct location.
Changelog
- genai/content_cache/contentcache_create_with_txt_gcs_pdf.go
- Reformatted the
cacheContents
array to improve readability by explicitly labeling eachFileData
part. - Restructured the
CreateCachedContentConfig
to enhance clarity, specifically forContents
andSystemInstruction
. - Added comments to delineate parts within the
cacheContents
array for better understanding.
- Reformatted the
- genai/content_cache/contentcache_delete.go
- Updated the license URL from
https://www.apache.org/licenses/LICENSE-2.0
tohttps://www.apache.org/licenses/LICENSE-2.0
.
- Updated the license URL from
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 is currently in preview and 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 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.
In code's deep forest, clarity's the guide,
Where nested forms can often hide.
A touch of grace,
A structured space,
For minds to wander, side by side.
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
The pull request updates the samples for nested objects, aiming for better readability. The changes primarily involve reformatting the structure of the cacheContents
in contentcache_create_with_txt_gcs_pdf.go
to improve clarity. Overall, the changes seem reasonable and contribute to better code organization.
Summary of Findings
- MIME Type Consistency: The MIME type string literal should be defined as a constant to avoid duplication and potential typos. This applies to both
contentcache_create_with_txt_gcs_pdf.go
and other files where MIME types are used. - Code Comment Style: The code comments
Part 1
andPart 2
are useful, but consider standardizing the comment style across the codebase for consistency. - HTTP Option Struct Initialization: The initialization of the
HTTPOptions
struct can be simplified by directly assigning theAPIVersion
field during struct creation.
Merge Readiness
The pull request is in good shape and improves the readability of the code. However, addressing the comments regarding MIME type consistency and HTTP option struct initialization would further enhance the quality of the code. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity issues should be addressed before merging.
{ // Part 1 | ||
FileData: &genai.FileData{ | ||
FileURI: "gs://cloud-samples-data/generative-ai/pdf/2312.11805v3.pdf", | ||
MIMEType: "application/pdf", | ||
}, |
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.
Consider defining application/pdf
as a constant to avoid duplication and potential typos. This could be defined at the package level, e.g., const pdfMIMEType = "application/pdf"
.
FileData: &genai.FileData{
FileURI: "gs://cloud-samples-data/generative-ai/pdf/2312.11805v3.pdf",
MIMEType: pdfMIMEType, // Use the constant here
},
{ // Part 2 | ||
FileData: &genai.FileData{ | ||
FileURI: "gs://cloud-samples-data/generative-ai/pdf/2403.05530.pdf", | ||
MIMEType: "application/pdf", | ||
}, |
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.
Consider defining application/pdf
as a constant to avoid duplication and potential typos. This could be defined at the package level, e.g., const pdfMIMEType = "application/pdf"
.
FileData: &genai.FileData{
FileURI: "gs://cloud-samples-data/generative-ai/pdf/2403.05530.pdf",
MIMEType: pdfMIMEType, // Use the constant here
},
HTTPOptions: genai.HTTPOptions{ | ||
APIVersion: "v1", | ||
}, |
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.
HTTPOptions: genai.HTTPOptions{ | ||
APIVersion: "v1", | ||
}, |
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.
…removing local testing comments
…update and use_with_text script
Hey @CadillacBurgess1 -- If you're still working on this PR, let's switch it to a draft. Thanks! |
Description
Fixes #
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
go test -v ./..
(see Testing)gofmt
(see Formatting)go vet
(see Formatting)