Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,7 +55,7 @@ def chat_with_image(message, image, history):
|
|
| 55 |
# Call the Together AI API
|
| 56 |
try:
|
| 57 |
response = client.chat.completions.create(
|
| 58 |
-
model="meta-llama/Llama-
|
| 59 |
messages=messages,
|
| 60 |
max_tokens=512,
|
| 61 |
temperature=0.7,
|
|
@@ -73,9 +73,19 @@ def chat_with_image(message, image, history):
|
|
| 73 |
full_response += chunk.choices[0].delta.content
|
| 74 |
yield full_response
|
| 75 |
except Exception as e:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
yield f"An error occurred: {str(e)}"
|
| 77 |
|
| 78 |
|
|
|
|
| 79 |
# Create the Gradio interface
|
| 80 |
with gr.Blocks() as demo:
|
| 81 |
chatbot = gr.Chatbot()
|
|
|
|
| 55 |
# Call the Together AI API
|
| 56 |
try:
|
| 57 |
response = client.chat.completions.create(
|
| 58 |
+
model="meta-llama/Llama-Vision-Free",
|
| 59 |
messages=messages,
|
| 60 |
max_tokens=512,
|
| 61 |
temperature=0.7,
|
|
|
|
| 73 |
full_response += chunk.choices[0].delta.content
|
| 74 |
yield full_response
|
| 75 |
except Exception as e:
|
| 76 |
+
# Enhanced error handling
|
| 77 |
+
import traceback
|
| 78 |
+
traceback.print_exc()
|
| 79 |
+
if hasattr(e, 'response') and e.response is not None:
|
| 80 |
+
try:
|
| 81 |
+
error_content = e.response.json()
|
| 82 |
+
print("Error response JSON:", error_content)
|
| 83 |
+
except Exception:
|
| 84 |
+
print("Error response text:", e.response.text)
|
| 85 |
yield f"An error occurred: {str(e)}"
|
| 86 |
|
| 87 |
|
| 88 |
+
|
| 89 |
# Create the Gradio interface
|
| 90 |
with gr.Blocks() as demo:
|
| 91 |
chatbot = gr.Chatbot()
|