shaneperry0101's picture
fix(test): find bug
6bd7f31 verified
raw
history blame
1.21 kB
import streamlit as st
from transformers import pipeline
# Load the conversational model from Hugging Face
chatbot = pipeline('conversational', model='microsoft/DialoGPT-medium')
# Initialize session state for storing the conversation
if 'conversation' not in st.session_state:
st.session_state.conversation = []
# Streamlit app layout
st.title("Chatbot Application")
user_input = st.text_input("You:", key="input")
# if st.button("Send"):
# if user_input:
# # Append user input to the conversation
# st.session_state.conversation.append({"role": "user", "content": user_input})
# # Generate response
# response = chatbot(user_input)
# bot_response = response[0]['generated_text']
# # Append bot response to the conversation
# st.session_state.conversation.append({"role": "bot", "content": bot_response})
# # Display the conversation
# for message in st.session_state.conversation:
# if message["role"] == "user":
# st.text_area("You:", value=message["content"], key=f"user_{message['content']}", height=50)
# else:
# st.text_area("Bot:", value=message["content"], key=f"bot_{message['content']}", height=50)