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"])