diff --git a/BUILDER_APPS_MIGRATION.md b/BUILDER_APPS_MIGRATION.md index 23465aeb..f2ba044d 100644 --- a/BUILDER_APPS_MIGRATION.md +++ b/BUILDER_APPS_MIGRATION.md @@ -51,15 +51,20 @@ Das Projekt nutzt ein geteiltes `helpers.py`, das auf der alten OpenAI Python Li openai==0.28.1 # weitere deps... ### 1.5 Python Syntax & F-Strings -Multi-Line f-Strings mit JSON-Beispielen (`{...}`) sind extrem fehleranfällig (Escaping, Einrückung). -* **Best Practice:** Komplexe JSON-Daten oder Strings **vorher** in Variablen speichern und dann einfügen. +Multi-Line f-Strings sind in Docker-Umgebungen fehleranfällig. +* **Vermeide:** Ternary Operators (`... if x else ...`) innerhalb von Multi-Line f-Strings. Dies führt oft zu `SyntaxError: invalid decimal literal`. +* **Best Practice:** Nutze explizite `if/else` Blöcke zur Definition des Prompts. +* **Vermeide:** Verschachtelte JSON-Dumps (`{...}`) direkt im f-String. Nutze vorher definierte Variablen. ```python # Schlecht: - prompt = f"""Daten: {json.dumps(data.get('nested'))}""" + prompt = f"""Daten: {json.dumps(data)}""" if lang=='de' else f"""Data: ...""" # Gut: - nested_json = json.dumps(data.get('nested')) - prompt = f"""Daten: {nested_json}""" + json_data = json.dumps(data) + if lang == 'de': + prompt = f"""Daten: {json_data}""" + else: + prompt = f"""Data: {json_data}""" ``` * **Signaturen prüfen:** Shared Libraries (`helpers.py`) haben oft ältere Signaturen. * Beispiel: `call_openai_chat` unterstützt oft kein `system_message` Argument. Stattdessen Prompt manuell zusammenbauen (`sys_instr + "\n\n" + prompt`). diff --git a/gtm_architect_orchestrator.py b/gtm_architect_orchestrator.py index b1fee724..9514e886 100644 --- a/gtm_architect_orchestrator.py +++ b/gtm_architect_orchestrator.py @@ -131,7 +131,8 @@ def analyze_product(data): lang = data.get('language', 'de') sys_instr = get_system_instruction(lang) - extraction_prompt = f""" + if lang == 'en': + extraction_prompt = f""" PHASE 1-A: TECHNICAL EXTRACTION Input Product Description: "{product_input[:25000]}..." @@ -141,7 +142,9 @@ Task: 3. Create a short raw analysis summary. Output JSON format ONLY. -""" if lang == 'en' else f""" +""" + else: + extraction_prompt = f""" PHASE 1-A: TECHNICAL EXTRACTION Input Product Description: "{product_input[:25000]}..." @@ -152,15 +155,18 @@ Aufgabe: Output JSON format ONLY. """ + # Fix: Prepend system instruction manually full_extraction_prompt = sys_instr + "\n\n" + extraction_prompt + # Using response_format_json=True since helpers.py supports it (for logging/prompt hint) extraction_response = call_openai_chat(full_extraction_prompt, response_format_json=True) extraction_data = json.loads(extraction_response) features_json = json.dumps(extraction_data.get('features')) constraints_json = json.dumps(extraction_data.get('constraints')) - conflict_prompt = f""" + if lang == 'en': + conflict_prompt = f""" PHASE 1-B: PORTFOLIO CONFLICT CHECK New Product Features: {features_json} @@ -174,7 +180,9 @@ Task: Check if the new product overlaps significantly with existing ones (is it just a clone?). Output JSON format ONLY. -""" if lang == 'en' else f""" +""" + else: + conflict_prompt = f""" PHASE 1-B: PORTFOLIO CONFLICT CHECK Neue Produkt-Features: {features_json} @@ -189,6 +197,7 @@ Prüfe, ob das neue Produkt signifikant mit bestehenden Produkten überlappt (Is Output JSON format ONLY. """ + # Fix: Prepend system instruction manually full_conflict_prompt = sys_instr + "\n\n" + conflict_prompt conflict_response = call_openai_chat(full_conflict_prompt, response_format_json=True) @@ -205,7 +214,8 @@ def discover_icps(data): features_json = json.dumps(phase1_result.get('features')) constraints_json = json.dumps(phase1_result.get('constraints')) - prompt = f""" + if lang == 'en': + prompt = f""" PHASE 2: ICP DISCOVERY & DATA PROXIES Based on the product features: {features_json} And constraints: {constraints_json} @@ -215,7 +225,9 @@ Output JSON format ONLY: "icps": [ {{ "name": "Industry Name", "rationale": "Rationale" }} ], "dataProxies": [ {{ "target": "Criteria", "method": "How" }} ] }} -""" if lang == 'en' else f""" +""" + else: + prompt = f""" PHASE 2: ICP DISCOVERY & DATA PROXIES Basierend auf Features: {features_json} Und Constraints: {constraints_json} @@ -226,6 +238,7 @@ Output JSON format ONLY: "dataProxies": [ {{ "target": "Kriterium", "method": "Methode" }} ] }} """ + # Fix: Prepend system instruction manually full_prompt = sys_instr + "\n\n" + prompt response = call_openai_chat(full_prompt, response_format_json=True) @@ -283,11 +296,11 @@ def main(): try: data = json.loads(sys.stdin.read()) except: - data = {} + data = {{}} else: - data = {} + data = {{}} - modes = { + modes = {{ "analyze_product": analyze_product, "discover_icps": discover_icps, "hunt_whales": hunt_whales, @@ -306,4 +319,4 @@ def main(): print(json.dumps({"error": f"Unknown mode: {args.mode}"})) if __name__ == "__main__": - main() \ No newline at end of file + main()