Spaces:
Sleeping
Sleeping
File size: 1,206 Bytes
7808125 3b09a64 7808125 3b09a64 64dac4c 3b09a64 6bd7f31 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
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)
|