ChatGPT_UI / app.py
ytrsoymr's picture
Create app.py
f0308fe verified
import streamlit as st
import time
def chat_interface():
st.set_page_config(page_title="ChatGPT UI Clone", layout="wide")
st.title("ChatGPT UI Clone")
# Sidebar for settings
with st.sidebar:
st.header("Settings")
model_option = st.selectbox("Select Model", ["GPT-3.5", "GPT-4"])
temperature = st.slider("Temperature", 0.0, 1.0, 0.7, 0.1)
# Chat history
if "messages" not in st.session_state:
st.session_state.messages = []
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# User input
user_input = st.chat_input("Type your message...")
if user_input:
st.session_state.messages.append({"role": "user", "content": user_input})
with st.chat_message("user"):
st.markdown(user_input)
# Simulating a response
with st.chat_message("assistant"):
response_placeholder = st.empty()
response_text = "Generating response..."
response_placeholder.markdown(response_text)
time.sleep(1) # Simulating processing time
response_text = f"You said: {user_input}" # Replace with actual model response
response_placeholder.markdown(response_text)
st.session_state.messages.append({"role": "assistant", "content": response_text})
if __name__ == "__main__":
chat_interface()