BotWii / app.py
Mauriciotuks's picture
Update app.py
26e08e9 verified
raw
history blame
867 Bytes
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
import gradio as gr
#Lightweight model compatible with free HF Spaces
model_id = "google/flan-t5-small"
#Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
#Create generation pipeline
pipe = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
#AI response function
def botwii_ai(prompt):
result = pipe(prompt, max_new_tokens=100)
return result[0]['generated_text']
#Gradio Interface
interface = gr.Interface(
fn=botwii_ai,
inputs=gr.Textbox(lines=3, label="Enter your question"),
outputs=gr.Textbox(label="AI's response"),
title="🤖 BotWii - Lightweight AI",
description="Simple, free assistant AI based on FLAN-T5-small, no API key needed."
)
interface.launch()