import streamlit as st from transformers import pipeline @st.cache_resource def load_model(): chatbot = pipeline("conversational", model="facebook/blenderbot-400M-distill") return chatbot st.title("Український Чат-бот") if "history" not in st.session_state: st.session_state.history = [] user_input = st.text_input("Ви:", "") if st.button("Надіслати"): chatbot = load_model() response = chatbot(st.session_state.history + [{"role": "user", "content": user_input}]) st.session_state.history.extend([{"role": "user", "content": user_input}, {"role": "assistant", "content": response.generated_responses[0]}]) if st.session_state.history: for message in st.session_state.history: if message["role"] == "user": st.write(f"Ви: {message['content']}") else: st.write(f"Бот: {message['content']}")