Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,19 +13,9 @@ def chat(message, history, img=None):
|
|
| 13 |
genai.configure(api_key='AIzaSyCMBk81YmILNTok8hd6tYtJaevp1qbl6I0') # Replace with your actual API key
|
| 14 |
|
| 15 |
text_model = genai.GenerativeModel('gemini-pro')
|
| 16 |
-
vision_model = genai.GenerativeModel('gemini-pro-vision')
|
| 17 |
|
| 18 |
try:
|
| 19 |
-
if img is not None:
|
| 20 |
-
# Process image with vision model
|
| 21 |
-
image_response = vision_model.generate_content(img)
|
| 22 |
-
image_response.resolve() # Wait for response completion
|
| 23 |
-
image_text = to_markdown(image_response.text)
|
| 24 |
-
|
| 25 |
-
# Combine image and text for unified response
|
| 26 |
-
prompt = f"{message}\n{image_text}"
|
| 27 |
-
response = text_model.generate_content(prompt, stream=True)
|
| 28 |
-
else:
|
| 29 |
# Use only text model
|
| 30 |
response = text_model.generate_content(message, stream=True)
|
| 31 |
|
|
@@ -40,8 +30,7 @@ chat_interface = gr.ChatInterface(
|
|
| 40 |
fn=chat,
|
| 41 |
title="Gemini Chat",
|
| 42 |
description="Chat with an AI assistant powered by Gemini",
|
| 43 |
-
theme="soft"
|
| 44 |
-
inputs=[gr.Textbox(lines=1, label="Enter your message"), gr.Image()],
|
| 45 |
)
|
| 46 |
|
| 47 |
chat_interface.launch()
|
|
|
|
| 13 |
genai.configure(api_key='AIzaSyCMBk81YmILNTok8hd6tYtJaevp1qbl6I0') # Replace with your actual API key
|
| 14 |
|
| 15 |
text_model = genai.GenerativeModel('gemini-pro')
|
| 16 |
+
#vision_model = genai.GenerativeModel('gemini-pro-vision')
|
| 17 |
|
| 18 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Use only text model
|
| 20 |
response = text_model.generate_content(message, stream=True)
|
| 21 |
|
|
|
|
| 30 |
fn=chat,
|
| 31 |
title="Gemini Chat",
|
| 32 |
description="Chat with an AI assistant powered by Gemini",
|
| 33 |
+
theme="soft"
|
|
|
|
| 34 |
)
|
| 35 |
|
| 36 |
chat_interface.launch()
|