feat(company-explorer-integration): Implement Company Explorer Connector and Lead Engine Sync [2f988f42]\n\nIntegrates the Company Explorer API into the Lead Engine workflow, allowing for robust company existence checks, creation, and asynchronous enrichment.\n\n- Introduced as a central client wrapper for the Company Explorer API, handling find-or-create logic, discovery, polling for website data, and analysis triggers.\n- Updated to utilize the new connector for syncing new leads with the Company Explorer.\n- Added for comprehensive unit testing of the connector logic.\n- Created as a demonstration script for the end-to-end integration.\n- Updated to document the new client integration architecture pattern.\n\nThis enhances the Lead Engine with a reliable mechanism for company data enrichment.
This commit is contained in:
79
trading_twins_tool.py
Normal file
79
trading_twins_tool.py
Normal file
@@ -0,0 +1,79 @@
|
||||
import json
|
||||
import time
|
||||
import os
|
||||
from company_explorer_connector import handle_company_workflow
|
||||
|
||||
def run_trading_twins_process(target_company_name: str):
|
||||
"""
|
||||
Startet den Trading Twins Prozess für ein Zielunternehmen.
|
||||
Ruft den Company Explorer Workflow auf, um das Unternehmen zu finden,
|
||||
zu erstellen oder anzureichern.
|
||||
"""
|
||||
print(f"\n{'='*50}")
|
||||
print(f"Starte Trading Twins Analyse für: {target_company_name}")
|
||||
print(f"{'='*50}\n")
|
||||
|
||||
# Aufruf des Company Explorer Workflows
|
||||
# Diese Funktion prüft, ob die Firma existiert.
|
||||
# Wenn nicht, erstellt sie die Firma und startet die Anreicherung.
|
||||
# Sie gibt am Ende die Daten aus dem Company Explorer zurück.
|
||||
company_data_result = handle_company_workflow(target_company_name)
|
||||
|
||||
# Verarbeitung der Rückgabe (für den POC genügt eine Ausgabe)
|
||||
print("\n--- Ergebnis vom Company Explorer Connector (für Trading Twins) ---")
|
||||
|
||||
status = company_data_result.get("status")
|
||||
data = company_data_result.get("data")
|
||||
|
||||
if status == "error":
|
||||
print(f"Ein Fehler ist aufgetreten: {company_data_result.get('message')}")
|
||||
elif status == "found":
|
||||
print(f"Unternehmen gefunden. ID: {data.get('id')}, Name: {data.get('name')}")
|
||||
print(json.dumps(data, indent=2, ensure_ascii=False))
|
||||
elif status == "created_and_enriched":
|
||||
print(f"Unternehmen erstellt und Enrichment angestoßen. ID: {data.get('id')}, Name: {data.get('name')}")
|
||||
print("Hinweis: Enrichment-Prozesse laufen im Hintergrund und können einige Zeit dauern, bis alle Daten verfügbar sind.")
|
||||
print(json.dumps(data, indent=2, ensure_ascii=False))
|
||||
elif status == "created_discovery_timeout":
|
||||
print(f"Unternehmen erstellt, aber Discovery konnte keine Website finden (ID: {data.get('id')}, Name: {data.get('name')}).")
|
||||
print("Der Analyse-Prozess wurde daher nicht gestartet.")
|
||||
print(json.dumps(data, indent=2, ensure_ascii=False))
|
||||
else:
|
||||
print("Ein unerwarteter Status ist aufgetreten.")
|
||||
print(json.dumps(company_data_result, indent=2, ensure_ascii=False))
|
||||
|
||||
print(f"\n{'='*50}")
|
||||
print(f"Trading Twins Analyse für {target_company_name} abgeschlossen.")
|
||||
print(f"{'='*50}\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Simulieren der Umgebungsvariablen für diesen Testlauf, falls nicht gesetzt
|
||||
if "COMPANY_EXPLORER_API_USER" not in os.environ:
|
||||
os.environ["COMPANY_EXPLORER_API_USER"] = "admin"
|
||||
if "COMPANY_EXPLORER_API_PASSWORD" not in os.environ:
|
||||
os.environ["COMPANY_EXPLORER_API_PASSWORD"] = "gemini"
|
||||
|
||||
# Testfall 1: Ein Unternehmen, das wahrscheinlich bereits existiert
|
||||
# Da 'Robo-Planet GmbH' bei den vorherigen Läufen erstellt wurde, sollte es jetzt gefunden werden.
|
||||
run_trading_twins_process("Robo-Planet GmbH")
|
||||
|
||||
# Kurze Pause zwischen den Testläufen
|
||||
time.sleep(5)
|
||||
|
||||
# Testfall 1b: Ein bekanntes, real existierendes Unternehmen
|
||||
run_trading_twins_process("Klinikum Landkreis Erding")
|
||||
|
||||
# Kurze Pause zwischen den Testläufen
|
||||
time.sleep(5)
|
||||
|
||||
# Testfall 2: Ein neues, eindeutiges Unternehmen
|
||||
new_unique_company_name = f"Trading Twins New Target {int(time.time())}"
|
||||
run_trading_twins_process(new_unique_company_name)
|
||||
|
||||
# Kurze Pause
|
||||
time.sleep(5)
|
||||
|
||||
# Testfall 3: Ein weiteres neues Unternehmen, um die Erstellung zu prüfen
|
||||
another_new_company_name = f"Another Demo Corp {int(time.time())}"
|
||||
run_trading_twins_process(another_new_company_name)
|
||||
Reference in New Issue
Block a user