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

Fix google-generativeai import related issues #700

Closed
wants to merge 2 commits into from

Conversation

ssonal
Copy link
Contributor

@ssonal ssonal commented May 24, 2024

Update pyproject settings and package imports to prevent ModuleNotFound errors introduced in #684


🚀 This description was created by Ellipsis for commit c719247

Summary:

This PR fixes import issues related to 'google-generativeai' by updating import conditions and dependencies.

Key points:

  • Updated conditional import in instructor/__init__.py to check for 'google' module before importing 'from_gemini'.
  • Imported HarmCategory and HarmBlockThreshold from 'google.generativeai.types' in instructor/process_response.py for handling safety settings.
  • Added 'google-generativeai' to 'test-docs' dependencies in pyproject.toml.

Generated with ❤️ by ellipsis.dev

Update pyproject settings and package imports to prevent ModuleNotFound errors
@ssonal ssonal marked this pull request as ready for review May 24, 2024 03:45
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 c719247 in 1 minute and 52 seconds

More details
  • Looked at 53 lines of code in 3 files
  • Skipped 1 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. pyproject.toml:41
  • Draft comment:
    The addition of google-generativeai to the test-docs group in pyproject.toml is appropriate to ensure the package is available in testing environments, aligning with the PR's intent to fix import issues.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The PR description mentions updating pyproject settings and package imports to prevent ModuleNotFound errors. The changes in the pyproject.toml file include adding the google-generativeai package to the test-docs group, which is a necessary update to ensure that the package is available for testing environments where it might be needed. This change aligns with the PR's intent to fix import issues and seems correctly implemented.

Workflow ID: wflow_TAxW5lj3PzdO2Rir


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.

instructor/__init__.py Outdated Show resolved Hide resolved
@@ -387,6 +387,8 @@ def handle_response_model(
) | {"response_mime_type": "application/json"}

# minimize gemini safety related errors - model is highly prone to false alarms
from google.generativeai.types import HarmCategory, HarmBlockThreshold
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider moving the import statement for HarmCategory and HarmBlockThreshold to the top of the file to avoid performance penalties from importing inside a function:

Suggested change
from google.generativeai.types import HarmCategory, HarmBlockThreshold
from google.generativeai.types import HarmCategory, HarmBlockThreshold

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
@jxnl jxnl closed this May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants