README / app.py
ronycu50's picture
Update app.py
810eb66 verified
Raw History Blame Contribute Delete
775 Bytes
import gradio as gr
from transformers import pipeline
# Load a small, free AI model from Hugging Face
generator = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.2")
# Define chatbot logic
def fruit_health_bot(message, history=[]):
prompt = f"You are FruitHealthGPT, a friendly expert on fruits and health benefits. Be concise and helpful.\nUser: {message}\nFruitHealthGPT:"
response = generator(prompt, max_new_tokens=100, do_sample=True, temperature=0.7)
answer = response[0]["generated_text"].split("FruitHealthGPT:")[-1].strip()
return answer
# Create the chat UI
iface = gr.ChatInterface(
fn=fruit_health_bot,
title="🍎 FruitHealthGPT",
description="Ask me about the health benefits of any fruit!"
)
iface.launch()