Update app.py
Browse files
app.py
CHANGED
|
@@ -2,10 +2,13 @@ import gradio as gr
|
|
| 2 |
import google.generativeai as genai
|
| 3 |
import os
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
# π Configure API
|
| 6 |
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
|
| 7 |
|
| 8 |
-
# π€ Model
|
| 9 |
model = genai.GenerativeModel("gemini-1.5-flash")
|
| 10 |
|
| 11 |
def chat(message, history):
|
|
@@ -22,15 +25,16 @@ def chat(message, history):
|
|
| 22 |
return history, history
|
| 23 |
|
| 24 |
except Exception as e:
|
| 25 |
-
|
| 26 |
-
|
|
|
|
| 27 |
return history, history
|
| 28 |
|
| 29 |
-
|
| 30 |
demo = gr.ChatInterface(
|
| 31 |
fn=chat,
|
| 32 |
title="Jarvis AI π€",
|
| 33 |
description="Internal AI Assistant"
|
| 34 |
)
|
| 35 |
|
| 36 |
-
demo.launch()
|
|
|
|
| 2 |
import google.generativeai as genai
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
# π DEBUG (important)
|
| 6 |
+
print("API KEY:", os.getenv("GEMINI_API_KEY"))
|
| 7 |
+
|
| 8 |
# π Configure API
|
| 9 |
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
|
| 10 |
|
| 11 |
+
# π€ Model (stable one)
|
| 12 |
model = genai.GenerativeModel("gemini-1.5-flash")
|
| 13 |
|
| 14 |
def chat(message, history):
|
|
|
|
| 25 |
return history, history
|
| 26 |
|
| 27 |
except Exception as e:
|
| 28 |
+
error_msg = f"π₯ ERROR: {str(e)}"
|
| 29 |
+
print(error_msg)
|
| 30 |
+
history.append((message, error_msg))
|
| 31 |
return history, history
|
| 32 |
|
| 33 |
+
|
| 34 |
demo = gr.ChatInterface(
|
| 35 |
fn=chat,
|
| 36 |
title="Jarvis AI π€",
|
| 37 |
description="Internal AI Assistant"
|
| 38 |
)
|
| 39 |
|
| 40 |
+
demo.launch()
|