CHATBOT_2 / app.py
Dhruv0730's picture
Upload app.py
f10b1a9 verified
raw
history blame contribute delete
769 Bytes
# -*- coding: utf-8 -*-
"""app.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/14A4bTrBIYxd8EGljvdL540Y3NO-maA06
"""
# app.py
import streamlit as st
from transformers import pipeline
# Load model (we will use a lightweight model for demo)
@st.cache_resource
def load_pipeline():
return pipeline("text2text-generation", model="google/flan-t5-small")
chatbot = load_pipeline()
# Streamlit UI
st.title("Your Topic Chatbot 🤖")
st.write("Ask me anything about [Your Topic]!")
user_input = st.text_input("You:", "")
if st.button("Ask"):
if user_input:
response = chatbot(f"Answer the following question: {user_input}", max_length=100)
st.success(response[0]['generated_text'])