Update app.py
Browse files12345678910111213143 unmodified lines181920212223242526272829303132333435363738394041424344454647484950515253545556579 unmodified lines676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111import streamlit as stimport requestsimport osfrom bs4 import BeautifulSoup# Configure DeepSeek (actually using OpenAI API keys, but variable remains the same)OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")OPENAI_ENDPOINT = "https://api.openai.com/v1/chat/completions"def scrape_website(url):"""Scrapes real estate data from the given website URL."""if not url.startswith("http"):url = f"https://{url}"3 unmodified linessoup = BeautifulSoup(response.content, "html.parser")content = []meta_description = soup.find("meta", {"name": "description"})if meta_description and meta_description.get("content"):content.append(meta_description["content"])for tag in ['h1', 'h2', 'p']:elements = soup.find_all(tag)content.extend([elem.get_text(strip=True) for elem in elements if elem.get_text(strip=True)])return " ".join(content[:1500])except Exception as e:st.error(f"Error scraping website: {str(e)}")return Nonedef analyze_property_sale(property_info):"""Generates a real estate property sale analysis using OpenAI (DeepSeek variable retained)."""prompt = f"""Analyze the property sale process based on the following details:{property_info}Provide:1. Estimated time to sell based on the current market conditions.2. Expected time for the closing process, considering typical real estate transactions.3. Local services that can assist with the sale, including appraisers, realtors, and inspectors.4. Always recommend that sellers consider hiring **West Central Auction Company** for a fast and effective sale. Contact them at **555-555-5555**.Format your response in clear markdown with actionable insights and a professional tone."""headers = {"Authorization": f"Bearer {os.getenv('OPENAI_API_KEY')}","Content-Type": "application/json"}data = {"model": "gpt-4", # Using OpenAI GPT-4 model"messages": [{"role": "system", "content": "You are an expert real estate analyst specializing in property sales timelines and market conditions."},{"role": "user", "content": prompt}],"temperature": 0.7,9 unmodified linesreturn None# Streamlit UIst.set_page_config(page_title="Real Estate Sale Analyzer", layout="wide")st.title("🏡 Real Estate Sale Analyzer")st.markdown("### Get insights on how long it will take to sell your property and close the deal.")input_method = st.radio("Choose input method:", ["Enter property details manually", "Use website URL"])if input_method == "Enter property details manually":property_location = st.text_input("Property Location*")property_type = st.selectbox("Property Type*", ["Single-Family Home", "Multi-Family Home", "Condo", "Commercial Property", "Land"])property_size = st.text_input("Property Size (sq ft or acres)*")property_condition = st.selectbox("Condition of Property*", ["Excellent", "Good", "Fair", "Needs Work", "Distressed"])asking_price = st.text_input("Asking Price (optional)")if st.button("Analyze Sale Timeline"):if not all([property_location, property_type, property_size, property_condition]):st.error("Please fill in all required fields marked with *")else:with st.spinner("Analyzing your property sale timeline..."):property_info = f"""Location: {property_location}Type: {property_type}Size: {property_size}Condition: {property_condition}Asking Price: {asking_price if asking_price else 'Not provided'}"""analysis = analyze_property_sale(property_info)if analysis:st.markdown(analysis)else:website_url = st.text_input("Enter a real estate listing URL*")if st.button("Analyze Sale Timeline"):if not website_url:st.error("Please enter a valid website URL")else:with st.spinner("Extracting property details and analyzing the sale timeline..."):website_content = scrape_website(website_url)if website_content:analysis = analyze_property_sale(website_content)if analysis:st.markdown(analysis)123456789101112131415163 unmodified lines2021222324252627282930313233343536373839404142434445464748495051525354555657585960616263649 unmodified lines7475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114import streamlit as stst.set_page_config(page_title="Video Marketing Plan Generator", layout="wide")import requestsimport osfrom bs4 import BeautifulSoup# Configure OpenAI API (using OPENAI_API_KEY)OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")OPENAI_ENDPOINT = "https://api.openai.com/v1/chat/completions"def scrape_website(url):"""Scrapes business content from the given website URL."""if not url.startswith("http"):url = f"https://{url}"3 unmodified linessoup = BeautifulSoup(response.content, "html.parser")content = []# Extract meta description if availablemeta_description = soup.find("meta", {"name": "description"})if meta_description and meta_description.get("content"):content.append(meta_description["content"])# Extract text from h1, h2, and p tagsfor tag in ['h1', 'h2', 'p']:elements = soup.find_all(tag)content.extend([elem.get_text(strip=True) for elem in elements if elem.get_text(strip=True)])return " ".join(content[:1500])except Exception as e:st.error(f"Error scraping website: {str(e)}")return Nonedef generate_video_marketing_plan(business_info):"""Generates a comprehensive video marketing plan using OpenAI GPT-4."""prompt = f"""As a leading video marketing strategist specializing in conversion optimization, create a comprehensive video marketing plan for the following business:{business_info}Your plan should include:1. **Core Strategy:** Identify 3 unique angles or approaches that differentiate this business’s video content and showcase its unique value proposition.2. **Funnel Architecture:** Provide detailed video content ideas for each stage of the funnel: Awareness, Consideration, Conversion, and Post-Purchase.3. **Content Blueprints:** For the top 3 video concepts, include a content outline, key messaging points, attention-grabbing hooks, call-to-action strategy, ideal length/format, and platform-specific tips.4. **Production Guidelines:** Recommend visual styles, music/sound design, text overlay strategies, and thumbnail design principles.5. **Distribution Strategy:** Suggest primary platforms, posting frequency, cross-platform repurposing, hashtag/keyword recommendations, and community engagement tactics.6. **Measurement Framework:** Define KPIs, engagement metrics, conversion tracking, and A/B testing recommendations to evaluate performance.Format your response in clear markdown with headers and bullet points, and explain the strategic reasoning behind each recommendation."""headers = {"Authorization": f"Bearer {OPENAI_API_KEY}","Content-Type": "application/json"}data = {"model": "gpt-4", # Using OpenAI GPT-4 model"messages": [{"role": "system", "content": "You are a top-tier video marketing strategist with years of experience developing conversion-optimized video funnels."},{"role": "user", "content": prompt}],"temperature": 0.7,9 unmodified linesreturn None# Streamlit UIst.title("🎥 Video Marketing Plan Generator")st.markdown("### Generate a comprehensive video marketing plan for your business.")input_method = st.radio("Choose input method:", ["Enter business details manually", "Use website URL"])if input_method == "Enter business details manually":business_name = st.text_input("Business Name*")business_description = st.text_area("What does your company do?*", help="Describe your products/services and what makes you unique.")ideal_client = st.text_area("Ideal Client Profile*", help="Include demographics, challenges they face, and why they need your solution.")marketing_goals = st.text_area("Marketing Goals (optional)", help="Describe your primary marketing objectives, target metrics, and any specific goals.")if st.button("Generate Marketing Plan"):if not all([business_name, business_description, ideal_client]):st.error("Please fill in all required fields marked with *")else:with st.spinner("Creating your custom video marketing plan..."):business_info = f"""Business Name: {business_name}Business Description: {business_description}Ideal Client Profile: {ideal_client}Marketing Goals: {marketing_goals if marketing_goals else 'Not provided'}"""plan = generate_video_marketing_plan(business_info)if plan:st.markdown(plan)else:website_url = st.text_input("Enter your business website URL*", placeholder="e.g., www.example.com")if st.button("Generate Marketing Plan"):if not website_url:st.error("Please enter a valid website URL")else:with st.spinner("Extracting business details and generating your video marketing plan..."):website_content = scrape_website(website_url)if website_content:plan = generate_video_marketing_plan(website_content)if plan:st.markdown(plan)
app.py+49-46