fix(gtm): Final robust prompt construction to eliminate SyntaxError and update migration guide
This commit is contained in:
@@ -132,33 +132,33 @@ def analyze_product(data):
|
||||
sys_instr = get_system_instruction(lang)
|
||||
|
||||
if lang == 'en':
|
||||
extraction_prompt = f"""
|
||||
extraction_prompt_template = """
|
||||
PHASE 1-A: TECHNICAL EXTRACTION
|
||||
Input Product Description: "{product_input[:25000]}..."
|
||||
Input Product Description: "{product_description}"
|
||||
|
||||
Task:
|
||||
1. Extract key technical features (specs, capabilities).
|
||||
1) Extract key technical features (specs, capabilities).
|
||||
2) Derive "Hard Constraints". IMPORTANT: Check Vmax (<20km/h = Private Grounds) and Cleaning Type (Vacuum != Heavy Debris/Snow).
|
||||
3. Create a short raw analysis summary.
|
||||
3) Create a short raw analysis summary.
|
||||
|
||||
Output JSON format ONLY.
|
||||
"""
|
||||
extraction_prompt = extraction_prompt_template.format(product_description=product_input[:25000])
|
||||
else:
|
||||
extraction_prompt = f"""
|
||||
extraction_prompt_template = """
|
||||
PHASE 1-A: TECHNICAL EXTRACTION
|
||||
Input Product Description: "{product_input[:25000]}..."
|
||||
Input Product Description: "{product_description}"
|
||||
|
||||
Aufgabe:
|
||||
1. Extrahiere technische Hauptmerkmale (Specs, Fähigkeiten).
|
||||
1) Extrahiere technische Hauptmerkmale (Specs, Fähigkeiten).
|
||||
2) Leite "Harte Constraints" ab. WICHTIG: Prüfe Vmax (<20km/h = Privatgelände) und Reinigungstyp (Vakuum != Grobschmutz/Schnee).
|
||||
3. Erstelle eine kurze Rohanalyse-Zusammenfassung.
|
||||
3) Erstelle eine kurze Rohanalyse-Zusammenfassung.
|
||||
|
||||
Output JSON format ONLY.
|
||||
"""
|
||||
extraction_prompt = extraction_prompt_template.format(product_description=product_input[:25000])
|
||||
|
||||
# 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)
|
||||
|
||||
@@ -166,7 +166,7 @@ Output JSON format ONLY.
|
||||
constraints_json = json.dumps(extraction_data.get('constraints'))
|
||||
|
||||
if lang == 'en':
|
||||
conflict_prompt = f"""
|
||||
conflict_prompt_template = """
|
||||
PHASE 1-B: PORTFOLIO CONFLICT CHECK
|
||||
|
||||
New Product Features: {features_json}
|
||||
@@ -181,8 +181,9 @@ Check if the new product overlaps significantly with existing ones (is it just a
|
||||
|
||||
Output JSON format ONLY.
|
||||
"""
|
||||
conflict_prompt = conflict_prompt_template.format(features_json=features_json, constraints_json=constraints_json)
|
||||
else:
|
||||
conflict_prompt = f"""
|
||||
conflict_prompt_template = """
|
||||
PHASE 1-B: PORTFOLIO CONFLICT CHECK
|
||||
|
||||
Neue Produkt-Features: {features_json}
|
||||
@@ -197,8 +198,8 @@ Prüfe, ob das neue Produkt signifikant mit bestehenden Produkten überlappt (Is
|
||||
|
||||
Output JSON format ONLY.
|
||||
"""
|
||||
conflict_prompt = conflict_prompt_template.format(features_json=features_json, constraints_json=constraints_json)
|
||||
|
||||
# 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)
|
||||
conflict_data = json.loads(conflict_response)
|
||||
@@ -215,7 +216,7 @@ def discover_icps(data):
|
||||
constraints_json = json.dumps(phase1_result.get('constraints'))
|
||||
|
||||
if lang == 'en':
|
||||
prompt = f"""
|
||||
prompt_template = """
|
||||
PHASE 2: ICP DISCOVERY & DATA PROXIES
|
||||
Based on the product features: {features_json}
|
||||
And constraints: {constraints_json}
|
||||
@@ -226,8 +227,9 @@ Output JSON format ONLY:
|
||||
"dataProxies": [ {{ "target": "Criteria", "method": "How" }} ]
|
||||
}}
|
||||
"""
|
||||
prompt = prompt_template.format(features_json=features_json, constraints_json=constraints_json)
|
||||
else:
|
||||
prompt = f"""
|
||||
prompt_template = """
|
||||
PHASE 2: ICP DISCOVERY & DATA PROXIES
|
||||
Basierend auf Features: {features_json}
|
||||
Und Constraints: {constraints_json}
|
||||
@@ -238,8 +240,8 @@ Output JSON format ONLY:
|
||||
"dataProxies": [ {{ "target": "Kriterium", "method": "Methode" }} ]
|
||||
}}
|
||||
"""
|
||||
prompt = prompt_template.format(features_json=features_json, constraints_json=constraints_json)
|
||||
|
||||
# Fix: Prepend system instruction manually
|
||||
full_prompt = sys_instr + "\n\n" + prompt
|
||||
response = call_openai_chat(full_prompt, response_format_json=True)
|
||||
print(response)
|
||||
@@ -250,7 +252,6 @@ def hunt_whales(data):
|
||||
sys_instr = get_system_instruction(lang)
|
||||
icps_json = json.dumps(phase2_result.get('icps'))
|
||||
prompt = f"PHASE 3: WHALE HUNTING for {icps_json}. Identify 3-5 concrete DACH companies per industry and buying center roles. Output JSON ONLY."
|
||||
# Fix: Prepend system instruction manually
|
||||
full_prompt = sys_instr + "\n\n" + prompt
|
||||
response = call_openai_chat(full_prompt, response_format_json=True)
|
||||
print(response)
|
||||
@@ -262,7 +263,6 @@ def develop_strategy(data):
|
||||
sys_instr = get_system_instruction(lang)
|
||||
phase3_json = json.dumps(phase3_result)
|
||||
prompt = f"PHASE 4: STRATEGY Matrix for {phase3_json}. Apply Hybrid logic. Output JSON ONLY."
|
||||
# Fix: Prepend system instruction manually
|
||||
full_prompt = sys_instr + "\n\n" + prompt
|
||||
response = call_openai_chat(full_prompt, response_format_json=True)
|
||||
print(response)
|
||||
@@ -272,7 +272,6 @@ def generate_assets(data):
|
||||
sys_instr = get_system_instruction(lang)
|
||||
data_json = json.dumps(data)
|
||||
prompt = f"PHASE 5: GTM STRATEGY REPORT Markdown. Use facts, TCO, ROI. Data: {data_json}"
|
||||
# Fix: Prepend system instruction manually
|
||||
full_prompt = sys_instr + "\n\n" + prompt
|
||||
response = call_openai_chat(full_prompt)
|
||||
print(json.dumps(response))
|
||||
@@ -282,7 +281,6 @@ def generate_sales_enablement(data):
|
||||
sys_instr = get_system_instruction(lang)
|
||||
data_json = json.dumps(data)
|
||||
prompt = f"PHASE 6: Battlecards and MJ Prompts. Data: {data_json}. Output JSON ONLY."
|
||||
# Fix: Prepend system instruction manually
|
||||
full_prompt = sys_instr + "\n\n" + prompt
|
||||
response = call_openai_chat(full_prompt, response_format_json=True)
|
||||
print(response)
|
||||
@@ -321,4 +319,4 @@ def main():
|
||||
print(json.dumps({"error": f"Unknown mode: {args.mode}"}))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
Reference in New Issue
Block a user