ronycu50 commited on
Commit
810eb66
·
verified ·
1 Parent(s): 6b772ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -16
app.py CHANGED
@@ -1,26 +1,22 @@
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()
25
 
26
-
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Load a small, free AI model from Hugging Face
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
+ prompt = f"You are FruitHealthGPT, a friendly expert on fruits and health benefits. Be concise and helpful.\nUser: {message}\nFruitHealthGPT:"
10
+ response = generator(prompt, max_new_tokens=100, do_sample=True, temperature=0.7)
11
+ answer = response[0]["generated_text"].split("FruitHealthGPT:")[-1].strip()
12
+ return answer
 
 
 
 
 
 
 
13
 
14
+ # Create the chat UI
15
  iface = gr.ChatInterface(
16
  fn=fruit_health_bot,
17
+ title="🍎 FruitHealthGPT",
18
+ description="Ask me about the health benefits of any fruit!"
19
  )
20
 
21
  iface.launch()
22