Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,17 +7,16 @@ GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")
|
|
| 7 |
if not GEMINI_API_KEY:
|
| 8 |
raise ValueError("❌ GEMINI_API_KEY not found. Set it in Hugging Face Secrets.")
|
| 9 |
|
| 10 |
-
# ---
|
| 11 |
-
genai.
|
| 12 |
|
| 13 |
-
# ---
|
| 14 |
-
|
| 15 |
-
chat_session = model.start_chat()
|
| 16 |
|
| 17 |
# --- Define chat function ---
|
| 18 |
def chat_with_gemini(user_input, history):
|
| 19 |
try:
|
| 20 |
-
response =
|
| 21 |
history.append((user_input, response.text))
|
| 22 |
return history, history
|
| 23 |
except Exception as e:
|
|
|
|
| 7 |
if not GEMINI_API_KEY:
|
| 8 |
raise ValueError("❌ GEMINI_API_KEY not found. Set it in Hugging Face Secrets.")
|
| 9 |
|
| 10 |
+
# --- Initialize the client (no configure method!) ---
|
| 11 |
+
client = genai.Client()
|
| 12 |
|
| 13 |
+
# --- Create chat session ---
|
| 14 |
+
chat = client.chats.create(model="gemini-2.5-flash")
|
|
|
|
| 15 |
|
| 16 |
# --- Define chat function ---
|
| 17 |
def chat_with_gemini(user_input, history):
|
| 18 |
try:
|
| 19 |
+
response = chat.send_message(user_input)
|
| 20 |
history.append((user_input, response.text))
|
| 21 |
return history, history
|
| 22 |
except Exception as e:
|