Spaces:
Sleeping
Sleeping
Download llm_setup.py from abhinav0231/SparrowTale: direct link, hf CLI and curl.
- Browser
- Download file 561 Bytes
-
https://huggingface.co/spaces/abhinav0231/SparrowTale/resolve/main/llm_setup.py
- Command line
-
hf download hf://spaces/abhinav0231/SparrowTale/llm_setup.py
-
curl -L -o llm_setup.py https://huggingface.co/spaces/abhinav0231/SparrowTale/resolve/main/llm_setup.py
561 Bytes
| import os | |
| import streamlit as st | |
| from langchain_google_genai import ChatGoogleGenerativeAI | |
| api_key = st.secrets.get("GEMINI_API_KEY", os.getenv("GEMINI_API_KEY")) | |
| if not api_key: | |
| st.error("⚠️ GEMINI_API_KEY not found. Please add it in the Secrets tab.") | |
| st.stop() | |
| try: | |
| llm = ChatGoogleGenerativeAI( | |
| model="gemma-3-12b-it", | |
| temperature=1, | |
| google_api_key=api_key | |
| ) | |
| print("✅ LLM initialized successfully") | |
| except Exception as e: | |
| st.error(f"Error initializing the LLM: {e}") | |
| llm = None | |
| embeddings = None |