streamlit-chatbot / app_v1.py
rayl-aoit's picture
Rename app.py to app_v1.py
35d7875 verified
raw
history blame contribute delete
616 Bytes
import streamlit as st
from transformers import pipeline
# Set up the Streamlit app
st.title("Simple Chatbot")
# Initialize the Hugging Face pipeline for conversation
chatbot = pipeline("conversational", model="facebook/blenderbot-400M-distill")
# Function to handle user input and bot response
def get_response(user_input):
conversation = chatbot(user_input)
response = conversation[0]['generated_text']
return response
# Text input for user
user_input = st.text_input("You: ", "")
# When the user enters text
if user_input:
response = get_response(user_input)
st.write(f"Bot: {response}")