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

Issue with Gemini on Vertex AI #1166

Closed
6 tasks
sandeep540 opened this issue Nov 11, 2024 · 5 comments
Closed
6 tasks

Issue with Gemini on Vertex AI #1166

sandeep540 opened this issue Nov 11, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@sandeep540
Copy link

  • [ x] This is actually a bug report.
  • I am not getting good LLM Results
  • I have tried asking for help in the community on discord or discussions and have not received a response.
  • I have tried searching the documentation and have not found an answer.

What Model are you using?

  • gpt-3.5-turbo
  • gpt-4-turbo
  • gpt-4
  • [x ] Other (gemini-1.5-pro-002 on vertex ai)

Describe the bug
When executing this example - https://python.useinstructor.com/hub/vertexai/#vertex-ai-client , I am getting
ModuleNotFoundError: No module named 'instructor.client_vertexai'; 'instructor' is not a package
StackTrace
Traceback (most recent call last): File "c:\Users\A0100109\python\gemini-bq-py-test\instructor.py", line 1, in <module> import instructor.client_vertexai as instructor File "c:\Users\A0100109\python\gemini-bq-py-test\instructor.py", line 1, in <module> import instructor.client_vertexai as instructor ModuleNotFoundError: No module named 'instructor.client_vertexai'; 'instructor' is not a package

To Reproduce
Here is Code I used

import instructor

from pydantic import BaseModel
import vertexai.generative_models as GenerativeModel
import vertexai

vertexai.init(project="XXXX", location="us-central1")
client = GenerativeModel.GenerativeModel("gemini-1.5-pro-002")
client = instructor.from_vertexai(client)


class UserDetails(BaseModel):
    name: str
    age: int

resp = client.create(
    response_model=UserDetails,
    messages=[
        {
            "role": "user",
            "content": f'Extract the following entities: "Jason is 20"',
        },
    ],
)
print(resp)

**REQUIREMENTS.TXT

google-cloud-aiplatform==1.71.1
pydantic==2.9.2
instructor==1.6.3
jsonref==1.1.0

Expected behavior
Error should not appear

Screenshots
If applicable, add screenshots to help explain your problem.

@github-actions github-actions bot added the bug Something isn't working label Nov 11, 2024
@ivanleomk
Copy link
Collaborator

ivanleomk commented Nov 12, 2024

Could you try re-installing instructor.

@sandeep540
Copy link
Author

Tried, Different error

$ c:/Users/A0100109/python/gemini-bq-py-test/.venv/Scripts/python.exe c:/Users/A0100109/python/gemini-bq-py-test/instructor.py
Traceback (most recent call last):
  File "c:\Users\A0100109\python\gemini-bq-py-test\instructor.py", line 1, in <module>
    import instructor
  File "c:\Users\A0100109\python\gemini-bq-py-test\instructor.py", line 12, in <module>
    client = instructor.from_vertexai(client)
             ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: partially initialized module 'instructor' has no attribute 'from_vertexai' (most likely due to a circular import)
(.venv) 

@ivanleomk
Copy link
Collaborator

Tried, Different error

$ c:/Users/A0100109/python/gemini-bq-py-test/.venv/Scripts/python.exe c:/Users/A0100109/python/gemini-bq-py-test/instructor.py
Traceback (most recent call last):
  File "c:\Users\A0100109\python\gemini-bq-py-test\instructor.py", line 1, in <module>
    import instructor
  File "c:\Users\A0100109\python\gemini-bq-py-test\instructor.py", line 12, in <module>
    client = instructor.from_vertexai(client)
             ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: partially initialized module 'instructor' has no attribute 'from_vertexai' (most likely due to a circular import)
(.venv) 

Could you try renaming your script to another name? It seems like you're running it from a script called instructor.py

@sandeep540
Copy link
Author

Worked @ivanleomk , Kind of mistake from my side having same name as package for file

Screenshot 2024-11-12 at 4 00 39 PM

@ivanleomk
Copy link
Collaborator

Awesome glad to hear that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants