feat(opener): Optimiere Atomic Opener für Prägnanz und Direktheit [2ff88f42]

Überarbeite den Prompt für die Generierung der Atomic Opener.
Die Opener werden nun auf genau zwei Sätze begrenzt, um Prägnanz zu gewährleisten.
Der Ton ist faktenbasierter und leitet direkter zu den operativen Herausforderungen über,
anstatt generische Lobhudelei zu verwenden.
This commit is contained in:
2026-02-23 13:53:05 +00:00
parent a0526a844e
commit df80e37ffe
2 changed files with 40 additions and 18 deletions

View File

@@ -2,11 +2,12 @@ import os
import sys
import argparse
import logging
from typing import Any # Hinzugefügt
# Add the backend directory to the Python path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
# Add the company-explorer directory to the Python path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
from backend.database import get_db, Company
from backend.database import get_db, Company, Industry, Persona # Added Industry and Persona for full context
from backend.services.classification import ClassificationService
from backend.lib.logging_setup import setup_logging
@@ -15,30 +16,41 @@ from backend.lib.logging_setup import setup_logging
setup_logging()
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger = logging.getLogger(__name__)
def run_debug_analysis(company_id: int):
def run_debug_analysis(company_identifier: Any, is_id: bool):
"""
Runs the full classification and enrichment process for a single company
in the foreground and prints detailed results.
"""
logger.info(f"--- Starting Interactive Debug for Company ID: {company_id} ---")
logger.info(f"--- Starting Interactive Debug for Company: {company_identifier} (by {'ID' if is_id else 'Name'}) ---")
db_session = next(get_db())
try:
# 1. Fetch the company
company = db_session.query(Company).filter(Company.id == company_id).first()
if is_id:
company = db_session.query(Company).filter(Company.id == company_identifier).first()
else:
company = db_session.query(Company).filter(Company.name == company_identifier).first()
if not company:
logger.error(f"Company with ID {company_id} not found.")
logger.error(f"Company with {'ID' if is_id else 'Name'} {company_identifier} not found.")
# If by name, suggest similar names
if not is_id:
all_company_names = db_session.query(Company.name).limit(20).all()
print("\nAvailable Company Names (first 20):")
for (name,) in all_company_names:
print(f"- {name}")
return
logger.info(f"Found Company: {company.name}")
logger.info(f"Found Company: {company.name} (ID: {company.id})")
# --- PRE-ANALYSIS STATE ---
print("\n--- METRICS BEFORE ---")
print(f"Calculated: {company.calculated_metric_value} {company.calculated_metric_unit}")
print(f"Standardized: {company.standardized_metric_value} {company.standardized_metric_unit}")
print(f"Opener 1 (Infra): {company.ai_opener}")
print(f"Opener 2 (Ops): {company.ai_opener_secondary}")
print("----------------------\n")
# 2. Instantiate the service
@@ -59,14 +71,24 @@ def run_debug_analysis(company_id: int):
print(f"Opener 2 (Ops): {updated_company.ai_opener_secondary}")
print("---------------------")
logger.info(f"--- Interactive Debug Finished for Company ID: {company_id} ---")
logger.info(f"--- Interactive Debug Finished for Company: {company.name} (ID: {company.id}) ---")
except Exception as e:
logger.error(f"An error occurred during analysis: {e}", exc_info=True)
finally:
db_session.close()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Run a single company analysis for debugging.")
parser.add_argument("--id", type=int, default=1, help="The ID of the company to analyze.")
parser.add_argument("--id", type=int, help="The ID of the company to analyze.")
parser.add_argument("--company-name", type=str, help="The name of the company to analyze.")
args = parser.parse_args()
run_debug_analysis(args.id)
if args.id and args.company_name:
parser.error("Please provide either --id or --company-name, not both.")
elif args.id:
run_debug_analysis(args.id, is_id=True)
elif args.company_name:
run_debug_analysis(args.company_name, is_id=False)
else:
parser.error("Please provide either --id or --company-name.")