Update app.py
Browse files
app.py
CHANGED
|
@@ -2,23 +2,20 @@ import gradio as gr
|
|
| 2 |
from google import genai
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
# API KEY
|
| 6 |
API_KEY = os.getenv("GOOGLE_API_KEY")
|
| 7 |
|
| 8 |
if not API_KEY:
|
| 9 |
raise Exception("❌ API key missing")
|
| 10 |
|
| 11 |
-
# New client (IMPORTANT)
|
| 12 |
client = genai.Client(api_key=API_KEY)
|
| 13 |
|
| 14 |
def chat(message, history):
|
| 15 |
try:
|
| 16 |
response = client.models.generate_content(
|
| 17 |
-
model="gemini-1.5-flash",
|
| 18 |
contents=message
|
| 19 |
)
|
| 20 |
return response.text
|
| 21 |
-
|
| 22 |
except Exception as e:
|
| 23 |
return f"❌ Error: {str(e)}"
|
| 24 |
|
|
|
|
| 2 |
from google import genai
|
| 3 |
import os
|
| 4 |
|
|
|
|
| 5 |
API_KEY = os.getenv("GOOGLE_API_KEY")
|
| 6 |
|
| 7 |
if not API_KEY:
|
| 8 |
raise Exception("❌ API key missing")
|
| 9 |
|
|
|
|
| 10 |
client = genai.Client(api_key=API_KEY)
|
| 11 |
|
| 12 |
def chat(message, history):
|
| 13 |
try:
|
| 14 |
response = client.models.generate_content(
|
| 15 |
+
model="gemini-1.5-flash-latest", # 🔥 FIXED
|
| 16 |
contents=message
|
| 17 |
)
|
| 18 |
return response.text
|
|
|
|
| 19 |
except Exception as e:
|
| 20 |
return f"❌ Error: {str(e)}"
|
| 21 |
|