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

How can i set the gemini api key? #170

Open
cczw2010 opened this issue Feb 2, 2024 · 2 comments · May be fixed by #207
Open

How can i set the gemini api key? #170

cczw2010 opened this issue Feb 2, 2024 · 2 comments · May be fixed by #207

Comments

@cczw2010
Copy link

cczw2010 commented Feb 2, 2024

No description provided.

@fejdraus
Copy link

fejdraus commented Feb 8, 2024

This is not Gemini chat, it is google-vertexai, therefore there is no key. For real Gemini need to use in project google-genai, the key will be used there

@lienchen0526
Copy link

lienchen0526 commented Feb 27, 2024

As @fejdraus mentioned, it currently support google-vertexai. However, if you have an API key came from Google AI Studio, I think the workaround may work for you. Because it works on me:

  • (Step 1) Add a line langchain-google-genai = "0.0.9" to [tool.poetry.dependencies] section in backend/app/pyproject.toml.
  • (Step 2) Add a line GOOGLE_API_KEY=<your-api-key> to .env file, where the value of <your-api-key> is the api key generated on Google AI Studio
  • (Step 3) Add a line from langchain_google_genai import ChatGoogleGenerativeAI at the head of python file backend/app/api/llms.py.
  • (Step 4) In python file backend/app/api/llms.py, modify function def get_google_llm(): to be like:
@lru_cache(maxsize=1)
def get_google_llm():
    return ChatGoogleGenerativeAI(
        model="gemini-pro", convert_system_message_to_human=True
    )
  • (Step 5) Run docker-compose build.
  • (Step 6) Run docker-compose up, you should be able to run Gemini by the api key generated by the Google AI Studio.

@lienchen0526 lienchen0526 linked a pull request Feb 29, 2024 that will close this issue
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 a pull request may close this issue.

3 participants