Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
generator = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.2")
|
| 6 |
-
|
| 7 |
-
# Define chatbot logic
|
| 8 |
def fruit_health_bot(message, history=[]):
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
# Create
|
| 15 |
iface = gr.ChatInterface(
|
| 16 |
fn=fruit_health_bot,
|
| 17 |
-
title="
|
| 18 |
-
description="Ask me about the health benefits of
|
| 19 |
)
|
| 20 |
|
| 21 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
+
# Define chatbot behavior
|
|
|
|
|
|
|
|
|
|
| 4 |
def fruit_health_bot(message, history=[]):
|
| 5 |
+
responses = {
|
| 6 |
+
"apple": "Apples are great for heart health and rich in fiber.",
|
| 7 |
+
"banana": "Bananas are rich in potassium and good for energy.",
|
| 8 |
+
"orange": "Oranges boost your immune system with Vitamin C.",
|
| 9 |
+
"mango": "Mangoes are rich in antioxidants and support skin health."
|
| 10 |
+
}
|
| 11 |
+
message_lower = message.lower().strip()
|
| 12 |
+
for fruit in responses:
|
| 13 |
+
if fruit in message_lower:
|
| 14 |
+
return responses[fruit]
|
| 15 |
+
return "Hi there! 🍎 I'm FruitHealthGPT. Ask me about the health benefits of any fruit!"
|
| 16 |
|
| 17 |
+
# Create a simple chat interface
|
| 18 |
iface = gr.ChatInterface(
|
| 19 |
fn=fruit_health_bot,
|
| 20 |
+
title="🍇 FruitHealthGPT",
|
| 21 |
+
description="Ask me about the health benefits of fruits!"
|
| 22 |
)
|
| 23 |
|
| 24 |
iface.launch()
|