Skip to content
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: Add Gemini PDF example #1163

Merged
merged 6 commits into from
Nov 12, 2024
Merged

feat: Add Gemini PDF example #1163

merged 6 commits into from
Nov 12, 2024

Conversation

ivanleomk
Copy link
Collaborator

@ivanleomk ivanleomk commented Nov 11, 2024

Important

Adds a blog post on using Google's Gemini model with Instructor for efficient PDF processing, including setup and benefits.

  • New Blog Post:
    • Adds chat-with-your-pdf-with-gemini.md to docs/blog/posts/.
    • Describes using Google's Gemini model with Instructor for PDF processing.
    • Includes code example for setting up and processing PDFs.
  • Content Highlights:
    • Discusses drawbacks of traditional PDF processing methods.
    • Explains benefits of using Gemini and Instructor, such as simple integration and structured output.
    • Mentions multimodal support for processing various file types.

This description was created by Ellipsis for a7ec92f. It will automatically update as commits are pushed.

@ivanleomk ivanleomk changed the title feat: fixed up an example for working with pdf feat: Add Gemini PDF example Nov 11, 2024
@github-actions github-actions bot added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 11, 2024
Copy link

cloudflare-workers-and-pages bot commented Nov 11, 2024

Deploying instructor-py with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6a331dd
Status:⚡️  Build in progress...

View logs

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 8a39ada in 1 minute and 12 seconds

More details
  • Looked at 101 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. docs/blog/posts/chat-with-your-pdf-with-gemini.md:95
  • Draft comment:
    Ensure this new markdown file is added to mkdocs.yml for proper documentation inclusion.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_QxHSjkQWNMDqoMSw


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

file = genai.upload_file("path/to/your.pdf") # [Download sample PDF](sample.pdf)
resp = client.chat.completions.create(
messages=[
{"role": "user", "content": ["Summarize the following file", file]},
Copy link
Contributor

Choose a reason for hiding this comment

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

The content key in the message dictionary should be a string, not a list. Change "content": ["Summarize the following file", file] to "content": "Summarize the following file: " + file.

Suggested change
{"role": "user", "content": ["Summarize the following file", file]},
{"role": "user", "content": "Summarize the following file: " + file},

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on 7f48323 in 57 seconds

More details
  • Looked at 33 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. docs/blog/posts/chat-with-your-pdf-with-gemini.md:42
  • Draft comment:
    Make sure to add this new markdown file to the mkdocs.yml to ensure it is included in the documentation.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_v2DjqduThRmdBNYD


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

file = genai.upload_file("path/to/your.pdf")

# Wait for file to finish processing
while file.state != File.State.ACTIVE:
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing import for time module. Add import time at the beginning of the code.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 0ba2ab0 in 19 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. docs/blog/posts/chat-with-your-pdf-with-gemini.md:18
  • Draft comment:
    Add import time to avoid NameError in the while loop.
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. docs/blog/posts/chat-with-your-pdf-with-gemini.md:18
  • Draft comment:
    Make sure to add this new markdown file to the mkdocs.yml to ensure it appears in the documentation navigation.
  • Reason this comment was not posted:
    Confidence changes required: 80%
    The new markdown file should be added to the mkdocs.yml for proper documentation navigation.

Workflow ID: wflow_mDq2v3t4FrFFxDqZ


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 8b571a5 in 20 seconds

More details
  • Looked at 14 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. docs/blog/posts/chat-with-your-pdf-with-gemini.md:51
  • Draft comment:
    Missing import for the time module, which is used in the while loop. Add import time to avoid runtime errors.
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. docs/blog/posts/chat-with-your-pdf-with-gemini.md:51
  • Draft comment:
    Make sure to add this new markdown file to the mkdocs.yml to ensure it appears in the documentation navigation.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_gxQYx5PytUcthHaN


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on a7ec92f in 19 seconds

More details
  • Looked at 12 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. docs/blog/posts/chat-with-your-pdf-with-gemini.md:49
  • Draft comment:
    Consider adding a timeout to the while loop using the time module to prevent potential infinite loops if the file state never becomes ACTIVE.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The import of time is necessary for the sleep function used in the while loop. However, the while loop could benefit from a timeout to prevent infinite loops.
2. docs/blog/posts/chat-with-your-pdf-with-gemini.md:46
  • Draft comment:
    Ensure this new markdown file is added to the mkdocs.yml to be included in the documentation navigation.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_A13i5lDFntQjOWEd


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@jxnl jxnl merged commit 595bfa7 into main Nov 12, 2024
13 of 15 checks passed
@jxnl jxnl deleted the gemini-pdf branch November 12, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants