[2ff88f42] feat(GTM-Engine): Add final test and trigger scripts
This commit is contained in:
@@ -294,15 +294,18 @@ Gib NUR den finalen Satz aus. Keine Anführungszeichen.
|
||||
# 1. Load Definitions
|
||||
industries = self._load_industry_definitions(db)
|
||||
industry_defs = [{"name": i.name, "description": i.description} for i in industries]
|
||||
logger.debug(f"Loaded {len(industries)} industry definitions.")
|
||||
|
||||
# 2. Get Content (Website)
|
||||
website_content, _ = self._get_website_content_and_url(company)
|
||||
|
||||
if not website_content:
|
||||
logger.warning(f"No website content for {company.name}. Skipping classification.")
|
||||
if not website_content or len(website_content) < 100:
|
||||
logger.warning(f"No or insufficient website content for {company.name} (Length: {len(website_content) if website_content else 0}). Skipping classification.")
|
||||
return company
|
||||
logger.debug(f"Website content length for classification: {len(website_content)}")
|
||||
|
||||
# 3. Classify Industry
|
||||
logger.info(f"Running LLM classification prompt for {company.name}...")
|
||||
suggested_industry_name = self._run_llm_classification_prompt(website_content, company.name, industry_defs)
|
||||
logger.info(f"AI suggests industry: {suggested_industry_name}")
|
||||
|
||||
@@ -311,32 +314,47 @@ Gib NUR den finalen Satz aus. Keine Anführungszeichen.
|
||||
|
||||
if matched_industry:
|
||||
company.industry_ai = matched_industry.name
|
||||
logger.info(f"Matched company to industry: {matched_industry.name}")
|
||||
|
||||
# --- Generate PRIMARY Opener (Infrastructure/Cleaning) ---
|
||||
logger.info(f"Generating PRIMARY opener for {company.name}...")
|
||||
op_prim = self._generate_marketing_opener(
|
||||
company.name, website_content, matched_industry.name, matched_industry.pains, "primary"
|
||||
)
|
||||
if op_prim:
|
||||
company.ai_opener = op_prim
|
||||
logger.info(f"Opener (Primary): {op_prim}")
|
||||
logger.info(f"Opener (Primary) generated and set.")
|
||||
else:
|
||||
logger.warning(f"Failed to generate PRIMARY opener for {company.name}.")
|
||||
|
||||
# --- Generate SECONDARY Opener (Service/Logistics) ---
|
||||
# Only if relevant (could be optimized, but generating always is safer for "Dual Strategy")
|
||||
logger.info(f"Generating SECONDARY opener for {company.name}...")
|
||||
op_sec = self._generate_marketing_opener(
|
||||
company.name, website_content, matched_industry.name, matched_industry.pains, "secondary"
|
||||
)
|
||||
if op_sec:
|
||||
company.ai_opener_secondary = op_sec
|
||||
logger.info(f"Opener (Secondary): {op_sec}")
|
||||
logger.info(f"Opener (Secondary) generated and set.")
|
||||
else:
|
||||
logger.warning(f"Failed to generate SECONDARY opener for {company.name}.")
|
||||
|
||||
else:
|
||||
company.industry_ai = "Others"
|
||||
|
||||
logger.warning(f"No specific industry matched for {company.name}. Set to 'Others'.")
|
||||
|
||||
# 5. Extract Metrics (Cascade)
|
||||
if matched_industry:
|
||||
self.extract_metrics_for_industry(company, db, matched_industry)
|
||||
logger.info(f"Extracting metrics for {company.name} and industry {matched_industry.name}...")
|
||||
try:
|
||||
self.extract_metrics_for_industry(company, db, matched_industry)
|
||||
logger.info(f"Metric extraction completed for {company.name}.")
|
||||
except Exception as e:
|
||||
logger.error(f"Error during metric extraction for {company.name}: {e}", exc_info=True)
|
||||
else:
|
||||
logger.warning(f"Skipping metric extraction for {company.name} as no specific industry was matched.")
|
||||
|
||||
company.last_classification_at = datetime.utcnow()
|
||||
db.commit()
|
||||
logger.info(f"Classification and enrichment for {company.name} completed and committed.")
|
||||
|
||||
return company
|
||||
Reference in New Issue
Block a user