Skip to content

Added the requirement for environment variables to the README #1708

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ryuichi1208
Copy link

@ryuichi1208 ryuichi1208 commented May 13, 2025

When I run the sample, I get the following error. Added the requirement for the GEMINI_API_KEY environment variable to the README.

Traceback (most recent call last):
  File "/Users/ryuichi/ghq/github.com/ryuichi1208/homecmd/tmp/stt/client/tools/sort.py", line 4, in <module>
    agent = Agent(
            ^^^^^^
  File "/Users/ryuichi/ghq/github.com/ryuichi1208/homecmd/tmp/stt/client/tools/.venv/lib/python3.12/site-packages/pydantic_ai/agent.py", line 274, in __init__
    self.model = models.infer_model(model)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ryuichi/ghq/github.com/ryuichi1208/homecmd/tmp/stt/client/tools/.venv/lib/python3.12/site-packages/pydantic_ai/models/__init__.py", line 464, in infer_model
    return GeminiModel(model_name, provider=provider)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ryuichi/ghq/github.com/ryuichi1208/homecmd/tmp/stt/client/tools/.venv/lib/python3.12/site-packages/pydantic_ai/models/gemini.py", line 133, in __init__
    provider = infer_provider(provider)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ryuichi/ghq/github.com/ryuichi1208/homecmd/tmp/stt/client/tools/.venv/lib/python3.12/site-packages/pydantic_ai/providers/__init__.py", line 66, in infer_provider
    return GoogleGLAProvider()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/ryuichi/ghq/github.com/ryuichi1208/homecmd/tmp/stt/client/tools/.venv/lib/python3.12/site-packages/pydantic_ai/providers/google_gla.py", line 37, in __init__
    raise UserError(
pydantic_ai.exceptions.UserError: Set the `GEMINI_API_KEY` environment variable or pass it via `GoogleGLAProvider(api_key=...)`to use the Google GLA provider.

Copy link
Contributor

hyperlint-ai bot commented May 13, 2025

PR Change Summary

Added requirement for the GEMINI_API_KEY environment variable to ensure proper functioning of the agent.

  • Introduced a check for the GEMINI_API_KEY environment variable in the README example.
  • Raised a ValueError if the GEMINI_API_KEY is not set before running the agent.

Modified Files

  • README.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

@ryuichi1208 ryuichi1208 changed the title Added the requirement for the GEMINI_API_KEY environment variable to … Added the requirement for environment variables to the README May 13, 2025
@samuelcolvin
Copy link
Member

happy to have a comment in the readme saying "you need to set XXX", but I don't think we should change the code like this.

@ryuichi1208
Copy link
Author

Okay, I'll just comment the code and not modify it.

@Kludex
Copy link
Member

Kludex commented May 15, 2025

I think we need to either:

  1. Point the users to this page: https://ai.google.dev/gemini-api/docs/api-key
  2. Use an OpenAI model instead (just because it's more popular)

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.

3 participants