Overview
TheLeadEngine class is the main orchestration layer of the Lead Intelligence Engine. It coordinates the entire pipeline from URL extraction through AI evaluation to CRM integration. This class handles error recovery, duplicate detection, and provides comprehensive result metadata.
Constructor
LeadEngine()
Creates a new instance of the LeadEngine with all required components initialized.Extractorinstance for content extractionEvaluatorinstance for AI-powered analysisCodaClientinstance for CRM integrationRAGinstance for knowledge retrieval
The constructor takes no parameters. All components are initialized with their default configurations.
Methods
process_url()
Processes a complete lead intelligence workflow for a given URL.The website URL to analyze. Must be a valid HTTP/HTTPS URL.
The complete evaluation result with the following fields:
Exception- If extraction fails (no content retrieved)Exception- If AI evaluation failsException- If Coda sync fails (database/CRM errors)
Usage Examples
Basic Usage
Batch Processing with Error Handling
Extracting Key Information
Pipeline Flow
Theprocess_url() method executes the following steps in sequence:
Content Extraction
Extracts text content from the URL using the Extractor component with smart fallback for SPAs and protected sites.
Knowledge Retrieval
Retrieves relevant context from the knowledge base using RAG. Continues processing even if RAG fails.
AI Evaluation
Sends extracted content and RAG context to the LLM for structured evaluation and scoring.
Error Handling
The LeadEngine implements comprehensive error handling at each pipeline stage:- Extraction Errors: Raised immediately if no content can be extracted
- RAG Failures: Logged as warnings but processing continues
- Evaluation Errors: Wrapped with contextual messages about AI service failures
- CRM Errors: Raised with detailed Coda API error information
Performance Considerations
The typical processing time for a single URL ranges from 2-5 seconds, depending on:
- URL fetch latency
- Content size and complexity
- LLM response time
- Coda API response time
_latency field in the result for actual processing time.
Related Components
- Extractor - Content extraction with smart fallback
- Evaluator - AI-powered lead evaluation
- RAG - Knowledge retrieval system
- CodaClient - CRM integration layer