Update app.py
Browse files
app.py
CHANGED
|
@@ -6,16 +6,13 @@ model = gr.load(
|
|
| 6 |
provider="featherless-ai",
|
| 7 |
)
|
| 8 |
|
| 9 |
-
# Function to chat with error handling
|
| 10 |
def chat_with_model(prompt):
|
| 11 |
try:
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
response = model(
|
| 15 |
-
#
|
| 16 |
-
return response[0]["content"]
|
| 17 |
except Exception as e:
|
| 18 |
-
# Return a friendly error message
|
| 19 |
return f"⚠️ Error: {str(e)}"
|
| 20 |
|
| 21 |
# Gradio interface
|
|
@@ -24,7 +21,7 @@ with gr.Blocks(title="Dolphin Mistral Chatbot") as demo:
|
|
| 24 |
|
| 25 |
with gr.Row():
|
| 26 |
with gr.Column(scale=3):
|
| 27 |
-
user_input = gr.Textbox(label="Your Message", placeholder="Type 'hi'
|
| 28 |
submit_btn = gr.Button("Send")
|
| 29 |
with gr.Column(scale=2):
|
| 30 |
output_box = gr.Textbox(label="AI Response", lines=10)
|
|
|
|
| 6 |
provider="featherless-ai",
|
| 7 |
)
|
| 8 |
|
|
|
|
| 9 |
def chat_with_model(prompt):
|
| 10 |
try:
|
| 11 |
+
# Call the model with a single string, NOT wrapped in a list
|
| 12 |
+
# This avoids the list-of-list issue
|
| 13 |
+
response = model(prompt)
|
| 14 |
+
return response # Usually a string already
|
|
|
|
| 15 |
except Exception as e:
|
|
|
|
| 16 |
return f"⚠️ Error: {str(e)}"
|
| 17 |
|
| 18 |
# Gradio interface
|
|
|
|
| 21 |
|
| 22 |
with gr.Row():
|
| 23 |
with gr.Column(scale=3):
|
| 24 |
+
user_input = gr.Textbox(label="Your Message", placeholder="Type 'hi'", lines=3)
|
| 25 |
submit_btn = gr.Button("Send")
|
| 26 |
with gr.Column(scale=2):
|
| 27 |
output_box = gr.Textbox(label="AI Response", lines=10)
|