Spaces:
Sleeping
Sleeping
File size: 654 Bytes
290350d 20038c6 9022362 7bfc476 290350d 723e03c 9022362 290350d 723e03c 290350d 723e03c 290350d 723e03c 290350d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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"])
|