Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
import pathlib
|
| 4 |
import textwrap
|
| 5 |
-
|
| 6 |
-
try:
|
| 7 |
-
import google.generativeai as genai
|
| 8 |
-
except ImportError:
|
| 9 |
-
print("WARNING: google.generativeai not found. Install with `pip install google-generativeai` for AI-powered responses.")
|
| 10 |
-
genai = None
|
| 11 |
-
|
| 12 |
from IPython.display import display # Only for development/testing
|
| 13 |
from IPython.display import Markdown # Only for development/testing
|
| 14 |
|
|
@@ -37,11 +30,8 @@ def chat(user_message):
|
|
| 37 |
str: The AI-generated response (or a message indicating unavailability).
|
| 38 |
"""
|
| 39 |
|
| 40 |
-
genai.configure(api_key='AIzaSyCMBk81YmILNTok8hd6tYtJaevp1qbl6I0') # Replace with your actual API key
|
| 41 |
-
model = genai.GenerativeModel('gemini-pro')
|
| 42 |
-
|
| 43 |
-
if not genai:
|
| 44 |
-
return "AI responses are currently unavailable. Please install `google-generativeai` for this functionality."
|
| 45 |
|
| 46 |
try:
|
| 47 |
response = model.generate_content(user_message, stream=True)
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import pathlib
|
| 3 |
import textwrap
|
| 4 |
+
import google.generativeai as genai
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
from IPython.display import display # Only for development/testing
|
| 6 |
from IPython.display import Markdown # Only for development/testing
|
| 7 |
|
|
|
|
| 30 |
str: The AI-generated response (or a message indicating unavailability).
|
| 31 |
"""
|
| 32 |
|
| 33 |
+
genai.configure(api_key='AIzaSyCMBk81YmILNTok8hd6tYtJaevp1qbl6I0') # Replace with your actual API key
|
| 34 |
+
model = genai.GenerativeModel('gemini-pro')
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
try:
|
| 37 |
response = model.generate_content(user_message, stream=True)
|