From 7ae4d3018eece5bff0f0821149be8058404cff5b Mon Sep 17 00:00:00 2001 From: ShubhamSaboo Date: Wed, 14 May 2025 11:35:02 -0500 Subject: [PATCH] Updated README --- README.md | 1 - .../ai_real_estate_agent/README.md | 61 ---- .../ai_real_estate_agent.py | 321 ------------------ .../ai_real_estate_agent/requirements.txt | 5 - 4 files changed, 388 deletions(-) delete mode 100644 advanced_ai_agents/single_agent_apps/ai_real_estate_agent/README.md delete mode 100644 advanced_ai_agents/single_agent_apps/ai_real_estate_agent/ai_real_estate_agent.py delete mode 100644 advanced_ai_agents/single_agent_apps/ai_real_estate_agent/requirements.txt diff --git a/README.md b/README.md index 0277070..790f379 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,6 @@ We're launching a Global AI Agent Hackathon in collaboration with AI Agent ecosy * [🎯 AI Lead Generation Agent](advanced_ai_agents/single_agent_apps/ai_lead_generation_agent/) * [💰 AI Financial Coach Agent](advanced_ai_agents/multi_agent_apps/ai_financial_coach_agent/) * [🎬 AI Movie Production Agent](advanced_ai_agents/single_agent_apps/ai_movie_production_agent/) -* [🏠 AI Real Estate Agent](advanced_ai_agents/single_agent_apps/ai_real_estate_agent/) * [📈 AI Investment Agent](advanced_ai_agents/single_agent_apps/ai_investment_agent/) * [🏋️‍♂️ AI Health & Fitness Agent](advanced_ai_agents/single_agent_apps/ai_health_fitness_agent/) * [🗞️ AI Journalist Agent](advanced_ai_agents/single_agent_apps/ai_journalist_agent/) diff --git a/advanced_ai_agents/single_agent_apps/ai_real_estate_agent/README.md b/advanced_ai_agents/single_agent_apps/ai_real_estate_agent/README.md deleted file mode 100644 index c9e9f44..0000000 --- a/advanced_ai_agents/single_agent_apps/ai_real_estate_agent/README.md +++ /dev/null @@ -1,61 +0,0 @@ -## 🏠 AI Real Estate Agent - Powered by Firecrawl's Extract Endpoint - -The AI Real Estate Agent automates property search and market analysis using Firecrawl's Extract endpoint and Agno AI Agent's insights. It helps users find properties matching their criteria while providing detailed location trends and investment recommendations. This agent streamlines the property search process by combining data from multiple real estate websites and offering intelligent analysis. - -### Features -- **Smart Property Search**: Uses Firecrawl's Extract endpoint to find properties across multiple real estate websites -- **Multi-Source Integration**: Aggregates data from 99acres, Housing.com, Square Yards, Nobroker, and MagicBricks -- **Location Analysis**: Provides detailed price trends and investment insights for different localities -- **AI-Powered Recommendations**: Uses GPT models to analyze properties and provide structured recommendations -- **User-Friendly Interface**: Clean Streamlit UI for easy property search and results viewing -- **Customizable Search**: Filter by city, property type, category, and budget - -### How to Get Started -1. **Clone the repository**: - ```bash - git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git - cd ai_agent_tutorials/ai_real_estate_agent - ``` - -2. **Install the required packages**: - ```bash - pip install -r requirements.txt - ``` - -3. **Set up your API keys**: - - Get your Firecrawl API key from [Firecrawl's website](https://www.firecrawl.dev/app/api-keys) - - Get your OpenAI API key from [OpenAI's website](https://platform.openai.com/api-keys) - -4. **Run the application**: - ```bash - streamlit run ai_real_estate_agent.py - ``` - -### Using the Agent -1. **Enter API Keys**: - - Input your Firecrawl and OpenAI API keys in the sidebar - - Keys are securely stored in the session state - -2. **Set Search Criteria**: - - Enter the city name - - Select property category (Residential/Commercial) - - Choose property type (Flat/Individual House) - - Set maximum budget in Crores - -3. **View Results**: - - Property recommendations with detailed analysis - - Location trends with investment insights - - Expandable sections for easy reading - -### Features in Detail -- **Property Finding**: - - Searches across multiple real estate websites - - Returns 3-6 properties matching criteria - - Provides detailed property information and analysis - -- **Location Analysis**: - - Price trends for different localities - - Rental yield analysis - - Investment potential assessment - - Top performing areas identification - diff --git a/advanced_ai_agents/single_agent_apps/ai_real_estate_agent/ai_real_estate_agent.py b/advanced_ai_agents/single_agent_apps/ai_real_estate_agent/ai_real_estate_agent.py deleted file mode 100644 index f9b65d2..0000000 --- a/advanced_ai_agents/single_agent_apps/ai_real_estate_agent/ai_real_estate_agent.py +++ /dev/null @@ -1,321 +0,0 @@ -from typing import Dict, List -from pydantic import BaseModel, Field -from agno.agent import Agent -from agno.models.openai import OpenAIChat -from firecrawl import FirecrawlApp -import streamlit as st - -class PropertyData(BaseModel): - """Schema for property data extraction""" - building_name: str = Field(description="Name of the building/property", alias="Building_name") - property_type: str = Field(description="Type of property (commercial, residential, etc)", alias="Property_type") - location_address: str = Field(description="Complete address of the property") - price: str = Field(description="Price of the property", alias="Price") - description: str = Field(description="Detailed description of the property", alias="Description") - -class PropertiesResponse(BaseModel): - """Schema for multiple properties response""" - properties: List[PropertyData] = Field(description="List of property details") - -class LocationData(BaseModel): - """Schema for location price trends""" - location: str - price_per_sqft: float - percent_increase: float - rental_yield: float - -class LocationsResponse(BaseModel): - """Schema for multiple locations response""" - locations: List[LocationData] = Field(description="List of location data points") - -class FirecrawlResponse(BaseModel): - """Schema for Firecrawl API response""" - success: bool - data: Dict - status: str - expiresAt: str - -class PropertyFindingAgent: - """Agent responsible for finding properties and providing recommendations""" - - def __init__(self, firecrawl_api_key: str, openai_api_key: str, model_id: str = "o3-mini"): - self.agent = Agent( - model=OpenAIChat(id=model_id, api_key=openai_api_key), - markdown=True, - description="I am a real estate expert who helps find and analyze properties based on user preferences." - ) - self.firecrawl = FirecrawlApp(api_key=firecrawl_api_key) - - def find_properties( - self, - city: str, - max_price: float, - property_category: str = "Residential", - property_type: str = "Flat" - ) -> str: - """Find and analyze properties based on user preferences""" - formatted_location = city.lower() - - urls = [ - f"https://www.squareyards.com/sale/property-for-sale-in-{formatted_location}/*", - f"https://www.99acres.com/property-in-{formatted_location}-ffid/*", - f"https://housing.com/in/buy/{formatted_location}/{formatted_location}", - # f"https://www.nobroker.in/property/sale/{city}/{formatted_location}", - ] - - property_type_prompt = "Flats" if property_type == "Flat" else "Individual Houses" - - raw_response = self.firecrawl.extract( - urls=urls, - params={ - 'prompt': f"""Extract ONLY 10 OR LESS different {property_category} {property_type_prompt} from {city} that cost less than {max_price} crores. - - Requirements: - - Property Category: {property_category} properties only - - Property Type: {property_type_prompt} only - - Location: {city} - - Maximum Price: {max_price} crores - - Include complete property details with exact location - - IMPORTANT: Return data for at least 3 different properties. MAXIMUM 10. - - Format as a list of properties with their respective details - """, - 'schema': PropertiesResponse.model_json_schema() - } - ) - - print("Raw Property Response:", raw_response) - - if isinstance(raw_response, dict) and raw_response.get('success'): - properties = raw_response['data'].get('properties', []) - else: - properties = [] - - print("Processed Properties:", properties) - - - analysis = self.agent.run( - f"""As a real estate expert, analyze these properties and market trends: - - Properties Found in json format: - {properties} - - **IMPORTANT INSTRUCTIONS:** - 1. ONLY analyze properties from the above JSON data that match the user's requirements: - - Property Category: {property_category} - - Property Type: {property_type} - - Maximum Price: {max_price} crores - 2. DO NOT create new categories or property types - 3. From the matching properties, select 5-6 properties with prices closest to {max_price} crores - - Please provide your analysis in this format: - - 🏠 SELECTED PROPERTIES - • List only 5-6 best matching properties with prices closest to {max_price} crores - • For each property include: - - Name and Location - - Price (with value analysis) - - Key Features - - Pros and Cons - - 💰 BEST VALUE ANALYSIS - • Compare the selected properties based on: - - Price per sq ft - - Location advantage - - Amenities offered - - 📍 LOCATION INSIGHTS - • Specific advantages of the areas where selected properties are located - - 💡 RECOMMENDATIONS - • Top 3 properties from the selection with reasoning - • Investment potential - • Points to consider before purchase - - 🤝 NEGOTIATION TIPS - • Property-specific negotiation strategies - - Format your response in a clear, structured way using the above sections. - """ - ) - - return analysis.content - - def get_location_trends(self, city: str) -> str: - """Get price trends for different localities in the city""" - raw_response = self.firecrawl.extract([ - f"https://www.99acres.com/property-rates-and-price-trends-in-{city.lower()}-prffid/*" - ], { - 'prompt': """Extract price trends data for ALL major localities in the city. - IMPORTANT: - - Return data for at least 5-10 different localities - - Include both premium and affordable areas - - Do not skip any locality mentioned in the source - - Format as a list of locations with their respective data - """, - 'schema': LocationsResponse.model_json_schema(), - }) - - if isinstance(raw_response, dict) and raw_response.get('success'): - locations = raw_response['data'].get('locations', []) - - analysis = self.agent.run( - f"""As a real estate expert, analyze these location price trends for {city}: - - {locations} - - Please provide: - 1. A bullet-point summary of the price trends for each location - 2. Identify the top 3 locations with: - - Highest price appreciation - - Best rental yields - - Best value for money - 3. Investment recommendations: - - Best locations for long-term investment - - Best locations for rental income - - Areas showing emerging potential - 4. Specific advice for investors based on these trends - - Format the response as follows: - - 📊 LOCATION TRENDS SUMMARY - • [Bullet points for each location] - - 🏆 TOP PERFORMING AREAS - • [Bullet points for best areas] - - 💡 INVESTMENT INSIGHTS - • [Bullet points with investment advice] - - 🎯 RECOMMENDATIONS - • [Bullet points with specific recommendations] - """ - ) - - return analysis.content - - return "No price trends data available" - -def create_property_agent(): - """Create PropertyFindingAgent with API keys from session state""" - if 'property_agent' not in st.session_state: - st.session_state.property_agent = PropertyFindingAgent( - firecrawl_api_key=st.session_state.firecrawl_key, - openai_api_key=st.session_state.openai_key, - model_id=st.session_state.model_id - ) - -def main(): - st.set_page_config( - page_title="AI Real Estate Agent", - page_icon="🏠", - layout="wide" - ) - - with st.sidebar: - st.title("🔑 API Configuration") - - st.subheader("🤖 Model Selection") - model_id = st.selectbox( - "Choose OpenAI Model", - options=["o3-mini", "gpt-4o"], - help="Select the AI model to use. Choose gpt-4o if your api doesn't have access to o3-mini" - ) - st.session_state.model_id = model_id - - st.divider() - - st.subheader("🔐 API Keys") - firecrawl_key = st.text_input( - "Firecrawl API Key", - type="password", - help="Enter your Firecrawl API key" - ) - openai_key = st.text_input( - "OpenAI API Key", - type="password", - help="Enter your OpenAI API key" - ) - - if firecrawl_key and openai_key: - st.session_state.firecrawl_key = firecrawl_key - st.session_state.openai_key = openai_key - create_property_agent() - - st.title("🏠 AI Real Estate Agent") - st.info( - """ - Welcome to the AI Real Estate Agent! - Enter your search criteria below to get property recommendations - and location insights. - """ - ) - - col1, col2 = st.columns(2) - - with col1: - city = st.text_input( - "City", - placeholder="Enter city name (e.g., Bangalore)", - help="Enter the city where you want to search for properties" - ) - - property_category = st.selectbox( - "Property Category", - options=["Residential", "Commercial"], - help="Select the type of property you're interested in" - ) - - with col2: - max_price = st.number_input( - "Maximum Price (in Crores)", - min_value=0.1, - max_value=100.0, - value=5.0, - step=0.1, - help="Enter your maximum budget in Crores" - ) - - property_type = st.selectbox( - "Property Type", - options=["Flat", "Individual House"], - help="Select the specific type of property" - ) - - if st.button("🔍 Start Search", use_container_width=True): - if 'property_agent' not in st.session_state: - st.error("⚠️ Please enter your API keys in the sidebar first!") - return - - if not city: - st.error("⚠️ Please enter a city name!") - return - - try: - with st.spinner("🔍 Searching for properties..."): - property_results = st.session_state.property_agent.find_properties( - city=city, - max_price=max_price, - property_category=property_category, - property_type=property_type - ) - - st.success("✅ Property search completed!") - - st.subheader("🏘️ Property Recommendations") - st.markdown(property_results) - - st.divider() - - with st.spinner("📊 Analyzing location trends..."): - location_trends = st.session_state.property_agent.get_location_trends(city) - - st.success("✅ Location analysis completed!") - - with st.expander("📈 Location Trends Analysis of the city"): - st.markdown(location_trends) - - except Exception as e: - st.error(f"❌ An error occurred: {str(e)}") - -if __name__ == "__main__": - main() diff --git a/advanced_ai_agents/single_agent_apps/ai_real_estate_agent/requirements.txt b/advanced_ai_agents/single_agent_apps/ai_real_estate_agent/requirements.txt deleted file mode 100644 index 8590901..0000000 --- a/advanced_ai_agents/single_agent_apps/ai_real_estate_agent/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -agno -firecrawl-py==1.9.0 -pydantic -streamlit -openai \ No newline at end of file