From d8198dd23a4a8a525cf36c94e0d2805599d10ce7 Mon Sep 17 00:00:00 2001 From: Aksh Parekh Date: Mon, 29 Sep 2025 22:58:55 -0700 Subject: [PATCH 1/8] [DOCS][EXAMPLE] Job Finding Swarm --- docs/examples/job_finding.md | 652 +++++++++++++++++++++++++++++ docs/mkdocs.yml | 8 +- examples/demos/apps/job_finding.py | 538 ++++++++++++++++++++++++ 3 files changed, 1193 insertions(+), 5 deletions(-) create mode 100644 docs/examples/job_finding.md create mode 100644 examples/demos/apps/job_finding.py diff --git a/docs/examples/job_finding.md b/docs/examples/job_finding.md new file mode 100644 index 00000000..352f84be --- /dev/null +++ b/docs/examples/job_finding.md @@ -0,0 +1,652 @@ +# AI Job Search Swarm + +## Overview + +The AI Job Search Swarm is an intelligent multi-agent system designed to automate and streamline the job search process using the Swarms framework. It leverages specialized AI agents to analyze user requirements, execute comprehensive job searches, and curate relevant opportunities, transforming traditional job hunting into an intelligent, collaborative process. + +## Key Components + +The Job Search Swarm consists of three specialized agents, each responsible for a critical stage of the job search process: + +| Agent Name | Role | Responsibilities | +| :------------------------ | :--------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------- | +| **Sarah-Requirements-Analyzer** | Extracts and clarifies job search requirements. | Engages with the user to understand job titles, skills, locations, salary, company preferences, experience level, work authorization, and career goals. Analyzes user responses to identify key search terms, must-haves, deal-breakers, and priority factors. Generates 3-5 optimized search queries. | +| **David-Search-Executor** | Executes job searches and analyzes results for relevance. | Uses the `exa_search` tool for each query provided. Analyzes results for job title, skills, location, salary, company reputation, responsibilities, and growth opportunities. Categorizes results by match strength (Strong, Good, Moderate, Weak) and extracts key job details. | +| **Lisa-Results-Curator** | Filters, organizes, and presents job search results. | Reviews all search results. Filters and prioritizes based on match scores, user requirements, and job quality. Organizes results into "Top Recommendations," "Strong Alternatives," and "Worth Considering." Provides detailed comparisons for top recommendations and engages the user for feedback to refine the search. | + +## Installation + +To run the AI Job Search Swarm, you'll need to set up your Python environment and configure necessary API keys. + +### Prerequisites + +* Python 3.8+ +* An Exa API Key + +### Installation Steps + +1. **Clone the repository** (if you haven't already): + ```bash + git clone https://github.com/kyegomez/swarms.git + cd swarms + ``` +2. **Create a virtual environment** and activate it: + ```bash + python -m venv venv + source venv/bin/activate + ``` +3. **Install dependencies**: + The `job_finding.py` script relies on several libraries. These can be installed using the `requirements.txt` file located at the root of the project. + ```bash + pip install -r requirements.txt + ``` + This will install `httpx`, `python-dotenv`, `loguru`, and other necessary packages. + +### API Key Configuration + +The `exa_search` tool used by the Search Executor Agent requires an `EXA_API_KEY`. + +1. **Obtain an Exa API Key**: Visit [Exa AI](https://exa.ai/) to get your API key. +2. **Create a `.env` file**: In the root directory of your project, create a file named `.env` and add your Exa API key to it: + ``` + EXA_API_KEY="your_exa_api_key_here" + ``` + Replace `"your_exa_api_key_here"` with your actual Exa API Key. The `python-dotenv` library will automatically load this key into your environment. + +## Example Usage + +To run the job search swarm, execute the `job_finding.py` script from your terminal. + +```bash +python examples/demos/apps/job_finding.py +``` + +The script is designed to run with a pre-filled user requirement for demonstration purposes. You can modify the `user_requirements` string in the `main()` function within `examples/demos/apps/job_finding.py` to test different job search scenarios. + +**Example User Requirements (from `main()` function):** + +```python +from typing import List +import os +from dotenv import load_dotenv +from loguru import logger +import httpx +from swarms.structs.agent import Agent +from swarms.structs.conversation import Conversation +from swarms.utils.history_output_formatter import history_output_formatter +from swarms.utils.any_to_str import any_to_str + +# --- Exa Search Tool Integration --- +def exa_search( + query: str, + characters: int = 500, + sources: int = 3, +) -> str: + """ + Perform a highly summarized Exa web search for job listings and career information. + + Args: + query (str): Search query for jobs or career info. + characters (int): Max characters for summary. + sources (int): Number of sources. + + Returns: + str: Condensed summary of search results. + """ + api_key = os.getenv("EXA_API_KEY") + if not api_key: + raise ValueError("EXA_API_KEY environment variable is not set") + + headers = { + "x-api-key": api_key, + "content-type": "application/json", + } + + payload = { + "query": query, + "type": "auto", + "numResults": sources, + "contents": { + "text": True, + "summary": { + "schema": { + "type": "object", + "required": ["answer"], + "additionalProperties": False, + "properties": { + "answer": { + "type": "string", + "description": "Highly condensed summary of the search result", + } + }, + } + }, + "context": {"maxCharacters": characters}, + }, + } + + try: + logger.info(f"[SEARCH] Exa job search: {query[:50]}...") + response = httpx.post( + "https://api.exa.ai/search", + json=payload, + headers=headers, + timeout=30, + ) + response.raise_for_status() + json_data = response.json() + return any_to_str(json_data) + except Exception as e: + logger.error(f"Exa search failed: {e}") + return f"Search failed: {str(e)}. Please try again." + +# Load environment variables +load_dotenv() + +# System prompts for each agent + +REQUIREMENTS_ANALYZER_PROMPT = """ +You are the Requirements Analyzer Agent for Job Search. + +ROLE: +Extract and clarify job search requirements from user input to create optimized search queries. + +RESPONSIBILITIES: +- Engage with the user to understand: + * Desired job titles and roles + * Required skills and qualifications + * Preferred locations (remote, hybrid, on-site) + * Salary expectations + * Company size and culture preferences + * Industry preferences + * Experience level + * Work authorization status + * Career goals and priorities + +- Analyze user responses to identify: + * Key search terms and keywords + * Must-have vs nice-to-have requirements + * Deal-breakers or constraints + * Priority factors in job selection + +- Generate optimized search queries: + * Create 3-5 targeted search queries based on user requirements + * Combine job titles, skills, locations, and key criteria + * Format queries for maximum relevance + +OUTPUT FORMAT: +Provide a comprehensive requirements analysis: +1. User Profile Summary: + - Job titles of interest + - Key skills and qualifications + - Location preferences + - Salary range + - Priority factors + +2. Search Strategy: + - List of 3-5 optimized search queries + - Rationale for each query + - Expected result types + +3. Clarifications Needed (if any): + - Questions to refine search + - Missing information + +IMPORTANT: +- Always include ALL user responses verbatim in your analysis +- Format search queries clearly for the next agent +- Be specific and actionable in your recommendations +- Ask follow-up questions if requirements are unclear +""" + +SEARCH_EXECUTOR_PROMPT = """ +You are the Search Executor Agent for Job Search. + +ROLE: +Execute job searches using exa_search and analyze results for relevance. + +TOOLS: +You have access to the exa_search tool. Use it to find current job listings and career opportunities. + +RESPONSIBILITIES: +- Execute searches using queries from the Requirements Analyzer +- Use exa_search for EACH query provided +- Analyze search results for: + * Job title match + * Skills alignment + * Location compatibility + * Salary range fit + * Company reputation + * Role responsibilities + * Growth opportunities + +- Categorize results: + * Strong Match (80-100% alignment) + * Good Match (60-79% alignment) + * Moderate Match (40-59% alignment) + * Weak Match (<40% alignment) + +- For each job listing, extract: + * Job title and company + * Location and work arrangement + * Key requirements + * Salary range (if available) + * Application link or contact + * Match score and reasoning + +OUTPUT FORMAT: +Provide structured search results: +1. Search Execution Summary: + - Queries executed + - Total results found + - Distribution by match category + +2. Detailed Job Listings (organized by match strength): + For each job: + - Company and Job Title + - Location and Work Type + - Key Requirements + - Why it's a match (or not) + - Match Score (percentage) + - Application link + - Source (cite exa_search) + +3. Search Insights: + - Common themes in results + - Gap analysis (requirements not met) + - Market observations + +INSTRUCTIONS: +- Always use exa_search for EVERY query provided +- Cite exa_search results clearly +- Be objective in match assessment +- Provide actionable insights +""" + +RESULTS_CURATOR_PROMPT = """ +You are the Results Curator Agent for Job Search. + +ROLE: +Filter, organize, and present job search results to the user for decision-making. + +RESPONSIBILITIES: +- Review all search results from the Search Executor +- Filter and prioritize based on: + * Match scores + * User requirements + * Application deadlines + * Job quality indicators + +- Organize results into: + * Top Recommendations (top 3-5 best matches) + * Strong Alternatives (next 5-10 options) + * Worth Considering (other relevant matches) + +- For top recommendations, provide: + * Detailed comparison + * Pros and cons for each + * Application strategy suggestions + * Next steps + +- Engage user for feedback: + * Present curated results clearly + * Ask which jobs interest them + * Identify what's missing + * Determine if new search is needed + +OUTPUT FORMAT: +Provide a curated job search report: + +1. Executive Summary: + - Total jobs reviewed + - Number of strong matches + - Key findings + +2. Top Recommendations (detailed): + For each (max 5): + - Company & Title + - Why it's a top match + - Key highlights + - Potential concerns + - Recommendation strength (1-10) + - Application priority (High/Medium/Low) + +3. Strong Alternatives (brief list): + - Company & Title + - One-line match summary + - Match score + +4. User Decision Point: + Ask the user: + - "Which of these jobs interest you most?" + - "What's missing from these results?" + - "Should we refine the search or proceed with applications?" + - "Any requirements you'd like to adjust?" + +5. Next Steps: + Based on user response, either: + - Proceed with selected jobs + - Run new search with adjusted criteria + - Deep dive into specific opportunities + +IMPORTANT: +- Make it easy for users to make decisions +- Be honest about job fit +- Provide clear paths forward +- Always ask for user feedback before concluding +""" + +class JobSearchSwarm: + def __init__( + self, + name: str = "AI Job Search Swarm", + description: str = "An intelligent job search system that finds your ideal role", + max_loops: int = 1, + user_name: str = "Job Seeker", + output_type: str = "json", + ): + self.max_loops = max_loops + self.name = name + self.description = description + self.user_name = user_name + self.output_type = output_type + + self.agents = self._initialize_agents() + self.conversation = Conversation() + self.exa_search_results = [] + self.search_queries = [] + self.current_iteration = 0 + self.max_iterations = 10 # Prevent infinite loops + self.search_concluded = False + + self.handle_initial_processing() + + def handle_initial_processing(self): + self.conversation.add( + role="System", + content=f"Company: {self.name}\n" + f"Description: {self.description}\n" + f"Mission: Find the perfect job match for {self.user_name}" + ) + + def _initialize_agents(self) -> List[Agent]: + return [ + Agent( + agent_name="Sarah-Requirements-Analyzer", + agent_description="Analyzes user requirements and creates optimized job search queries.", + system_prompt=REQUIREMENTS_ANALYZER_PROMPT, + max_loops=self.max_loops, + dynamic_temperature_enabled=True, + output_type="final", + ), + Agent( + agent_name="David-Search-Executor", + agent_description="Executes job searches and analyzes results for relevance.", + system_prompt=SEARCH_EXECUTOR_PROMPT, + max_loops=self.max_loops, + dynamic_temperature_enabled=True, + output_type="final", + ), + Agent( + agent_name="Lisa-Results-Curator", + agent_description="Curates and presents job results for user decision-making.", + system_prompt=RESULTS_CURATOR_PROMPT, + max_loops=self.max_loops, + dynamic_temperature_enabled=True, + output_type="final", + ), + ] + + def find_agent_by_name(self, name: str) -> Agent: + for agent in self.agents: + if name in agent.agent_name: + return agent + return None + + def analyze_requirements(self, user_input: str): + """Phase 1: Analyze user requirements and generate search queries""" + sarah_agent = self.find_agent_by_name("Requirements-Analyzer") + + sarah_output = sarah_agent.run( + f"User Input: {user_input}\n\n" + f"Conversation History: {self.conversation.get_str()}\n\n" + f"Analyze the user's job search requirements and generate 3-5 optimized search queries. " + f"If information is unclear, ask clarifying questions." + ) + + self.conversation.add( + role="Requirements-Analyzer", content=sarah_output + ) + + # Extract search queries from Sarah's output + self.search_queries = self._extract_search_queries(sarah_output) + + return sarah_output + + def _extract_search_queries(self, analyzer_output: str) -> List[str]: + """Extract search queries from Requirements Analyzer output""" + queries = [] + lines = analyzer_output.split('\n') + + # Look for lines that appear to be search queries + for line in lines: + line = line.strip() + # Simple heuristic: lines with certain keywords or patterns + if any(keyword in line.lower() for keyword in ['query:', 'search:', 'query']): + # Extract the actual query + if ':' in line: + query = line.split(':', 1)[1].strip() + if query and len(query) > 10: + queries.append(query) + + # If no queries found, create default ones based on common patterns + if not queries: + logger.warning("No explicit queries found, generating fallback queries") + queries = [ + "software engineer jobs remote", + "data scientist positions", + "product manager opportunities" + ] + + return queries[:5] # Limit to 5 queries + + def execute_searches(self): + """Phase 2: Execute searches using exa_search and analyze results""" + # Execute exa_search for each query + self.exa_search_results = [] + for query in self.search_queries: + result = exa_search(query) + self.exa_search_results.append({ + "query": query, + "exa_result": result + }) + + # Pass results to Search Executor agent + david_agent = self.find_agent_by_name("Search-Executor") + + # Build exa context + exa_context = "\n\n[Exa Search Results]\n" + for item in self.exa_search_results: + exa_context += f"Query: {item['query']}\nResults: {item['exa_result']}\n\n" + + david_output = david_agent.run( + f"Conversation History: {self.conversation.get_str()}\n\n" + f"{exa_context}\n" + f"Analyze these job search results. Categorize each job by match strength and provide detailed analysis." + ) + + self.conversation.add( + role="Search-Executor", content=david_output + ) + + return david_output + + def curate_results(self) -> str: + """Phase 3: Curate results and get user feedback""" + lisa_agent = self.find_agent_by_name("Results-Curator") + + lisa_output = lisa_agent.run( + f"Conversation History: {self.conversation.get_str()}\n\n" + f"Curate the job search results, present top recommendations, and ask the user for feedback. " + f"Determine if we should continue searching or if the user has found suitable options." + ) + + self.conversation.add( + role="Results-Curator", content=lisa_output + ) + + return lisa_output + + def end(self) -> tuple[bool, str]: + """ + Conclude the job search without user interaction. + + Returns: + tuple[bool, str]: (needs_refinement, user_feedback) + """ + return False, "Search completed successfully." + + def run(self, initial_user_input: str): + """ + Run the job search swarm with continuous optimization. + + Args: + initial_user_input: User's initial job search requirements + """ + self.conversation.add(role=self.user_name, content=initial_user_input) + + user_input = initial_user_input + + while not self.search_concluded and self.current_iteration < self.max_iterations: + self.current_iteration += 1 + logger.info(f"Starting search iteration {self.current_iteration}") + + # Phase 1: Analyze requirements + print(f"\n{'='*60}") + print(f"ITERATION {self.current_iteration} - ANALYZING REQUIREMENTS") + print(f"{'='*60}\n") + self.analyze_requirements(user_input) + + + # Phase 2: Execute searches + print(f"\n{'='*60}") + print(f"ITERATION {self.current_iteration} - EXECUTING JOB SEARCHES") + print(f"{'='*60}\n") + self.execute_searches() + + # Phase 3: Curate and present results + print(f"\n{'='*60}") + print(f"ITERATION {self.current_iteration} - CURATING RESULTS") + print(f"{'='*60}\n") + self.curate_results() + + # Phase 4: Get user feedback + needs_refinement, user_feedback = self.end() + + # Add user feedback to conversation + self.conversation.add( + role=self.user_name, + content=f"User Feedback: {user_feedback}" + ) + + # Check if we should continue + if not needs_refinement: + self.search_concluded = True + print(f"\n{'='*60}") + print("SEARCH CONCLUDED - USER SATISFIED WITH RESULTS") + print(f"{'='*60}\n") + else: + # In production, get new user input here + print(f"\n{'='*60}") + print("SEARCH REQUIRES REFINEMENT") + print(f"{'='*60}\n") + # For demo, we'll stop after first iteration + self.search_concluded = True + + # Return formatted conversation history + return history_output_formatter( + self.conversation, type=self.output_type + ) + +def main(): + """Main entry point for job search swarm""" + + # Example 1: Pre-filled user requirements (for testing) + user_requirements = """ + I'm looking for a senior software engineer position with the following requirements: + - Job Title: Senior Software Engineer or Staff Engineer + - Skills: Python, distributed systems, cloud architecture (AWS/GCP), Kubernetes + - Location: Remote (US-based) or San Francisco Bay Area + - Salary: $180k - $250k + - Company: Mid-size to large tech companies, prefer companies with strong engineering culture + - Experience Level: 7+ years + - Industry: SaaS, Cloud Infrastructure, or Developer Tools + - Work Authorization: US Citizen + - Priorities: Technical challenges, work-life balance, remote flexibility, equity upside + - Deal-breakers: No pure management roles, no strict return-to-office policies + """ + + # Initialize the swarm + job_search_swarm = JobSearchSwarm( + name="AI-Powered Job Search Engine", + description="Intelligent job search system that continuously refines results until the perfect match is found", + user_name="Job Seeker", + output_type="json", + max_loops=1, + ) + + # Run the swarm + print("\n" + "="*60) + print("INITIALIZING JOB SEARCH SWARM") + print("="*60 + "\n") + + job_search_swarm.run(initial_user_input=user_requirements) + +if __name__ == "__main__": + main() +``` + +Upon execution, the swarm will: +1. Analyze the provided `user_requirements`. +2. Generate and execute search queries using Exa. +3. Curate and present the results in a structured format, including top recommendations and a prompt for user feedback. + +The output will be printed to the console, showing the progression of the agents through each phase of the job search. + +## Workflow Stages + +The `JobSearchSwarm` processes the job search through a continuous, iterative workflow: + +1. **Phase 1: Analyze Requirements (`analyze_requirements`)**: The `Sarah-Requirements-Analyzer` agent processes the user's input and conversation history to extract job criteria and generate optimized search queries. +2. **Phase 2: Execute Searches (`execute_searches`)**: The `David-Search-Executor` agent takes the generated queries, uses the `exa_search` tool to find job listings, and analyzes their relevance against the user's requirements. +3. **Phase 3: Curate Results (`curate_results`)**: The `Lisa-Results-Curator` agent reviews, filters, and organizes the search results, presenting top recommendations and asking for user feedback to guide further iterations. +4. **Phase 4: Get User Feedback (`end`)**: In a full implementation, this stage gathers explicit user feedback to determine if the search needs refinement or can be concluded. For demonstration, this is a simulated step. + +The swarm continues these phases in a loop until the `search_concluded` flag is set to `True` or `max_iterations` is reached. + +## Customization + +You can customize the `JobSearchSwarm` by modifying the `JobSearchSwarm` class parameters or the agents' prompts: + +* **`name` and `description`**: Customize the swarm's identity. +* **`user_name`**: Define the name of the user interacting with the swarm. +* **`output_type`**: Specify the desired output format for the conversation history (e.g., "json" or "list"). +* **`max_loops`**: Control the number of internal reasoning iterations each agent performs (set during agent initialization). +* **`system_prompt`**: Modify the `REQUIREMENTS_ANALYZER_PROMPT`, `SEARCH_EXECUTOR_PROMPT`, and `RESULTS_CURATOR_PROMPT` to refine agent behavior and output. +* **`max_iterations`**: Limit the total number of search cycles the swarm performs. + +## Best Practices + +To get the most out of the AI Job Search Swarm: + +* **Provide Clear Requirements**: Start with a detailed and unambiguous `initial_user_input` to help the Requirements Analyzer generate effective queries. +* **Iterate and Refine**: In a live application, leverage the user feedback loop to continuously refine search criteria and improve result relevance. +* **Monitor Agent Outputs**: Regularly review the outputs from each agent to ensure they are performing as expected and to identify areas for prompt improvement. +* **Manage API Usage**: Be mindful of your Exa API key usage, especially when experimenting with `max_iterations` or a large number of search queries. + +## Limitations + +* **Prompt Engineering Dependency**: The quality of the search results heavily depends on the clarity and effectiveness of the agent `system_prompt`s and the initial user input. +* **Exa Search Scope**: The `exa_search` tool's effectiveness is tied to the breadth and depth of Exa's indexed web content. +* **Iteration Control**: The current `end` method in `examples/demos/apps/job_finding.py` is simplified for demonstration. A robust production system would require a more sophisticated user interaction mechanism to determine when to stop or refine the search. +* **Verification Needed**: All AI-generated outputs, including job matches and summaries, should be independently verified by the user. \ No newline at end of file diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 7cc4064a..c16159d1 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -290,6 +290,7 @@ nav: - Overview: "swarms/structs/multi_swarm_orchestration.md" - HierarchicalSwarm: "swarms/structs/hierarchical_swarm.md" - Hierarchical Structured Communication Framework: "swarms/structs/hierarchical_structured_communication_framework.md" + - Auto Agent Builder: "swarms/structs/auto_agent_builder.md" - Hybrid Hierarchical-Cluster Swarm: "swarms/structs/hhcs.md" - Auto Swarm Builder: "swarms/structs/auto_swarm_builder.md" - Swarm Matcher: "swarms/structs/swarm_matcher.md" @@ -301,7 +302,6 @@ nav: - MultiAgentRouter: "swarms/structs/multi_agent_router.md" - ModelRouter: "swarms/structs/model_router.md" - - Rearrangers: - SwarmRearrange: "swarms/structs/swarm_rearrange.md" - AgentRearrange: "swarms/structs/agent_rearrange.md" @@ -345,10 +345,6 @@ nav: - Deploy on Google Cloud Run: "swarms_cloud/cloud_run.md" - Deploy on Phala: "swarms_cloud/phala_deploy.md" - Deploy on Cloudflare Workers: "swarms_cloud/cloudflare_workers.md" - - Agent Orchestration Protocol (AOP): - - AOP Reference: "swarms/structs/aop.md" - - AOP Server Setup: "swarms/examples/aop_server_example.md" - - AOP Cluster Example: "swarms/examples/aop_cluster_example.md" - Examples: @@ -421,6 +417,8 @@ nav: - Hiearchical Marketing Team: "examples/marketing_team.md" - Gold ETF Research with HeavySwarm: "examples/gold_etf_research.md" - Hiring Swarm: "examples/hiring_swarm.md" + - Real Estate Swarm: "examples/realestate_swarm.md" + - Job Finding Swarm: "examples/job_finding.md" - Tools & Integrations: - Web Search with Exa: "examples/exa_search.md" diff --git a/examples/demos/apps/job_finding.py b/examples/demos/apps/job_finding.py new file mode 100644 index 00000000..910f0b14 --- /dev/null +++ b/examples/demos/apps/job_finding.py @@ -0,0 +1,538 @@ +from typing import List +import os +from dotenv import load_dotenv +from loguru import logger +import httpx +from swarms.structs.agent import Agent +from swarms.structs.conversation import Conversation +from swarms.utils.history_output_formatter import history_output_formatter +from swarms.utils.any_to_str import any_to_str + +# --- Exa Search Tool Integration --- +def exa_search( + query: str, + characters: int = 500, + sources: int = 3, +) -> str: + """ + Perform a highly summarized Exa web search for job listings and career information. + + Args: + query (str): Search query for jobs or career info. + characters (int): Max characters for summary. + sources (int): Number of sources. + + Returns: + str: Condensed summary of search results. + """ + api_key = os.getenv("EXA_API_KEY") + if not api_key: + raise ValueError("EXA_API_KEY environment variable is not set") + + headers = { + "x-api-key": api_key, + "content-type": "application/json", + } + + payload = { + "query": query, + "type": "auto", + "numResults": sources, + "contents": { + "text": True, + "summary": { + "schema": { + "type": "object", + "required": ["answer"], + "additionalProperties": False, + "properties": { + "answer": { + "type": "string", + "description": "Highly condensed summary of the search result", + } + }, + } + }, + "context": {"maxCharacters": characters}, + }, + } + + try: + logger.info(f"[SEARCH] Exa job search: {query[:50]}...") + response = httpx.post( + "https://api.exa.ai/search", + json=payload, + headers=headers, + timeout=30, + ) + response.raise_for_status() + json_data = response.json() + return any_to_str(json_data) + except Exception as e: + logger.error(f"Exa search failed: {e}") + return f"Search failed: {str(e)}. Please try again." + +# Load environment variables +load_dotenv() + +# System prompts for each agent + +REQUIREMENTS_ANALYZER_PROMPT = """ +You are the Requirements Analyzer Agent for Job Search. + +ROLE: +Extract and clarify job search requirements from user input to create optimized search queries. + +RESPONSIBILITIES: +- Engage with the user to understand: + * Desired job titles and roles + * Required skills and qualifications + * Preferred locations (remote, hybrid, on-site) + * Salary expectations + * Company size and culture preferences + * Industry preferences + * Experience level + * Work authorization status + * Career goals and priorities + +- Analyze user responses to identify: + * Key search terms and keywords + * Must-have vs nice-to-have requirements + * Deal-breakers or constraints + * Priority factors in job selection + +- Generate optimized search queries: + * Create 3-5 targeted search queries based on user requirements + * Combine job titles, skills, locations, and key criteria + * Format queries for maximum relevance + +OUTPUT FORMAT: +Provide a comprehensive requirements analysis: +1. User Profile Summary: + - Job titles of interest + - Key skills and qualifications + - Location preferences + - Salary range + - Priority factors + +2. Search Strategy: + - List of 3-5 optimized search queries + - Rationale for each query + - Expected result types + +3. Clarifications Needed (if any): + - Questions to refine search + - Missing information + +IMPORTANT: +- Always include ALL user responses verbatim in your analysis +- Format search queries clearly for the next agent +- Be specific and actionable in your recommendations +- Ask follow-up questions if requirements are unclear +""" + +SEARCH_EXECUTOR_PROMPT = """ +You are the Search Executor Agent for Job Search. + +ROLE: +Execute job searches using exa_search and analyze results for relevance. + +TOOLS: +You have access to the exa_search tool. Use it to find current job listings and career opportunities. + +RESPONSIBILITIES: +- Execute searches using queries from the Requirements Analyzer +- Use exa_search for EACH query provided +- Analyze search results for: + * Job title match + * Skills alignment + * Location compatibility + * Salary range fit + * Company reputation + * Role responsibilities + * Growth opportunities + +- Categorize results: + * Strong Match (80-100% alignment) + * Good Match (60-79% alignment) + * Moderate Match (40-59% alignment) + * Weak Match (<40% alignment) + +- For each job listing, extract: + * Job title and company + * Location and work arrangement + * Key requirements + * Salary range (if available) + * Application link or contact + * Match score and reasoning + +OUTPUT FORMAT: +Provide structured search results: +1. Search Execution Summary: + - Queries executed + - Total results found + - Distribution by match category + +2. Detailed Job Listings (organized by match strength): + For each job: + - Company and Job Title + - Location and Work Type + - Key Requirements + - Why it's a match (or not) + - Match Score (percentage) + - Application link + - Source (cite exa_search) + +3. Search Insights: + - Common themes in results + - Gap analysis (requirements not met) + - Market observations + +INSTRUCTIONS: +- Always use exa_search for EVERY query provided +- Cite exa_search results clearly +- Be objective in match assessment +- Provide actionable insights +""" + +RESULTS_CURATOR_PROMPT = """ +You are the Results Curator Agent for Job Search. + +ROLE: +Filter, organize, and present job search results to the user for decision-making. + +RESPONSIBILITIES: +- Review all search results from the Search Executor +- Filter and prioritize based on: + * Match scores + * User requirements + * Application deadlines + * Job quality indicators + +- Organize results into: + * Top Recommendations (top 3-5 best matches) + * Strong Alternatives (next 5-10 options) + * Worth Considering (other relevant matches) + +- For top recommendations, provide: + * Detailed comparison + * Pros and cons for each + * Application strategy suggestions + * Next steps + +- Engage user for feedback: + * Present curated results clearly + * Ask which jobs interest them + * Identify what's missing + * Determine if new search is needed + +OUTPUT FORMAT: +Provide a curated job search report: + +1. Executive Summary: + - Total jobs reviewed + - Number of strong matches + - Key findings + +2. Top Recommendations (detailed): + For each (max 5): + - Company & Title + - Why it's a top match + - Key highlights + - Potential concerns + - Recommendation strength (1-10) + - Application priority (High/Medium/Low) + +3. Strong Alternatives (brief list): + - Company & Title + - One-line match summary + - Match score + +4. User Decision Point: + Ask the user: + - "Which of these jobs interest you most?" + - "What's missing from these results?" + - "Should we refine the search or proceed with applications?" + - "Any requirements you'd like to adjust?" + +5. Next Steps: + Based on user response, either: + - Proceed with selected jobs + - Run new search with adjusted criteria + - Deep dive into specific opportunities + +IMPORTANT: +- Make it easy for users to make decisions +- Be honest about job fit +- Provide clear paths forward +- Always ask for user feedback before concluding +""" + +class JobSearchSwarm: + def __init__( + self, + name: str = "AI Job Search Swarm", + description: str = "An intelligent job search system that finds your ideal role", + max_loops: int = 1, + user_name: str = "Job Seeker", + output_type: str = "json", + ): + self.max_loops = max_loops + self.name = name + self.description = description + self.user_name = user_name + self.output_type = output_type + + self.agents = self._initialize_agents() + self.conversation = Conversation() + self.exa_search_results = [] + self.search_queries = [] + self.current_iteration = 0 + self.max_iterations = 10 # Prevent infinite loops + self.search_concluded = False + + self.handle_initial_processing() + + def handle_initial_processing(self): + self.conversation.add( + role="System", + content=f"Company: {self.name}\n" + f"Description: {self.description}\n" + f"Mission: Find the perfect job match for {self.user_name}" + ) + + def _initialize_agents(self) -> List[Agent]: + return [ + Agent( + agent_name="Sarah-Requirements-Analyzer", + agent_description="Analyzes user requirements and creates optimized job search queries.", + system_prompt=REQUIREMENTS_ANALYZER_PROMPT, + max_loops=self.max_loops, + dynamic_temperature_enabled=True, + output_type="final", + ), + Agent( + agent_name="David-Search-Executor", + agent_description="Executes job searches and analyzes results for relevance.", + system_prompt=SEARCH_EXECUTOR_PROMPT, + max_loops=self.max_loops, + dynamic_temperature_enabled=True, + output_type="final", + ), + Agent( + agent_name="Lisa-Results-Curator", + agent_description="Curates and presents job results for user decision-making.", + system_prompt=RESULTS_CURATOR_PROMPT, + max_loops=self.max_loops, + dynamic_temperature_enabled=True, + output_type="final", + ), + ] + + def find_agent_by_name(self, name: str) -> Agent: + for agent in self.agents: + if name in agent.agent_name: + return agent + return None + + def analyze_requirements(self, user_input: str): + """Phase 1: Analyze user requirements and generate search queries""" + sarah_agent = self.find_agent_by_name("Requirements-Analyzer") + + sarah_output = sarah_agent.run( + f"User Input: {user_input}\n\n" + f"Conversation History: {self.conversation.get_str()}\n\n" + f"Analyze the user's job search requirements and generate 3-5 optimized search queries. " + f"If information is unclear, ask clarifying questions." + ) + + self.conversation.add( + role="Requirements-Analyzer", content=sarah_output + ) + + # Extract search queries from Sarah's output + self.search_queries = self._extract_search_queries(sarah_output) + + return sarah_output + + def _extract_search_queries(self, analyzer_output: str) -> List[str]: + """Extract search queries from Requirements Analyzer output""" + queries = [] + lines = analyzer_output.split('\n') + + # Look for lines that appear to be search queries + for line in lines: + line = line.strip() + # Simple heuristic: lines with certain keywords or patterns + if any(keyword in line.lower() for keyword in ['query:', 'search:', 'query']): + # Extract the actual query + if ':' in line: + query = line.split(':', 1)[1].strip() + if query and len(query) > 10: + queries.append(query) + + # If no queries found, create default ones based on common patterns + if not queries: + logger.warning("No explicit queries found, generating fallback queries") + queries = [ + "software engineer jobs remote", + "data scientist positions", + "product manager opportunities" + ] + + return queries[:5] # Limit to 5 queries + + def execute_searches(self): + """Phase 2: Execute searches using exa_search and analyze results""" + # Execute exa_search for each query + self.exa_search_results = [] + for query in self.search_queries: + result = exa_search(query) + self.exa_search_results.append({ + "query": query, + "exa_result": result + }) + + # Pass results to Search Executor agent + david_agent = self.find_agent_by_name("Search-Executor") + + # Build exa context + exa_context = "\n\n[Exa Search Results]\n" + for item in self.exa_search_results: + exa_context += f"Query: {item['query']}\nResults: {item['exa_result']}\n\n" + + david_output = david_agent.run( + f"Conversation History: {self.conversation.get_str()}\n\n" + f"{exa_context}\n" + f"Analyze these job search results. Categorize each job by match strength and provide detailed analysis." + ) + + self.conversation.add( + role="Search-Executor", content=david_output + ) + + return david_output + + def curate_results(self) -> str: + """Phase 3: Curate results and get user feedback""" + lisa_agent = self.find_agent_by_name("Results-Curator") + + lisa_output = lisa_agent.run( + f"Conversation History: {self.conversation.get_str()}\n\n" + f"Curate the job search results, present top recommendations, and ask the user for feedback. " + f"Determine if we should continue searching or if the user has found suitable options." + ) + + self.conversation.add( + role="Results-Curator", content=lisa_output + ) + + return lisa_output + + def end(self) -> tuple[bool, str]: + """ + Conclude the job search without user interaction. + + Returns: + tuple[bool, str]: (needs_refinement, user_feedback) + """ + return False, "Search completed successfully." + + def run(self, initial_user_input: str): + """ + Run the job search swarm with continuous optimization. + + Args: + initial_user_input: User's initial job search requirements + """ + self.conversation.add(role=self.user_name, content=initial_user_input) + + user_input = initial_user_input + + while not self.search_concluded and self.current_iteration < self.max_iterations: + self.current_iteration += 1 + logger.info(f"Starting search iteration {self.current_iteration}") + + # Phase 1: Analyze requirements + print(f"\n{'='*60}") + print(f"ITERATION {self.current_iteration} - ANALYZING REQUIREMENTS") + print(f"{'='*60}\n") + self.analyze_requirements(user_input) + + + # Phase 2: Execute searches + print(f"\n{'='*60}") + print(f"ITERATION {self.current_iteration} - EXECUTING JOB SEARCHES") + print(f"{'='*60}\n") + self.execute_searches() + + # Phase 3: Curate and present results + print(f"\n{'='*60}") + print(f"ITERATION {self.current_iteration} - CURATING RESULTS") + print(f"{'='*60}\n") + self.curate_results() + + # Phase 4: Get user feedback + needs_refinement, user_feedback = self.end() + + # Add user feedback to conversation + self.conversation.add( + role=self.user_name, + content=f"User Feedback: {user_feedback}" + ) + + # Check if we should continue + if not needs_refinement: + self.search_concluded = True + print(f"\n{'='*60}") + print("SEARCH CONCLUDED - USER SATISFIED WITH RESULTS") + print(f"{'='*60}\n") + else: + # In production, get new user input here + print(f"\n{'='*60}") + print("SEARCH REQUIRES REFINEMENT") + print(f"{'='*60}\n") + # For demo, we'll stop after first iteration + self.search_concluded = True + + # Return formatted conversation history + return history_output_formatter( + self.conversation, type=self.output_type + ) + +def main(): + """Main entry point for job search swarm""" + + # Example 1: Pre-filled user requirements (for testing) + user_requirements = """ + I'm looking for a senior software engineer position with the following requirements: + - Job Title: Senior Software Engineer or Staff Engineer + - Skills: Python, distributed systems, cloud architecture (AWS/GCP), Kubernetes + - Location: Remote (US-based) or San Francisco Bay Area + - Salary: $180k - $250k + - Company: Mid-size to large tech companies, prefer companies with strong engineering culture + - Experience Level: 7+ years + - Industry: SaaS, Cloud Infrastructure, or Developer Tools + - Work Authorization: US Citizen + - Priorities: Technical challenges, work-life balance, remote flexibility, equity upside + - Deal-breakers: No pure management roles, no strict return-to-office policies + """ + + # Initialize the swarm + job_search_swarm = JobSearchSwarm( + name="AI-Powered Job Search Engine", + description="Intelligent job search system that continuously refines results until the perfect match is found", + user_name="Job Seeker", + output_type="json", + max_loops=1, + ) + + # Run the swarm + print("\n" + "="*60) + print("INITIALIZING JOB SEARCH SWARM") + print("="*60 + "\n") + + job_search_swarm.run(initial_user_input=user_requirements) + +if __name__ == "__main__": + main() \ No newline at end of file From 700bb8c6c2cb38c85ef16cfdc80bb31a17af30f8 Mon Sep 17 00:00:00 2001 From: Aksh Parekh Date: Wed, 1 Oct 2025 21:34:43 -0700 Subject: [PATCH 2/8] [FIX] DOCS & EXA --- docs/examples/job_finding.md | 744 +++++++++++++++-------------- examples/demos/apps/job_finding.py | 72 +-- 2 files changed, 378 insertions(+), 438 deletions(-) diff --git a/docs/examples/job_finding.md b/docs/examples/job_finding.md index 352f84be..65782723 100644 --- a/docs/examples/job_finding.md +++ b/docs/examples/job_finding.md @@ -25,17 +25,6 @@ To run the AI Job Search Swarm, you'll need to set up your Python environment an ### Installation Steps -1. **Clone the repository** (if you haven't already): - ```bash - git clone https://github.com/kyegomez/swarms.git - cd swarms - ``` -2. **Create a virtual environment** and activate it: - ```bash - python -m venv venv - source venv/bin/activate - ``` -3. **Install dependencies**: The `job_finding.py` script relies on several libraries. These can be installed using the `requirements.txt` file located at the root of the project. ```bash pip install -r requirements.txt @@ -67,282 +56,247 @@ The script is designed to run with a pre-filled user requirement for demonstrati ```python from typing import List -import os -from dotenv import load_dotenv from loguru import logger -import httpx from swarms.structs.agent import Agent from swarms.structs.conversation import Conversation from swarms.utils.history_output_formatter import history_output_formatter -from swarms.utils.any_to_str import any_to_str - -# --- Exa Search Tool Integration --- -def exa_search( - query: str, - characters: int = 500, - sources: int = 3, -) -> str: - """ - Perform a highly summarized Exa web search for job listings and career information. - - Args: - query (str): Search query for jobs or career info. - characters (int): Max characters for summary. - sources (int): Number of sources. - - Returns: - str: Condensed summary of search results. - """ - api_key = os.getenv("EXA_API_KEY") - if not api_key: - raise ValueError("EXA_API_KEY environment variable is not set") - - headers = { - "x-api-key": api_key, - "content-type": "application/json", - } - - payload = { - "query": query, - "type": "auto", - "numResults": sources, - "contents": { - "text": True, - "summary": { - "schema": { - "type": "object", - "required": ["answer"], - "additionalProperties": False, - "properties": { - "answer": { - "type": "string", - "description": "Highly condensed summary of the search result", - } - }, - } - }, - "context": {"maxCharacters": characters}, - }, - } - - try: - logger.info(f"[SEARCH] Exa job search: {query[:50]}...") - response = httpx.post( - "https://api.exa.ai/search", - json=payload, - headers=headers, - timeout=30, - ) - response.raise_for_status() - json_data = response.json() - return any_to_str(json_data) - except Exception as e: - logger.error(f"Exa search failed: {e}") - return f"Search failed: {str(e)}. Please try again." - -# Load environment variables -load_dotenv() +from swarms_tools import exa_search # System prompts for each agent - -REQUIREMENTS_ANALYZER_PROMPT = """ -You are the Requirements Analyzer Agent for Job Search. +INTAKE_AGENT_PROMPT = """ +You are an M&A Intake Specialist responsible for gathering comprehensive information about a potential transaction. ROLE: -Extract and clarify job search requirements from user input to create optimized search queries. +Engage with the user to understand the full context of the potential M&A deal, extracting critical details that will guide subsequent analyses. RESPONSIBILITIES: -- Engage with the user to understand: - * Desired job titles and roles - * Required skills and qualifications - * Preferred locations (remote, hybrid, on-site) - * Salary expectations - * Company size and culture preferences - * Industry preferences - * Experience level - * Work authorization status - * Career goals and priorities - -- Analyze user responses to identify: - * Key search terms and keywords - * Must-have vs nice-to-have requirements - * Deal-breakers or constraints - * Priority factors in job selection - -- Generate optimized search queries: - * Create 3-5 targeted search queries based on user requirements - * Combine job titles, skills, locations, and key criteria - * Format queries for maximum relevance +- Conduct a thorough initial interview to understand: + * Transaction type (acquisition, merger, divestiture) + * Industry and sector specifics + * Target company profile and size + * Strategic objectives + * Buyer/seller perspective + * Timeline and urgency + * Budget constraints + * Specific concerns or focus areas OUTPUT FORMAT: -Provide a comprehensive requirements analysis: -1. User Profile Summary: - - Job titles of interest - - Key skills and qualifications - - Location preferences - - Salary range - - Priority factors - -2. Search Strategy: - - List of 3-5 optimized search queries - - Rationale for each query - - Expected result types - -3. Clarifications Needed (if any): - - Questions to refine search - - Missing information +Provide a comprehensive Deal Brief that includes: +1. Transaction Overview + - Proposed transaction type + - Key parties involved + - Initial strategic rationale + +2. Stakeholder Context + - Buyer's background and motivations + - Target company's current position + - Key decision-makers + +3. Initial Assessment + - Preliminary strategic fit + - Potential challenges or red flags + - Recommended focus areas for deeper analysis + +4. Information Gaps + - Questions that need further clarification + - Additional data points required IMPORTANT: -- Always include ALL user responses verbatim in your analysis -- Format search queries clearly for the next agent -- Be specific and actionable in your recommendations -- Ask follow-up questions if requirements are unclear +- Be thorough and systematic +- Ask probing questions to uncover nuanced details +- Maintain a neutral, professional tone +- Prepare a foundation for subsequent in-depth analysis """ -SEARCH_EXECUTOR_PROMPT = """ -You are the Search Executor Agent for Job Search. +MARKET_ANALYSIS_PROMPT = """ +You are an M&A Market Intelligence Analyst tasked with conducting comprehensive market research. ROLE: -Execute job searches using exa_search and analyze results for relevance. +Perform an in-depth analysis of market dynamics, competitive landscape, and strategic implications for the potential transaction. TOOLS: -You have access to the exa_search tool. Use it to find current job listings and career opportunities. +You have access to the exa_search tool for gathering real-time market intelligence. RESPONSIBILITIES: -- Execute searches using queries from the Requirements Analyzer -- Use exa_search for EACH query provided -- Analyze search results for: - * Job title match - * Skills alignment - * Location compatibility - * Salary range fit - * Company reputation - * Role responsibilities - * Growth opportunities - -- Categorize results: - * Strong Match (80-100% alignment) - * Good Match (60-79% alignment) - * Moderate Match (40-59% alignment) - * Weak Match (<40% alignment) - -- For each job listing, extract: - * Job title and company - * Location and work arrangement - * Key requirements - * Salary range (if available) - * Application link or contact - * Match score and reasoning +1. Conduct Market Research + - Use exa_search to gather current market insights + - Analyze industry trends, size, and growth potential + - Identify key players and market share distribution + +2. Competitive Landscape Analysis + - Map out competitive ecosystem + - Assess target company's market positioning + - Identify potential competitive advantages or vulnerabilities + +3. Strategic Fit Evaluation + - Analyze alignment with buyer's strategic objectives + - Assess potential market entry or expansion opportunities + - Evaluate potential for market disruption + +4. External Factor Assessment + - Examine regulatory environment + - Analyze technological disruption potential + - Consider macroeconomic impacts OUTPUT FORMAT: -Provide structured search results: -1. Search Execution Summary: - - Queries executed - - Total results found - - Distribution by match category - -2. Detailed Job Listings (organized by match strength): - For each job: - - Company and Job Title - - Location and Work Type - - Key Requirements - - Why it's a match (or not) - - Match Score (percentage) - - Application link - - Source (cite exa_search) - -3. Search Insights: - - Common themes in results - - Gap analysis (requirements not met) - - Market observations - -INSTRUCTIONS: -- Always use exa_search for EVERY query provided -- Cite exa_search results clearly -- Be objective in match assessment -- Provide actionable insights +Provide a comprehensive Market Analysis Report: +1. Market Overview + - Market size and growth trajectory + - Key industry trends + - Competitive landscape summary + +2. Strategic Fit Assessment + - Market attractiveness score (1-10) + - Strategic alignment evaluation + - Potential synergies and opportunities + +3. Risk and Opportunity Mapping + - Key market opportunities + - Potential competitive threats + - Regulatory and technological risk factors + +4. Recommended Next Steps + - Areas requiring deeper investigation + - Initial strategic recommendations """ -RESULTS_CURATOR_PROMPT = """ -You are the Results Curator Agent for Job Search. +FINANCIAL_VALUATION_PROMPT = """ +You are an M&A Financial Analysis and Risk Expert. Perform comprehensive financial evaluation and risk assessment. -ROLE: -Filter, organize, and present job search results to the user for decision-making. +RESPONSIBILITIES: +1. Financial Health Analysis + - Analyze revenue trends and quality + - Evaluate profitability metrics (EBITDA, margins) + - Conduct cash flow analysis + - Assess balance sheet strength + - Review working capital requirements + +2. Valuation Analysis + - Perform comparable company analysis + - Conduct precedent transaction analysis + - Develop Discounted Cash Flow (DCF) model + - Assess asset-based valuation + +3. Synergy and Risk Assessment + - Quantify potential revenue and cost synergies + - Identify financial and operational risks + - Evaluate integration complexity + - Assess potential deal-breakers + +OUTPUT FORMAT: +1. Comprehensive Financial Analysis Report +2. Valuation Range (low, mid, high scenarios) +3. Synergy Potential Breakdown +4. Detailed Risk Matrix +5. Recommended Pricing Strategy +""" + +DEAL_STRUCTURING_PROMPT = """ +You are an M&A Deal Structuring Advisor. Recommend the optimal transaction structure. RESPONSIBILITIES: -- Review all search results from the Search Executor -- Filter and prioritize based on: - * Match scores - * User requirements - * Application deadlines - * Job quality indicators - -- Organize results into: - * Top Recommendations (top 3-5 best matches) - * Strong Alternatives (next 5-10 options) - * Worth Considering (other relevant matches) - -- For top recommendations, provide: - * Detailed comparison - * Pros and cons for each - * Application strategy suggestions - * Next steps - -- Engage user for feedback: - * Present curated results clearly - * Ask which jobs interest them - * Identify what's missing - * Determine if new search is needed +1. Transaction Structure Design + - Evaluate asset vs stock purchase options + - Analyze cash vs stock consideration + - Design earnout provisions + - Develop contingent payment structures + +2. Financing Strategy + - Recommend debt/equity mix + - Identify optimal financing sources + - Assess impact on buyer's capital structure + +3. Tax and Legal Optimization + - Design tax-efficient structure + - Consider jurisdictional implications + - Minimize tax liabilities + +4. Deal Protection Mechanisms + - Develop escrow arrangements + - Design representations and warranties + - Create indemnification provisions + - Recommend non-compete agreements OUTPUT FORMAT: -Provide a curated job search report: - -1. Executive Summary: - - Total jobs reviewed - - Number of strong matches - - Key findings - -2. Top Recommendations (detailed): - For each (max 5): - - Company & Title - - Why it's a top match - - Key highlights - - Potential concerns - - Recommendation strength (1-10) - - Application priority (High/Medium/Low) - -3. Strong Alternatives (brief list): - - Company & Title - - One-line match summary - - Match score - -4. User Decision Point: - Ask the user: - - "Which of these jobs interest you most?" - - "What's missing from these results?" - - "Should we refine the search or proceed with applications?" - - "Any requirements you'd like to adjust?" - -5. Next Steps: - Based on user response, either: - - Proceed with selected jobs - - Run new search with adjusted criteria - - Deep dive into specific opportunities +1. Recommended Deal Structure +2. Detailed Payment Terms +3. Key Contractual Protections +4. Tax Optimization Strategy +5. Rationale for Proposed Structure +""" -IMPORTANT: -- Make it easy for users to make decisions -- Be honest about job fit -- Provide clear paths forward -- Always ask for user feedback before concluding +INTEGRATION_PLANNING_PROMPT = """ +You are an M&A Integration Planning Expert. Develop a comprehensive post-merger integration roadmap. + +RESPONSIBILITIES: +1. Immediate Integration Priorities + - Define critical day-1 actions + - Develop communication strategy + - Identify quick win opportunities + +2. 100-Day Integration Plan + - Design organizational structure alignment + - Establish governance framework + - Create detailed integration milestones + +3. Functional Integration Strategy + - Plan operations consolidation + - Design systems and technology integration + - Align sales and marketing approaches + - Develop cultural integration plan + +4. Synergy Realization + - Create detailed synergy capture timeline + - Establish performance tracking mechanisms + - Define accountability framework + +OUTPUT FORMAT: +1. Comprehensive Integration Roadmap +2. Detailed 100-Day Plan +3. Functional Integration Strategies +4. Synergy Realization Timeline +5. Risk Mitigation Recommendations """ -class JobSearchSwarm: +FINAL_RECOMMENDATION_PROMPT = """ +You are the Senior M&A Advisory Partner. Synthesize all analyses into a comprehensive recommendation. + +RESPONSIBILITIES: +1. Executive Summary + - Summarize transaction overview + - Highlight strategic rationale + - Articulate key value drivers + +2. Investment Thesis Validation + - Assess strategic benefits + - Evaluate financial attractiveness + - Project long-term potential + +3. Comprehensive Risk Assessment + - Summarize top risks + - Provide mitigation strategies + - Identify potential deal-breakers + +4. Final Recommendation + - Provide clear GO/NO-GO recommendation + - Specify recommended offer range + - Outline key proceeding conditions + +OUTPUT FORMAT: +1. Executive-Level Recommendation Report +2. Decision Framework +3. Risk-Adjusted Strategic Perspective +4. Actionable Next Steps +5. Recommendation Confidence Level +""" + +class MAAdvisorySwarm: def __init__( self, - name: str = "AI Job Search Swarm", - description: str = "An intelligent job search system that finds your ideal role", + name: str = "M&A Advisory Swarm", + description: str = "Comprehensive AI-driven M&A advisory system", max_loops: int = 1, - user_name: str = "Job Seeker", + user_name: str = "M&A Advisor", output_type: str = "json", ): self.max_loops = max_loops @@ -356,8 +310,8 @@ class JobSearchSwarm: self.exa_search_results = [] self.search_queries = [] self.current_iteration = 0 - self.max_iterations = 10 # Prevent infinite loops - self.search_concluded = False + self.max_iterations = 1 # Limiting to 1 iteration for full sequential demo + self.analysis_concluded = False self.handle_initial_processing() @@ -366,35 +320,59 @@ class JobSearchSwarm: role="System", content=f"Company: {self.name}\n" f"Description: {self.description}\n" - f"Mission: Find the perfect job match for {self.user_name}" + f"Mission: Provide comprehensive M&A advisory for {self.user_name}" ) def _initialize_agents(self) -> List[Agent]: return [ Agent( - agent_name="Sarah-Requirements-Analyzer", - agent_description="Analyzes user requirements and creates optimized job search queries.", - system_prompt=REQUIREMENTS_ANALYZER_PROMPT, + agent_name="Emma-Intake-Specialist", + agent_description="Gathers comprehensive initial information about the potential M&A transaction.", + system_prompt=INTAKE_AGENT_PROMPT, max_loops=self.max_loops, dynamic_temperature_enabled=True, output_type="final", ), Agent( - agent_name="David-Search-Executor", - agent_description="Executes job searches and analyzes results for relevance.", - system_prompt=SEARCH_EXECUTOR_PROMPT, + agent_name="Marcus-Market-Analyst", + agent_description="Conducts in-depth market research and competitive analysis.", + system_prompt=MARKET_ANALYSIS_PROMPT, max_loops=self.max_loops, dynamic_temperature_enabled=True, output_type="final", ), Agent( - agent_name="Lisa-Results-Curator", - agent_description="Curates and presents job results for user decision-making.", - system_prompt=RESULTS_CURATOR_PROMPT, + agent_name="Sophia-Financial-Analyst", + agent_description="Performs comprehensive financial valuation and risk assessment.", + system_prompt=FINANCIAL_VALUATION_PROMPT, max_loops=self.max_loops, dynamic_temperature_enabled=True, output_type="final", ), + Agent( + agent_name="David-Deal-Structuring-Advisor", + agent_description="Recommends optimal deal structure and terms.", + system_prompt=DEAL_STRUCTURING_PROMPT, + max_loops=self.max_loops, + dynamic_temperature_enabled=True, + output_type="final", + ), + Agent( + agent_name="Nathan-Integration-Planner", + agent_description="Develops comprehensive post-merger integration roadmap.", + system_prompt=INTEGRATION_PLANNING_PROMPT, + max_loops=self.max_loops, + dynamic_temperature_enabled=True, + output_type="final", + ), + Agent( + agent_name="Alex-Final-Recommendation-Partner", + agent_description="Synthesizes all analyses into a comprehensive recommendation.", + system_prompt=FINAL_RECOMMENDATION_PROMPT, + max_loops=self.max_loops, + dynamic_temperature_enabled=True, + output_type="final", + ) ] def find_agent_by_name(self, name: str) -> Agent: @@ -403,55 +381,51 @@ class JobSearchSwarm: return agent return None - def analyze_requirements(self, user_input: str): - """Phase 1: Analyze user requirements and generate search queries""" - sarah_agent = self.find_agent_by_name("Requirements-Analyzer") + def intake_and_scoping(self, user_input: str): + """Phase 1: Intake and initial deal scoping""" + emma_agent = self.find_agent_by_name("Intake-Specialist") - sarah_output = sarah_agent.run( + emma_output = emma_agent.run( f"User Input: {user_input}\n\n" f"Conversation History: {self.conversation.get_str()}\n\n" - f"Analyze the user's job search requirements and generate 3-5 optimized search queries. " + f"Analyze the potential M&A transaction, extract key details, and prepare a comprehensive deal brief. " f"If information is unclear, ask clarifying questions." ) self.conversation.add( - role="Requirements-Analyzer", content=sarah_output + role="Intake-Specialist", content=emma_output ) - # Extract search queries from Sarah's output - self.search_queries = self._extract_search_queries(sarah_output) + # Extract potential search queries for market research + self.search_queries = self._extract_search_queries(emma_output) - return sarah_output + return emma_output - def _extract_search_queries(self, analyzer_output: str) -> List[str]: - """Extract search queries from Requirements Analyzer output""" + def _extract_search_queries(self, intake_output: str) -> List[str]: + """Extract search queries from Intake Specialist output""" queries = [] - lines = analyzer_output.split('\n') + lines = intake_output.split('\n') - # Look for lines that appear to be search queries + # Look for lines that could be good search queries for line in lines: line = line.strip() - # Simple heuristic: lines with certain keywords or patterns - if any(keyword in line.lower() for keyword in ['query:', 'search:', 'query']): - # Extract the actual query - if ':' in line: - query = line.split(':', 1)[1].strip() - if query and len(query) > 10: - queries.append(query) + # Simple heuristic: lines with potential research keywords + if any(keyword in line.lower() for keyword in ['market', 'industry', 'trend', 'competitor', 'analysis']): + if len(line) > 20: # Ensure query is substantial + queries.append(line) - # If no queries found, create default ones based on common patterns + # Fallback queries if none found if not queries: - logger.warning("No explicit queries found, generating fallback queries") queries = [ - "software engineer jobs remote", - "data scientist positions", - "product manager opportunities" + "M&A trends in technology sector", + "Market analysis for potential business acquisition", + "Competitive landscape in enterprise software" ] - return queries[:5] # Limit to 5 queries + return queries[:3] # Limit to 3 queries - def execute_searches(self): - """Phase 2: Execute searches using exa_search and analyze results""" + def market_research(self): + """Phase 2: Conduct market research using exa_search""" # Execute exa_search for each query self.exa_search_results = [] for query in self.search_queries: @@ -461,107 +435,138 @@ class JobSearchSwarm: "exa_result": result }) - # Pass results to Search Executor agent - david_agent = self.find_agent_by_name("Search-Executor") + # Pass results to Market Analysis agent + marcus_agent = self.find_agent_by_name("Market-Analyst") # Build exa context - exa_context = "\n\n[Exa Search Results]\n" + exa_context = "\n\n[Exa Market Research Results]\n" for item in self.exa_search_results: exa_context += f"Query: {item['query']}\nResults: {item['exa_result']}\n\n" - david_output = david_agent.run( + marcus_output = marcus_agent.run( f"Conversation History: {self.conversation.get_str()}\n\n" f"{exa_context}\n" - f"Analyze these job search results. Categorize each job by match strength and provide detailed analysis." + f"Analyze these market research results. Provide comprehensive market intelligence and strategic insights." + ) + + self.conversation.add( + role="Market-Analyst", content=marcus_output + ) + + return marcus_output + + def financial_valuation(self): + """Phase 3: Perform comprehensive financial valuation and risk assessment""" + sophia_agent = self.find_agent_by_name("Financial-Analyst") + + sophia_output = sophia_agent.run( + f"Conversation History: {self.conversation.get_str()}\n\n" + f"Perform comprehensive financial analysis and risk assessment based on previous insights." ) self.conversation.add( - role="Search-Executor", content=david_output + role="Financial-Analyst", content=sophia_output + ) + + return sophia_output + + def deal_structuring(self): + """Phase 4: Recommend optimal deal structure""" + david_agent = self.find_agent_by_name("Deal-Structuring-Advisor") + + david_output = david_agent.run( + f"Conversation History: {self.conversation.get_str()}\n\n" + f"Recommend the optimal transaction structure and terms based on all prior analyses." + ) + + self.conversation.add( + role="Deal-Structuring-Advisor", content=david_output ) return david_output - def curate_results(self) -> str: - """Phase 3: Curate results and get user feedback""" - lisa_agent = self.find_agent_by_name("Results-Curator") + def integration_planning(self): + """Phase 5: Develop post-merger integration roadmap""" + nathan_agent = self.find_agent_by_name("Integration-Planner") - lisa_output = lisa_agent.run( + nathan_output = nathan_agent.run( f"Conversation History: {self.conversation.get_str()}\n\n" - f"Curate the job search results, present top recommendations, and ask the user for feedback. " - f"Determine if we should continue searching or if the user has found suitable options." + f"Create a comprehensive integration plan to realize deal value." ) self.conversation.add( - role="Results-Curator", content=lisa_output + role="Integration-Planner", content=nathan_output ) - return lisa_output + return nathan_output - def end(self) -> tuple[bool, str]: - """ - Conclude the job search without user interaction. + def final_recommendation(self): + """Phase 6: Synthesize all analyses into a comprehensive recommendation""" + alex_agent = self.find_agent_by_name("Final-Recommendation-Partner") - Returns: - tuple[bool, str]: (needs_refinement, user_feedback) - """ - return False, "Search completed successfully." + alex_output = alex_agent.run( + f"Conversation History: {self.conversation.get_str()}\n\n" + f"Synthesize all agent analyses into a comprehensive, actionable M&A recommendation." + ) + + self.conversation.add( + role="Final-Recommendation-Partner", content=alex_output + ) + + return alex_output + def run(self, initial_user_input: str): """ - Run the job search swarm with continuous optimization. + Run the M&A advisory swarm with continuous analysis. Args: - initial_user_input: User's initial job search requirements + initial_user_input: User's initial M&A transaction details """ self.conversation.add(role=self.user_name, content=initial_user_input) - user_input = initial_user_input - - while not self.search_concluded and self.current_iteration < self.max_iterations: + while not self.analysis_concluded and self.current_iteration < self.max_iterations: self.current_iteration += 1 - logger.info(f"Starting search iteration {self.current_iteration}") + logger.info(f"Starting analysis iteration {self.current_iteration}") - # Phase 1: Analyze requirements + # Phase 1: Intake and Scoping print(f"\n{'='*60}") - print(f"ITERATION {self.current_iteration} - ANALYZING REQUIREMENTS") + print("ITERATION - INTAKE AND SCOPING") print(f"{'='*60}\n") - self.analyze_requirements(user_input) - + self.intake_and_scoping(initial_user_input) - # Phase 2: Execute searches + # Phase 2: Market Research (with exa_search) print(f"\n{'='*60}") - print(f"ITERATION {self.current_iteration} - EXECUTING JOB SEARCHES") + print("ITERATION - MARKET RESEARCH") print(f"{'='*60}\n") - self.execute_searches() + self.market_research() - # Phase 3: Curate and present results + # Phase 3: Financial Valuation print(f"\n{'='*60}") - print(f"ITERATION {self.current_iteration} - CURATING RESULTS") + print("ITERATION - FINANCIAL VALUATION") print(f"{'='*60}\n") - self.curate_results() + self.financial_valuation() - # Phase 4: Get user feedback - needs_refinement, user_feedback = self.end() + # Phase 4: Deal Structuring + print(f"\n{'='*60}") + print("ITERATION - DEAL STRUCTURING") + print(f"{'='*60}\n") + self.deal_structuring() - # Add user feedback to conversation - self.conversation.add( - role=self.user_name, - content=f"User Feedback: {user_feedback}" - ) + # Phase 5: Integration Planning + print(f"\n{'='*60}") + print("ITERATION - INTEGRATION PLANNING") + print(f"{'='*60}\n") + self.integration_planning() - # Check if we should continue - if not needs_refinement: - self.search_concluded = True - print(f"\n{'='*60}") - print("SEARCH CONCLUDED - USER SATISFIED WITH RESULTS") - print(f"{'='*60}\n") - else: - # In production, get new user input here - print(f"\n{'='*60}") - print("SEARCH REQUIRES REFINEMENT") - print(f"{'='*60}\n") - # For demo, we'll stop after first iteration - self.search_concluded = True + # Phase 6: Final Recommendation + print(f"\n{'='*60}") + print("ITERATION - FINAL RECOMMENDATION") + print(f"{'='*60}\n") + self.final_recommendation() + + # Conclude analysis after one full sequence for demo purposes + self.analysis_concluded = True # Return formatted conversation history return history_output_formatter( @@ -569,38 +574,43 @@ class JobSearchSwarm: ) def main(): - """Main entry point for job search swarm""" + """Main entry point for M&A advisory swarm""" + + # Example M&A transaction details + transaction_details = """ + We are exploring a potential acquisition of DataPulse Analytics by TechNova Solutions. + + Transaction Context: + - Buyer: TechNova Solutions (NASDAQ: TNVA) - $500M annual revenue enterprise software company + - Target: DataPulse Analytics - Series B AI-driven analytics startup based in San Francisco + - Primary Objectives: + * Expand predictive analytics capabilities in healthcare and financial services + * Accelerate AI-powered business intelligence product roadmap + * Acquire top-tier machine learning engineering talent - # Example 1: Pre-filled user requirements (for testing) - user_requirements = """ - I'm looking for a senior software engineer position with the following requirements: - - Job Title: Senior Software Engineer or Staff Engineer - - Skills: Python, distributed systems, cloud architecture (AWS/GCP), Kubernetes - - Location: Remote (US-based) or San Francisco Bay Area - - Salary: $180k - $250k - - Company: Mid-size to large tech companies, prefer companies with strong engineering culture - - Experience Level: 7+ years - - Industry: SaaS, Cloud Infrastructure, or Developer Tools - - Work Authorization: US Citizen - - Priorities: Technical challenges, work-life balance, remote flexibility, equity upside - - Deal-breakers: No pure management roles, no strict return-to-office policies + Key Considerations: + - Deep integration of DataPulse's proprietary AI models into TechNova's existing platform + - Retention of key DataPulse leadership and engineering team + - Projected 3-year ROI and synergy potential + - Regulatory and compliance alignment + - Technology stack compatibility """ # Initialize the swarm - job_search_swarm = JobSearchSwarm( - name="AI-Powered Job Search Engine", - description="Intelligent job search system that continuously refines results until the perfect match is found", - user_name="Job Seeker", + ma_advisory_swarm = MAAdvisorySwarm( + name="AI-Powered M&A Advisory System", + description="Comprehensive AI-driven M&A advisory and market intelligence platform", + user_name="Corporate Development Team", output_type="json", max_loops=1, ) # Run the swarm print("\n" + "="*60) - print("INITIALIZING JOB SEARCH SWARM") + print("INITIALIZING M&A ADVISORY SWARM") print("="*60 + "\n") - job_search_swarm.run(initial_user_input=user_requirements) + ma_advisory_swarm.run(initial_user_input=transaction_details) if __name__ == "__main__": main() diff --git a/examples/demos/apps/job_finding.py b/examples/demos/apps/job_finding.py index 910f0b14..97174f63 100644 --- a/examples/demos/apps/job_finding.py +++ b/examples/demos/apps/job_finding.py @@ -1,79 +1,9 @@ from typing import List -import os -from dotenv import load_dotenv from loguru import logger -import httpx from swarms.structs.agent import Agent from swarms.structs.conversation import Conversation from swarms.utils.history_output_formatter import history_output_formatter -from swarms.utils.any_to_str import any_to_str - -# --- Exa Search Tool Integration --- -def exa_search( - query: str, - characters: int = 500, - sources: int = 3, -) -> str: - """ - Perform a highly summarized Exa web search for job listings and career information. - - Args: - query (str): Search query for jobs or career info. - characters (int): Max characters for summary. - sources (int): Number of sources. - - Returns: - str: Condensed summary of search results. - """ - api_key = os.getenv("EXA_API_KEY") - if not api_key: - raise ValueError("EXA_API_KEY environment variable is not set") - - headers = { - "x-api-key": api_key, - "content-type": "application/json", - } - - payload = { - "query": query, - "type": "auto", - "numResults": sources, - "contents": { - "text": True, - "summary": { - "schema": { - "type": "object", - "required": ["answer"], - "additionalProperties": False, - "properties": { - "answer": { - "type": "string", - "description": "Highly condensed summary of the search result", - } - }, - } - }, - "context": {"maxCharacters": characters}, - }, - } - - try: - logger.info(f"[SEARCH] Exa job search: {query[:50]}...") - response = httpx.post( - "https://api.exa.ai/search", - json=payload, - headers=headers, - timeout=30, - ) - response.raise_for_status() - json_data = response.json() - return any_to_str(json_data) - except Exception as e: - logger.error(f"Exa search failed: {e}") - return f"Search failed: {str(e)}. Please try again." - -# Load environment variables -load_dotenv() +from swarms_tools import exa_search # System prompts for each agent From 8b2113516d3981c50ebf8c825bce4864e79d007f Mon Sep 17 00:00:00 2001 From: Aksh Parekh Date: Thu, 2 Oct 2025 18:20:56 -0700 Subject: [PATCH 3/8] Update job_finding.md --- docs/examples/job_finding.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/docs/examples/job_finding.md b/docs/examples/job_finding.md index 65782723..21e44487 100644 --- a/docs/examples/job_finding.md +++ b/docs/examples/job_finding.md @@ -23,14 +23,6 @@ To run the AI Job Search Swarm, you'll need to set up your Python environment an * Python 3.8+ * An Exa API Key -### Installation Steps - - The `job_finding.py` script relies on several libraries. These can be installed using the `requirements.txt` file located at the root of the project. - ```bash - pip install -r requirements.txt - ``` - This will install `httpx`, `python-dotenv`, `loguru`, and other necessary packages. - ### API Key Configuration The `exa_search` tool used by the Search Executor Agent requires an `EXA_API_KEY`. @@ -659,4 +651,4 @@ To get the most out of the AI Job Search Swarm: * **Prompt Engineering Dependency**: The quality of the search results heavily depends on the clarity and effectiveness of the agent `system_prompt`s and the initial user input. * **Exa Search Scope**: The `exa_search` tool's effectiveness is tied to the breadth and depth of Exa's indexed web content. * **Iteration Control**: The current `end` method in `examples/demos/apps/job_finding.py` is simplified for demonstration. A robust production system would require a more sophisticated user interaction mechanism to determine when to stop or refine the search. -* **Verification Needed**: All AI-generated outputs, including job matches and summaries, should be independently verified by the user. \ No newline at end of file +* **Verification Needed**: All AI-generated outputs, including job matches and summaries, should be independently verified by the user. From b2794323e13aa1417383d3e0c996bb528cabddc0 Mon Sep 17 00:00:00 2001 From: Aksh Parekh Date: Fri, 3 Oct 2025 19:39:20 -0700 Subject: [PATCH 4/8] Update job_finding.md --- docs/examples/job_finding.md | 62 ++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/docs/examples/job_finding.md b/docs/examples/job_finding.md index 21e44487..8901038f 100644 --- a/docs/examples/job_finding.md +++ b/docs/examples/job_finding.md @@ -1,50 +1,50 @@ -# AI Job Search Swarm +# Job Finding Swarm ## Overview -The AI Job Search Swarm is an intelligent multi-agent system designed to automate and streamline the job search process using the Swarms framework. It leverages specialized AI agents to analyze user requirements, execute comprehensive job searches, and curate relevant opportunities, transforming traditional job hunting into an intelligent, collaborative process. +The Job Finding Swarm is an intelligent multi-agent system designed to automate and streamline the job search process using the Swarms framework. It leverages specialized AI agents to analyze user requirements, execute comprehensive job searches, and curate relevant opportunities, transforming traditional job hunting into an intelligent, collaborative process. ## Key Components -The Job Search Swarm consists of three specialized agents, each responsible for a critical stage of the job search process: +The Job Finding Swarm consists of three specialized agents, each responsible for a critical stage of the job search process: -| Agent Name | Role | Responsibilities | -| :------------------------ | :--------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------- | -| **Sarah-Requirements-Analyzer** | Extracts and clarifies job search requirements. | Engages with the user to understand job titles, skills, locations, salary, company preferences, experience level, work authorization, and career goals. Analyzes user responses to identify key search terms, must-haves, deal-breakers, and priority factors. Generates 3-5 optimized search queries. | -| **David-Search-Executor** | Executes job searches and analyzes results for relevance. | Uses the `exa_search` tool for each query provided. Analyzes results for job title, skills, location, salary, company reputation, responsibilities, and growth opportunities. Categorizes results by match strength (Strong, Good, Moderate, Weak) and extracts key job details. | -| **Lisa-Results-Curator** | Filters, organizes, and presents job search results. | Reviews all search results. Filters and prioritizes based on match scores, user requirements, and job quality. Organizes results into "Top Recommendations," "Strong Alternatives," and "Worth Considering." Provides detailed comparisons for top recommendations and engages the user for feedback to refine the search. | +| Agent Name | Role | Responsibilities | +| :-------------------------- | :-------------------------- | :----------------------------------------------------------------------------------------------- | +| **Sarah-Requirements-Analyzer** | Clarifies requirements | Gathers and analyzes user job preferences; generates 3-5 search queries. | +| **David-Search-Executor** | Runs job searches | Uses `exa_search` for each query; analyzes and categorizes job results by match strength. | +| **Lisa-Results-Curator** | Organizes results | Filters, prioritizes, and presents jobs; provides top picks and refines search with user input. | -## Installation - -To run the AI Job Search Swarm, you'll need to set up your Python environment and configure necessary API keys. +## Step 1: Setup and Installation ### Prerequisites -* Python 3.8+ -* An Exa API Key +| Requirement | +|-----------------------| +| Python 3.8 or higher | +| pip package manager | -### API Key Configuration +1. **Install dependencies:** + Use the following command to download all dependencies. + ```bash + # Install Swarms framework + pip install swarms -The `exa_search` tool used by the Search Executor Agent requires an `EXA_API_KEY`. + # Install environment and logging dependencies + pip install python-dotenv loguru -1. **Obtain an Exa API Key**: Visit [Exa AI](https://exa.ai/) to get your API key. -2. **Create a `.env` file**: In the root directory of your project, create a file named `.env` and add your Exa API key to it: + # Install HTTP client and tools + pip install httpx swarms_tools ``` - EXA_API_KEY="your_exa_api_key_here" +2. **Set up API Keys:** + The `Property Research Agent` utilizes the `exa_search` tool, which requires an `EXA_API_KEY`. + Create a `.env` file in the root directory of your project (or wherever your application loads environment variables) and add your API keys: ``` - Replace `"your_exa_api_key_here"` with your actual Exa API Key. The `python-dotenv` library will automatically load this key into your environment. - -## Example Usage - -To run the job search swarm, execute the `job_finding.py` script from your terminal. - -```bash -python examples/demos/apps/job_finding.py -``` - -The script is designed to run with a pre-filled user requirement for demonstration purposes. You can modify the `user_requirements` string in the `main()` function within `examples/demos/apps/job_finding.py` to test different job search scenarios. + EXA_API_KEY="YOUR_EXA_API_KEY" + OPENAI_API_KEY="OPENAI_API_KEY" + ``` + Replace `"YOUR_EXA_API_KEY"` & `"OPENAI_API_KEY"` with your actual API keys. -**Example User Requirements (from `main()` function):** +## Step 2: Running the Job Finding Swarm ```python from typing import List @@ -639,7 +639,7 @@ You can customize the `JobSearchSwarm` by modifying the `JobSearchSwarm` class p ## Best Practices -To get the most out of the AI Job Search Swarm: +To get the most out of the AI Job Finding Swarm: * **Provide Clear Requirements**: Start with a detailed and unambiguous `initial_user_input` to help the Requirements Analyzer generate effective queries. * **Iterate and Refine**: In a live application, leverage the user feedback loop to continuously refine search criteria and improve result relevance. From 78f10e648e85d210efcdd5526e638c8f98af755a Mon Sep 17 00:00:00 2001 From: Aksh Parekh Date: Tue, 7 Oct 2025 17:52:36 -0700 Subject: [PATCH 5/8] Update mkdocs.yml --- docs/mkdocs.yml | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index c16159d1..d154c6b1 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -92,8 +92,6 @@ extra: "Tools": - title: "Tools and MCP" url: "https://docs.swarms.world/en/latest/swarms/tools/tools_examples/" - - title: "MCP (Model Context Protocol)" - url: "https://docs.swarms.world/en/latest/swarms/examples/agent_with_mcp/" - title: "OpenAI Tools & Function Calling" url: "https://docs.swarms.world/en/latest/swarms/examples/agent_structured_outputs/" - title: "Web Search (Exa, Serper)" @@ -114,8 +112,6 @@ extra: url: "https://docs.swarms.world/en/latest/examples/templates/" - title: "Financial Analysis Swarms" url: "https://docs.swarms.world/en/latest/swarms/examples/swarms_api_finance/" - - title: "Deep Research Swarm" - url: "https://docs.swarms.world/en/latest/swarms/structs/deep_research_swarm/" - title: "Medical Diagnosis Systems" url: "https://docs.swarms.world/en/latest/swarms/examples/swarms_api_medical/" - title: "DAO Governance" @@ -282,7 +278,6 @@ nav: - ForestSwarm: "swarms/structs/forest_swarm.md" - MALT: "swarms/structs/malt.md" - Multi-Agent Execution Utilities: "swarms/structs/various_execution_methods.md" - - Deep Research Swarm: "swarms/structs/deep_research_swarm.md" - Council of Judges: "swarms/structs/council_of_judges.md" - Heavy Swarm: "swarms/structs/heavy_swarm.md" @@ -290,7 +285,6 @@ nav: - Overview: "swarms/structs/multi_swarm_orchestration.md" - HierarchicalSwarm: "swarms/structs/hierarchical_swarm.md" - Hierarchical Structured Communication Framework: "swarms/structs/hierarchical_structured_communication_framework.md" - - Auto Agent Builder: "swarms/structs/auto_agent_builder.md" - Hybrid Hierarchical-Cluster Swarm: "swarms/structs/hhcs.md" - Auto Swarm Builder: "swarms/structs/auto_swarm_builder.md" - Swarm Matcher: "swarms/structs/swarm_matcher.md" @@ -302,6 +296,7 @@ nav: - MultiAgentRouter: "swarms/structs/multi_agent_router.md" - ModelRouter: "swarms/structs/model_router.md" + - Rearrangers: - SwarmRearrange: "swarms/structs/swarm_rearrange.md" - AgentRearrange: "swarms/structs/agent_rearrange.md" @@ -327,7 +322,6 @@ nav: - Overview: "swarms_tools/overview.md" - BaseTool Reference: "swarms/tools/base_tool.md" - MCP Client Utils: "swarms/tools/mcp_client_call.md" - - MCP Agent Tool: "swarms/tools/mcp_agent_tool.md" - Vertical Tools: - Finance: "swarms_tools/finance.md" @@ -345,6 +339,10 @@ nav: - Deploy on Google Cloud Run: "swarms_cloud/cloud_run.md" - Deploy on Phala: "swarms_cloud/phala_deploy.md" - Deploy on Cloudflare Workers: "swarms_cloud/cloudflare_workers.md" + - Agent Orchestration Protocol (AOP): + - AOP Reference: "swarms/structs/aop.md" + - AOP Server Setup: "swarms/examples/aop_server_example.md" + - AOP Cluster Example: "swarms/examples/aop_cluster_example.md" - Examples: @@ -373,7 +371,6 @@ nav: - Agent with Gemini Nano Banana: "swarms/examples/jarvis_agent.md" - LLM Providers: - Language Models: - - How to Create A Custom Language Model: "swarms/models/custom_model.md" - Overview: "swarms/examples/model_providers.md" - OpenAI: "swarms/examples/openai_example.md" - Anthropic: "swarms/examples/claude.md" @@ -387,10 +384,6 @@ nav: - VLLM: "swarms/examples/vllm_integration.md" - Llama4: "swarms/examples/llama4.md" - Custom Base URL & API Keys: "swarms/examples/custom_base_url_example.md" - - MultiModal Models: - - BaseMultiModalModel: "swarms/models/base_multimodal_model.md" - - Multi Modal Models Available: "swarms/models/multimodal_models.md" - - GPT4VisionAPI: "swarms/models/gpt4v.md" @@ -417,19 +410,16 @@ nav: - Hiearchical Marketing Team: "examples/marketing_team.md" - Gold ETF Research with HeavySwarm: "examples/gold_etf_research.md" - Hiring Swarm: "examples/hiring_swarm.md" - - Real Estate Swarm: "examples/realestate_swarm.md" - - Job Finding Swarm: "examples/job_finding.md" + - Advanced Research: "examples/av.md" - Tools & Integrations: - Web Search with Exa: "examples/exa_search.md" - - Advanced Research: "examples/av.md" - Browser Use: "examples/browser_use.md" - Yahoo Finance: "swarms/examples/yahoo_finance.md" - Firecrawl: "developer_guides/firecrawl.md" - MCP: - Multi-MCP Agent Integration: "swarms/examples/multi_mcp_agent.md" - - Agent With MCP Integration: "swarms/examples/agent_with_mcp.md" - RAG: - RAG with Qdrant: "swarms/RAG/qdrant_rag.md" From 05f4d5f5894c3d0704129b642bd96de9e1111847 Mon Sep 17 00:00:00 2001 From: Aksh Parekh Date: Tue, 7 Oct 2025 17:54:19 -0700 Subject: [PATCH 6/8] Update mkdocs.yml --- docs/mkdocs.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index d154c6b1..7e849302 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -428,6 +428,9 @@ nav: - Web Scraper Agents: "developer_guides/web_scraper.md" - Smart Database: "examples/smart_database.md" + - AOP: + - Medical AOP Example: "examples/aop_medical.md" + - Swarms Cloud API: - Overview: "swarms_cloud/migration.md" From 6b53a6f97521700d8e2577c0942b2e1b55dd7120 Mon Sep 17 00:00:00 2001 From: Aksh Parekh Date: Tue, 7 Oct 2025 18:06:17 -0700 Subject: [PATCH 8/8] Delete docs/examples/job_finding.md --- docs/examples/job_finding.md | 654 ----------------------------------- 1 file changed, 654 deletions(-) delete mode 100644 docs/examples/job_finding.md diff --git a/docs/examples/job_finding.md b/docs/examples/job_finding.md deleted file mode 100644 index 8901038f..00000000 --- a/docs/examples/job_finding.md +++ /dev/null @@ -1,654 +0,0 @@ -# Job Finding Swarm - -## Overview - -The Job Finding Swarm is an intelligent multi-agent system designed to automate and streamline the job search process using the Swarms framework. It leverages specialized AI agents to analyze user requirements, execute comprehensive job searches, and curate relevant opportunities, transforming traditional job hunting into an intelligent, collaborative process. - -## Key Components - -The Job Finding Swarm consists of three specialized agents, each responsible for a critical stage of the job search process: - -| Agent Name | Role | Responsibilities | -| :-------------------------- | :-------------------------- | :----------------------------------------------------------------------------------------------- | -| **Sarah-Requirements-Analyzer** | Clarifies requirements | Gathers and analyzes user job preferences; generates 3-5 search queries. | -| **David-Search-Executor** | Runs job searches | Uses `exa_search` for each query; analyzes and categorizes job results by match strength. | -| **Lisa-Results-Curator** | Organizes results | Filters, prioritizes, and presents jobs; provides top picks and refines search with user input. | - -## Step 1: Setup and Installation - -### Prerequisites - -| Requirement | -|-----------------------| -| Python 3.8 or higher | -| pip package manager | - -1. **Install dependencies:** - Use the following command to download all dependencies. - ```bash - # Install Swarms framework - pip install swarms - - # Install environment and logging dependencies - pip install python-dotenv loguru - - # Install HTTP client and tools - pip install httpx swarms_tools - ``` -2. **Set up API Keys:** - The `Property Research Agent` utilizes the `exa_search` tool, which requires an `EXA_API_KEY`. - Create a `.env` file in the root directory of your project (or wherever your application loads environment variables) and add your API keys: - ``` - EXA_API_KEY="YOUR_EXA_API_KEY" - OPENAI_API_KEY="OPENAI_API_KEY" - ``` - Replace `"YOUR_EXA_API_KEY"` & `"OPENAI_API_KEY"` with your actual API keys. - -## Step 2: Running the Job Finding Swarm - -```python -from typing import List -from loguru import logger -from swarms.structs.agent import Agent -from swarms.structs.conversation import Conversation -from swarms.utils.history_output_formatter import history_output_formatter -from swarms_tools import exa_search - -# System prompts for each agent -INTAKE_AGENT_PROMPT = """ -You are an M&A Intake Specialist responsible for gathering comprehensive information about a potential transaction. - -ROLE: -Engage with the user to understand the full context of the potential M&A deal, extracting critical details that will guide subsequent analyses. - -RESPONSIBILITIES: -- Conduct a thorough initial interview to understand: - * Transaction type (acquisition, merger, divestiture) - * Industry and sector specifics - * Target company profile and size - * Strategic objectives - * Buyer/seller perspective - * Timeline and urgency - * Budget constraints - * Specific concerns or focus areas - -OUTPUT FORMAT: -Provide a comprehensive Deal Brief that includes: -1. Transaction Overview - - Proposed transaction type - - Key parties involved - - Initial strategic rationale - -2. Stakeholder Context - - Buyer's background and motivations - - Target company's current position - - Key decision-makers - -3. Initial Assessment - - Preliminary strategic fit - - Potential challenges or red flags - - Recommended focus areas for deeper analysis - -4. Information Gaps - - Questions that need further clarification - - Additional data points required - -IMPORTANT: -- Be thorough and systematic -- Ask probing questions to uncover nuanced details -- Maintain a neutral, professional tone -- Prepare a foundation for subsequent in-depth analysis -""" - -MARKET_ANALYSIS_PROMPT = """ -You are an M&A Market Intelligence Analyst tasked with conducting comprehensive market research. - -ROLE: -Perform an in-depth analysis of market dynamics, competitive landscape, and strategic implications for the potential transaction. - -TOOLS: -You have access to the exa_search tool for gathering real-time market intelligence. - -RESPONSIBILITIES: -1. Conduct Market Research - - Use exa_search to gather current market insights - - Analyze industry trends, size, and growth potential - - Identify key players and market share distribution - -2. Competitive Landscape Analysis - - Map out competitive ecosystem - - Assess target company's market positioning - - Identify potential competitive advantages or vulnerabilities - -3. Strategic Fit Evaluation - - Analyze alignment with buyer's strategic objectives - - Assess potential market entry or expansion opportunities - - Evaluate potential for market disruption - -4. External Factor Assessment - - Examine regulatory environment - - Analyze technological disruption potential - - Consider macroeconomic impacts - -OUTPUT FORMAT: -Provide a comprehensive Market Analysis Report: -1. Market Overview - - Market size and growth trajectory - - Key industry trends - - Competitive landscape summary - -2. Strategic Fit Assessment - - Market attractiveness score (1-10) - - Strategic alignment evaluation - - Potential synergies and opportunities - -3. Risk and Opportunity Mapping - - Key market opportunities - - Potential competitive threats - - Regulatory and technological risk factors - -4. Recommended Next Steps - - Areas requiring deeper investigation - - Initial strategic recommendations -""" - -FINANCIAL_VALUATION_PROMPT = """ -You are an M&A Financial Analysis and Risk Expert. Perform comprehensive financial evaluation and risk assessment. - -RESPONSIBILITIES: -1. Financial Health Analysis - - Analyze revenue trends and quality - - Evaluate profitability metrics (EBITDA, margins) - - Conduct cash flow analysis - - Assess balance sheet strength - - Review working capital requirements - -2. Valuation Analysis - - Perform comparable company analysis - - Conduct precedent transaction analysis - - Develop Discounted Cash Flow (DCF) model - - Assess asset-based valuation - -3. Synergy and Risk Assessment - - Quantify potential revenue and cost synergies - - Identify financial and operational risks - - Evaluate integration complexity - - Assess potential deal-breakers - -OUTPUT FORMAT: -1. Comprehensive Financial Analysis Report -2. Valuation Range (low, mid, high scenarios) -3. Synergy Potential Breakdown -4. Detailed Risk Matrix -5. Recommended Pricing Strategy -""" - -DEAL_STRUCTURING_PROMPT = """ -You are an M&A Deal Structuring Advisor. Recommend the optimal transaction structure. - -RESPONSIBILITIES: -1. Transaction Structure Design - - Evaluate asset vs stock purchase options - - Analyze cash vs stock consideration - - Design earnout provisions - - Develop contingent payment structures - -2. Financing Strategy - - Recommend debt/equity mix - - Identify optimal financing sources - - Assess impact on buyer's capital structure - -3. Tax and Legal Optimization - - Design tax-efficient structure - - Consider jurisdictional implications - - Minimize tax liabilities - -4. Deal Protection Mechanisms - - Develop escrow arrangements - - Design representations and warranties - - Create indemnification provisions - - Recommend non-compete agreements - -OUTPUT FORMAT: -1. Recommended Deal Structure -2. Detailed Payment Terms -3. Key Contractual Protections -4. Tax Optimization Strategy -5. Rationale for Proposed Structure -""" - -INTEGRATION_PLANNING_PROMPT = """ -You are an M&A Integration Planning Expert. Develop a comprehensive post-merger integration roadmap. - -RESPONSIBILITIES: -1. Immediate Integration Priorities - - Define critical day-1 actions - - Develop communication strategy - - Identify quick win opportunities - -2. 100-Day Integration Plan - - Design organizational structure alignment - - Establish governance framework - - Create detailed integration milestones - -3. Functional Integration Strategy - - Plan operations consolidation - - Design systems and technology integration - - Align sales and marketing approaches - - Develop cultural integration plan - -4. Synergy Realization - - Create detailed synergy capture timeline - - Establish performance tracking mechanisms - - Define accountability framework - -OUTPUT FORMAT: -1. Comprehensive Integration Roadmap -2. Detailed 100-Day Plan -3. Functional Integration Strategies -4. Synergy Realization Timeline -5. Risk Mitigation Recommendations -""" - -FINAL_RECOMMENDATION_PROMPT = """ -You are the Senior M&A Advisory Partner. Synthesize all analyses into a comprehensive recommendation. - -RESPONSIBILITIES: -1. Executive Summary - - Summarize transaction overview - - Highlight strategic rationale - - Articulate key value drivers - -2. Investment Thesis Validation - - Assess strategic benefits - - Evaluate financial attractiveness - - Project long-term potential - -3. Comprehensive Risk Assessment - - Summarize top risks - - Provide mitigation strategies - - Identify potential deal-breakers - -4. Final Recommendation - - Provide clear GO/NO-GO recommendation - - Specify recommended offer range - - Outline key proceeding conditions - -OUTPUT FORMAT: -1. Executive-Level Recommendation Report -2. Decision Framework -3. Risk-Adjusted Strategic Perspective -4. Actionable Next Steps -5. Recommendation Confidence Level -""" - -class MAAdvisorySwarm: - def __init__( - self, - name: str = "M&A Advisory Swarm", - description: str = "Comprehensive AI-driven M&A advisory system", - max_loops: int = 1, - user_name: str = "M&A Advisor", - output_type: str = "json", - ): - self.max_loops = max_loops - self.name = name - self.description = description - self.user_name = user_name - self.output_type = output_type - - self.agents = self._initialize_agents() - self.conversation = Conversation() - self.exa_search_results = [] - self.search_queries = [] - self.current_iteration = 0 - self.max_iterations = 1 # Limiting to 1 iteration for full sequential demo - self.analysis_concluded = False - - self.handle_initial_processing() - - def handle_initial_processing(self): - self.conversation.add( - role="System", - content=f"Company: {self.name}\n" - f"Description: {self.description}\n" - f"Mission: Provide comprehensive M&A advisory for {self.user_name}" - ) - - def _initialize_agents(self) -> List[Agent]: - return [ - Agent( - agent_name="Emma-Intake-Specialist", - agent_description="Gathers comprehensive initial information about the potential M&A transaction.", - system_prompt=INTAKE_AGENT_PROMPT, - max_loops=self.max_loops, - dynamic_temperature_enabled=True, - output_type="final", - ), - Agent( - agent_name="Marcus-Market-Analyst", - agent_description="Conducts in-depth market research and competitive analysis.", - system_prompt=MARKET_ANALYSIS_PROMPT, - max_loops=self.max_loops, - dynamic_temperature_enabled=True, - output_type="final", - ), - Agent( - agent_name="Sophia-Financial-Analyst", - agent_description="Performs comprehensive financial valuation and risk assessment.", - system_prompt=FINANCIAL_VALUATION_PROMPT, - max_loops=self.max_loops, - dynamic_temperature_enabled=True, - output_type="final", - ), - Agent( - agent_name="David-Deal-Structuring-Advisor", - agent_description="Recommends optimal deal structure and terms.", - system_prompt=DEAL_STRUCTURING_PROMPT, - max_loops=self.max_loops, - dynamic_temperature_enabled=True, - output_type="final", - ), - Agent( - agent_name="Nathan-Integration-Planner", - agent_description="Develops comprehensive post-merger integration roadmap.", - system_prompt=INTEGRATION_PLANNING_PROMPT, - max_loops=self.max_loops, - dynamic_temperature_enabled=True, - output_type="final", - ), - Agent( - agent_name="Alex-Final-Recommendation-Partner", - agent_description="Synthesizes all analyses into a comprehensive recommendation.", - system_prompt=FINAL_RECOMMENDATION_PROMPT, - max_loops=self.max_loops, - dynamic_temperature_enabled=True, - output_type="final", - ) - ] - - def find_agent_by_name(self, name: str) -> Agent: - for agent in self.agents: - if name in agent.agent_name: - return agent - return None - - def intake_and_scoping(self, user_input: str): - """Phase 1: Intake and initial deal scoping""" - emma_agent = self.find_agent_by_name("Intake-Specialist") - - emma_output = emma_agent.run( - f"User Input: {user_input}\n\n" - f"Conversation History: {self.conversation.get_str()}\n\n" - f"Analyze the potential M&A transaction, extract key details, and prepare a comprehensive deal brief. " - f"If information is unclear, ask clarifying questions." - ) - - self.conversation.add( - role="Intake-Specialist", content=emma_output - ) - - # Extract potential search queries for market research - self.search_queries = self._extract_search_queries(emma_output) - - return emma_output - - def _extract_search_queries(self, intake_output: str) -> List[str]: - """Extract search queries from Intake Specialist output""" - queries = [] - lines = intake_output.split('\n') - - # Look for lines that could be good search queries - for line in lines: - line = line.strip() - # Simple heuristic: lines with potential research keywords - if any(keyword in line.lower() for keyword in ['market', 'industry', 'trend', 'competitor', 'analysis']): - if len(line) > 20: # Ensure query is substantial - queries.append(line) - - # Fallback queries if none found - if not queries: - queries = [ - "M&A trends in technology sector", - "Market analysis for potential business acquisition", - "Competitive landscape in enterprise software" - ] - - return queries[:3] # Limit to 3 queries - - def market_research(self): - """Phase 2: Conduct market research using exa_search""" - # Execute exa_search for each query - self.exa_search_results = [] - for query in self.search_queries: - result = exa_search(query) - self.exa_search_results.append({ - "query": query, - "exa_result": result - }) - - # Pass results to Market Analysis agent - marcus_agent = self.find_agent_by_name("Market-Analyst") - - # Build exa context - exa_context = "\n\n[Exa Market Research Results]\n" - for item in self.exa_search_results: - exa_context += f"Query: {item['query']}\nResults: {item['exa_result']}\n\n" - - marcus_output = marcus_agent.run( - f"Conversation History: {self.conversation.get_str()}\n\n" - f"{exa_context}\n" - f"Analyze these market research results. Provide comprehensive market intelligence and strategic insights." - ) - - self.conversation.add( - role="Market-Analyst", content=marcus_output - ) - - return marcus_output - - def financial_valuation(self): - """Phase 3: Perform comprehensive financial valuation and risk assessment""" - sophia_agent = self.find_agent_by_name("Financial-Analyst") - - sophia_output = sophia_agent.run( - f"Conversation History: {self.conversation.get_str()}\n\n" - f"Perform comprehensive financial analysis and risk assessment based on previous insights." - ) - - self.conversation.add( - role="Financial-Analyst", content=sophia_output - ) - - return sophia_output - - def deal_structuring(self): - """Phase 4: Recommend optimal deal structure""" - david_agent = self.find_agent_by_name("Deal-Structuring-Advisor") - - david_output = david_agent.run( - f"Conversation History: {self.conversation.get_str()}\n\n" - f"Recommend the optimal transaction structure and terms based on all prior analyses." - ) - - self.conversation.add( - role="Deal-Structuring-Advisor", content=david_output - ) - - return david_output - - def integration_planning(self): - """Phase 5: Develop post-merger integration roadmap""" - nathan_agent = self.find_agent_by_name("Integration-Planner") - - nathan_output = nathan_agent.run( - f"Conversation History: {self.conversation.get_str()}\n\n" - f"Create a comprehensive integration plan to realize deal value." - ) - - self.conversation.add( - role="Integration-Planner", content=nathan_output - ) - - return nathan_output - - def final_recommendation(self): - """Phase 6: Synthesize all analyses into a comprehensive recommendation""" - alex_agent = self.find_agent_by_name("Final-Recommendation-Partner") - - alex_output = alex_agent.run( - f"Conversation History: {self.conversation.get_str()}\n\n" - f"Synthesize all agent analyses into a comprehensive, actionable M&A recommendation." - ) - - self.conversation.add( - role="Final-Recommendation-Partner", content=alex_output - ) - - return alex_output - - - def run(self, initial_user_input: str): - """ - Run the M&A advisory swarm with continuous analysis. - - Args: - initial_user_input: User's initial M&A transaction details - """ - self.conversation.add(role=self.user_name, content=initial_user_input) - - while not self.analysis_concluded and self.current_iteration < self.max_iterations: - self.current_iteration += 1 - logger.info(f"Starting analysis iteration {self.current_iteration}") - - # Phase 1: Intake and Scoping - print(f"\n{'='*60}") - print("ITERATION - INTAKE AND SCOPING") - print(f"{'='*60}\n") - self.intake_and_scoping(initial_user_input) - - # Phase 2: Market Research (with exa_search) - print(f"\n{'='*60}") - print("ITERATION - MARKET RESEARCH") - print(f"{'='*60}\n") - self.market_research() - - # Phase 3: Financial Valuation - print(f"\n{'='*60}") - print("ITERATION - FINANCIAL VALUATION") - print(f"{'='*60}\n") - self.financial_valuation() - - # Phase 4: Deal Structuring - print(f"\n{'='*60}") - print("ITERATION - DEAL STRUCTURING") - print(f"{'='*60}\n") - self.deal_structuring() - - # Phase 5: Integration Planning - print(f"\n{'='*60}") - print("ITERATION - INTEGRATION PLANNING") - print(f"{'='*60}\n") - self.integration_planning() - - # Phase 6: Final Recommendation - print(f"\n{'='*60}") - print("ITERATION - FINAL RECOMMENDATION") - print(f"{'='*60}\n") - self.final_recommendation() - - # Conclude analysis after one full sequence for demo purposes - self.analysis_concluded = True - - # Return formatted conversation history - return history_output_formatter( - self.conversation, type=self.output_type - ) - -def main(): - """Main entry point for M&A advisory swarm""" - - # Example M&A transaction details - transaction_details = """ - We are exploring a potential acquisition of DataPulse Analytics by TechNova Solutions. - - Transaction Context: - - Buyer: TechNova Solutions (NASDAQ: TNVA) - $500M annual revenue enterprise software company - - Target: DataPulse Analytics - Series B AI-driven analytics startup based in San Francisco - - Primary Objectives: - * Expand predictive analytics capabilities in healthcare and financial services - * Accelerate AI-powered business intelligence product roadmap - * Acquire top-tier machine learning engineering talent - - Key Considerations: - - Deep integration of DataPulse's proprietary AI models into TechNova's existing platform - - Retention of key DataPulse leadership and engineering team - - Projected 3-year ROI and synergy potential - - Regulatory and compliance alignment - - Technology stack compatibility - """ - - # Initialize the swarm - ma_advisory_swarm = MAAdvisorySwarm( - name="AI-Powered M&A Advisory System", - description="Comprehensive AI-driven M&A advisory and market intelligence platform", - user_name="Corporate Development Team", - output_type="json", - max_loops=1, - ) - - # Run the swarm - print("\n" + "="*60) - print("INITIALIZING M&A ADVISORY SWARM") - print("="*60 + "\n") - - ma_advisory_swarm.run(initial_user_input=transaction_details) - -if __name__ == "__main__": - main() -``` - -Upon execution, the swarm will: -1. Analyze the provided `user_requirements`. -2. Generate and execute search queries using Exa. -3. Curate and present the results in a structured format, including top recommendations and a prompt for user feedback. - -The output will be printed to the console, showing the progression of the agents through each phase of the job search. - -## Workflow Stages - -The `JobSearchSwarm` processes the job search through a continuous, iterative workflow: - -1. **Phase 1: Analyze Requirements (`analyze_requirements`)**: The `Sarah-Requirements-Analyzer` agent processes the user's input and conversation history to extract job criteria and generate optimized search queries. -2. **Phase 2: Execute Searches (`execute_searches`)**: The `David-Search-Executor` agent takes the generated queries, uses the `exa_search` tool to find job listings, and analyzes their relevance against the user's requirements. -3. **Phase 3: Curate Results (`curate_results`)**: The `Lisa-Results-Curator` agent reviews, filters, and organizes the search results, presenting top recommendations and asking for user feedback to guide further iterations. -4. **Phase 4: Get User Feedback (`end`)**: In a full implementation, this stage gathers explicit user feedback to determine if the search needs refinement or can be concluded. For demonstration, this is a simulated step. - -The swarm continues these phases in a loop until the `search_concluded` flag is set to `True` or `max_iterations` is reached. - -## Customization - -You can customize the `JobSearchSwarm` by modifying the `JobSearchSwarm` class parameters or the agents' prompts: - -* **`name` and `description`**: Customize the swarm's identity. -* **`user_name`**: Define the name of the user interacting with the swarm. -* **`output_type`**: Specify the desired output format for the conversation history (e.g., "json" or "list"). -* **`max_loops`**: Control the number of internal reasoning iterations each agent performs (set during agent initialization). -* **`system_prompt`**: Modify the `REQUIREMENTS_ANALYZER_PROMPT`, `SEARCH_EXECUTOR_PROMPT`, and `RESULTS_CURATOR_PROMPT` to refine agent behavior and output. -* **`max_iterations`**: Limit the total number of search cycles the swarm performs. - -## Best Practices - -To get the most out of the AI Job Finding Swarm: - -* **Provide Clear Requirements**: Start with a detailed and unambiguous `initial_user_input` to help the Requirements Analyzer generate effective queries. -* **Iterate and Refine**: In a live application, leverage the user feedback loop to continuously refine search criteria and improve result relevance. -* **Monitor Agent Outputs**: Regularly review the outputs from each agent to ensure they are performing as expected and to identify areas for prompt improvement. -* **Manage API Usage**: Be mindful of your Exa API key usage, especially when experimenting with `max_iterations` or a large number of search queries. - -## Limitations - -* **Prompt Engineering Dependency**: The quality of the search results heavily depends on the clarity and effectiveness of the agent `system_prompt`s and the initial user input. -* **Exa Search Scope**: The `exa_search` tool's effectiveness is tied to the breadth and depth of Exa's indexed web content. -* **Iteration Control**: The current `end` method in `examples/demos/apps/job_finding.py` is simplified for demonstration. A robust production system would require a more sophisticated user interaction mechanism to determine when to stop or refine the search. -* **Verification Needed**: All AI-generated outputs, including job matches and summaries, should be independently verified by the user.