Spaces:
Sleeping
Sleeping
Download src/utils/core.py from utkarsh134/FastAPI-HackathonIn2Mins: direct link, hf CLI and curl.
- Browser
- Download file 558 Bytes
-
https://huggingface.co/spaces/utkarsh134/FastAPI-HackathonIn2Mins/resolve/main/src/utils/core.py
- Command line
-
hf download hf://spaces/utkarsh134/FastAPI-HackathonIn2Mins/src/utils/core.py
-
curl -L -o core.py https://huggingface.co/spaces/utkarsh134/FastAPI-HackathonIn2Mins/resolve/main/src/utils/core.py
558 Bytes
| import os | |
| from langchain_google_genai import ChatGoogleGenerativeAI | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| def get_llm(): | |
| """Create and return a ChatGoogleGenerativeAI instance with proper authentication.""" | |
| google_api_key = os.getenv("GOOGLE_API_KEY") | |
| if not google_api_key: | |
| raise ValueError("GOOGLE_API_KEY environment variable is not set") | |
| return ChatGoogleGenerativeAI( | |
| model="gemini-2.0-flash", | |
| temperature=0, | |
| google_api_key=google_api_key | |
| ) | |
| # Global LLM instance for reuse | |
| llm = get_llm() |