import streamlit as st import requests import uuid # styling st.set_page_config(page_title="Real Estate AI 💬", page_icon="🤖", layout="centered") # Custom CSS for beautification st.markdown(""" """, unsafe_allow_html=True) # Constants WEBHOOK_URL = "https://shahrukh1472.app.n8n.cloud/webhook/2f9e9f00-7ce8-485e-bd34-0df1014c4303" BEARER_TOKEN = "TestCreds99" def generate_session_id(): return str(uuid.uuid4()) def send_message_to_llm(session_id, message): headers = { "Authorization": f"Bearer {BEARER_TOKEN}", "Content-Type": "application/json" } payload = { "sessionId": session_id, "chatInput": message } response = requests.post(WEBHOOK_URL, json=payload, headers=headers) if response.status_code == 200: return response.json()["output"] else: return f"Error: {response.status_code} - {response.text}" def main(): st.sidebar.title("🏠 Navigation") page = st.sidebar.radio("", ["Chatbot", "Information"]) if page == "Chatbot": st.title("Hey, I'm your Real-estate AI Agent. Let's Chat!") st.caption("Your smart assistant for finding the perfect property — faster, easier, smarter.") # Initialize session state if "messages" not in st.session_state: st.session_state.messages = [] if "session_id" not in st.session_state: st.session_state.session_id = generate_session_id() # Display chat messages for message in st.session_state.messages: with st.chat_message(message["role"]): st.write(message["content"]) # User input user_input = st.chat_input("Type your message here...") if user_input: # Add user message to chat history st.session_state.messages.append({"role": "user", "content": user_input}) with st.chat_message("user"): st.write(user_input) # Get LLM response llm_response = send_message_to_llm(st.session_state.session_id, user_input) # Add LLM response to chat history st.session_state.messages.append({"role": "assistant", "content": llm_response}) with st.chat_message("assistant"): st.write(llm_response) elif page == "Information": st.title("About the Real Estate Chatbot") st.markdown(""" ### 🤖 **What This Chatbot Does** This AI chatbot helps you: - 🏘️ Find properties that match your preferences - 💰 Compare price trends in different locations - 📈 Analyze market growth and investment potential - 🏠 Get instant answers to real estate queries ### 🌐 **Future Additions** - Integration with live property listings - Predictive price estimation - Neighborhood insights and amenities --- 💬 *Switch to the Chatbot page from the sidebar to start talking!* """) if __name__ == "__main__": main()