Spaces:
Sleeping
Sleeping
| 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 | |
| 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"]) | |