Spaces:
No application file

File size: 917 Bytes
5855cdb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from transformers import pipeline

# Load the Hugging Face conversational pipeline
@st.cache_resource
def load_model():
    return pipeline("conversational", model="microsoft/DialoGPT-medium")

# Initialize the bot
chatbot = load_model()

# Streamlit app
st.title("Personal Chatbot")
st.write("Hi! I'm your personal chatbot. Ask me anything!")

# Session state to hold conversation
if "conversation" not in st.session_state:
    st.session_state.conversation = None

# User input
user_input = st.text_input("You:", placeholder="Type your message here...")

# Generate and display chatbot response
if st.button("Send") and user_input:
    st.session_state.conversation = chatbot(f"User: {user_input}")
    for message in st.session_state.conversation.iter_texts():
        if message['author'] == 'bot':
            st.text_area("Chatbot:", message['text'], key=f"bot_{user_input}", height=200)