From df80e37ffe59950644bfdd1accb188c48bda2d9d Mon Sep 17 00:00:00 2001 From: Floke Date: Mon, 23 Feb 2026 13:53:05 +0000 Subject: [PATCH] =?UTF-8?q?feat(opener):=20Optimiere=20Atomic=20Opener=20f?= =?UTF-8?q?=C3=BCr=20Pr=C3=A4gnanz=20und=20Direktheit=20[2ff88f42]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ü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. --- .../backend/scripts/debug_single_company.py | 46 ++++++++++++++----- .../backend/services/classification.py | 12 ++--- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/company-explorer/backend/scripts/debug_single_company.py b/company-explorer/backend/scripts/debug_single_company.py index bf469e16..9b651d3b 100644 --- a/company-explorer/backend/scripts/debug_single_company.py +++ b/company-explorer/backend/scripts/debug_single_company.py @@ -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.") diff --git a/company-explorer/backend/services/classification.py b/company-explorer/backend/services/classification.py index 17bd7710..ac630345 100644 --- a/company-explorer/backend/services/classification.py +++ b/company-explorer/backend/services/classification.py @@ -247,10 +247,10 @@ HYGIENE-BEWEISE: