guvichatbotmultilingual / src /streamlit_app.py
zaid002's picture
Update src/streamlit_app.py
290350d verified
raw
history blame contribute delete
654 Bytes
import os
import streamlit as st
from transformers import pipeline
# βœ… Custom cache directory
CUSTOM_CACHE_DIR = "./hf_cache"
os.makedirs(CUSTOM_CACHE_DIR, exist_ok=True)
os.environ["TRANSFORMERS_CACHE"] = CUSTOM_CACHE_DIR
@st.cache_resource
def load_chatbot_model():
# βœ… Use text2text-generation for BlenderBot
return pipeline("text2text-generation", model="facebook/blenderbot-400M-distill")
chatbot = load_chatbot_model()
st.title("πŸ’¬ BlenderBot Chatbot")
user_input = st.text_input("You:")
if st.button("Send") and user_input:
response = chatbot(user_input, max_length=100)
st.write("πŸ€–:", response[0]["generated_text"])