-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat(vertexai): pdf input #4112
Conversation
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
vertexai/multimodal-pdf/pdf.go
Outdated
|
||
res, err := model.GenerateContent(ctx, part, genai.Text(prompt)) | ||
if err != nil { | ||
return fmt.Errorf("unable to generate contents: %v", err) |
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.
blocking: This and other fmt.Errorf instances, please wrap errors with %w.
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.
Awesome! I wasn't very familiar with %w
, now I see it makes perfect sense
vertexai/multimodal-pdf/pdf.go
Outdated
// generateContentFromPDF generates a response into w, based upon the prompt | ||
// and the pdf file provided. | ||
// pdf is a Google Cloud Storage path starting with "gs://" | ||
func generateContentFromPDF(w io.Writer, prompt, pdf, projectID, location, modelName string) error { |
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.
suggestion: Follow the decision made as part of #4110 (review)
vertexai/multimodal-pdf/pdf.go
Outdated
// generateContentFromPDF generates a response into w, based upon the prompt | ||
// and the pdf file provided. | ||
// pdf is a Google Cloud Storage path starting with "gs://" |
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.
suggestion: Similar to #4113 (comment), suggest making the purpose of the code vs. what it does a little more clear.
Secondarily, my preference is to make the top-line comment independent of reading the function signature, so I would use "provided io.Writer" over specifying the variable name w
.
vertexai/multimodal-pdf/pdf_test.go
Outdated
buf := new(bytes.Buffer) | ||
prompt := ` | ||
Your are a very professional document summarization specialist. |
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.
suggestion:
buf := new(bytes.Buffer) | |
prompt := ` | |
Your are a very professional document summarization specialist. | |
buf := new(bytes.Buffer) | |
prompt := ` | |
You are a very professional document summarization specialist. |
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.
Good catch, thank you
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.
Also fixing upstream in Python: GoogleCloudPlatform/python-docs-samples#11592
kokoro failing with |
Go version of the Python sample at https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/generative_ai/gemini_pdf_example.py
Region tag
generativeaionvertexai_gemini_pdf