Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,19 @@
|
|
| 1 |
-
import os
|
| 2 |
import gradio as gr
|
| 3 |
import google.generativeai as genai
|
|
|
|
| 4 |
from dotenv import load_dotenv
|
| 5 |
|
| 6 |
-
#
|
| 7 |
load_dotenv()
|
| 8 |
-
api_key = os.getenv("AIzaSyB1l7od1mPJ3CdN1AVF509xtHx1unYqnww")
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
| 11 |
raise ValueError("❌ GEMINI_API_KEY not found. Please set it in your .env or Hugging Face secrets.")
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
genai.configure(api_key=
|
| 15 |
MODEL_ID = "gemini-1.5-pro" # or gemini-1.5-flash for faster inference
|
| 16 |
|
| 17 |
# ---------------- AI Response Function ----------------
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import google.generativeai as genai
|
| 3 |
+
import os
|
| 4 |
from dotenv import load_dotenv
|
| 5 |
|
| 6 |
+
# ✅ Load environment variables (for local .env use)
|
| 7 |
load_dotenv()
|
|
|
|
| 8 |
|
| 9 |
+
# ✅ Fetch Gemini API Key (works for both local + Hugging Face + Render)
|
| 10 |
+
GEMINI_API_KEY = os.getenv("AIzaSyB1l7od1mPJ3CdN1AVF509xtHx1unYqnww")
|
| 11 |
+
|
| 12 |
+
if not GEMINI_API_KEY:
|
| 13 |
raise ValueError("❌ GEMINI_API_KEY not found. Please set it in your .env or Hugging Face secrets.")
|
| 14 |
|
| 15 |
+
# 🔹 Configure Gemini client
|
| 16 |
+
genai.configure(api_key=GEMINI_API_KEY)
|
| 17 |
MODEL_ID = "gemini-1.5-pro" # or gemini-1.5-flash for faster inference
|
| 18 |
|
| 19 |
# ---------------- AI Response Function ----------------
|