import streamlit as st
import streamlit.components.v1 as components
# Set page config
st.set_page_config(
page_title="Perplexity AI Clone",
page_icon="🔍",
layout="wide",
initial_sidebar_state="collapsed"
)
# Custom CSS for dark theme and styling
st.markdown("""
""", unsafe_allow_html=True)
# Main HTML structure
st.markdown("""
What do you want to know?
""", unsafe_allow_html=True)
# JavaScript for interactive functionality
components.html("""
""", height=0)
# Session state for chat history
if 'messages' not in st.session_state:
st.session_state.messages = []
# Handle form submission (alternative method using Streamlit)
with st.form(key='chat_form', clear_on_submit=True):
user_input = st.text_input("", placeholder="Ask anything...", label_visibility="hidden", key="user_input")
submit_button = st.form_submit_button("Send", use_container_width=False)
if submit_button and user_input:
st.session_state.messages.append({"role": "user", "content": user_input})
# Here you would add your AI response logic
st.session_state.messages.append({"role": "assistant", "content": f"You asked: {user_input}"})
# Display chat history (if any messages exist)
if st.session_state.messages:
st.markdown("### Chat History")
for message in st.session_state.messages:
if message["role"] == "user":
st.markdown(f"**You:** {message['content']}")
else:
st.markdown(f"**Assistant:** {message['content']}")