feat(gtm-architect): Integrate GTM Architect app with Python backend, DB persistence, and Docker stack
This commit is contained in:
107
gtm_architect_orchestrator.py
Normal file
107
gtm_architect_orchestrator.py
Normal file
@@ -0,0 +1,107 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
# Add project root to Python path
|
||||
project_root = Path(__file__).resolve().parents[1]
|
||||
sys.path.append(str(project_root))
|
||||
|
||||
from helpers import call_openai_chat
|
||||
import market_db_manager
|
||||
|
||||
# Ensure DB is ready
|
||||
market_db_manager.init_db()
|
||||
|
||||
def get_system_instruction(lang):
|
||||
if lang == 'de':
|
||||
# ... (rest of get_system_instruction remains same)
|
||||
else:
|
||||
return """
|
||||
# IDENTITY & PURPOSE
|
||||
You are the "GTM Architect Engine" for Roboplanet. Your task is to develop a precise Go-to-Market strategy for new technical products (robots).
|
||||
# ... (rest of english instructions)
|
||||
"""
|
||||
|
||||
# --- Database Handlers ---
|
||||
|
||||
def save_project_handler(data):
|
||||
# data contains the full application state
|
||||
# Ensure we have a name for the list view
|
||||
if 'name' not in data:
|
||||
# Try to derive a name from product input or phases
|
||||
input_text = data.get('productInput', '')
|
||||
# Take first 30 chars or first line
|
||||
derived_name = input_text.split('\n')[0][:30] if input_text else "Untitled Strategy"
|
||||
data['name'] = derived_name
|
||||
|
||||
result = market_db_manager.save_project(data)
|
||||
print(json.dumps(result))
|
||||
|
||||
def list_projects_handler(data):
|
||||
# data is ignored here
|
||||
projects = market_db_manager.get_all_projects()
|
||||
print(json.dumps(projects))
|
||||
|
||||
def load_project_handler(data):
|
||||
project_id = data.get('id')
|
||||
project = market_db_manager.load_project(project_id)
|
||||
if project:
|
||||
print(json.dumps(project))
|
||||
else:
|
||||
print(json.dumps({"error": "Project not found"}))
|
||||
|
||||
def delete_project_handler(data):
|
||||
project_id = data.get('id')
|
||||
result = market_db_manager.delete_project(project_id)
|
||||
print(json.dumps(result))
|
||||
|
||||
# --- AI Handlers ---
|
||||
|
||||
def analyze_product(data):
|
||||
# ... (rest of analyze_product and other AI handlers remain same)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="GTM Architect Orchestrator")
|
||||
parser.add_argument("--mode", type=str, required=True, help="Execution mode")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Read stdin only if there is input, otherwise data is empty dict
|
||||
if not sys.stdin.isatty():
|
||||
try:
|
||||
data = json.loads(sys.stdin.read())
|
||||
except json.JSONDecodeError:
|
||||
data = {}
|
||||
else:
|
||||
data = {}
|
||||
|
||||
if args.mode == "analyze_product":
|
||||
analyze_product(data)
|
||||
elif args.mode == "discover_icps":
|
||||
discover_icps(data)
|
||||
elif args.mode == "hunt_whales":
|
||||
hunt_whales(data)
|
||||
elif args.mode == "develop_strategy":
|
||||
develop_strategy(data)
|
||||
elif args.mode == "generate_assets":
|
||||
generate_assets(data)
|
||||
elif args.mode == "generate_sales_enablement":
|
||||
generate_sales_enablement(data)
|
||||
# DB Modes
|
||||
elif args.mode == "save_project":
|
||||
save_project_handler(data)
|
||||
elif args.mode == "list_projects":
|
||||
list_projects_handler(data)
|
||||
elif args.mode == "load_project":
|
||||
load_project_handler(data)
|
||||
elif args.mode == "delete_project":
|
||||
delete_project_handler(data)
|
||||
else:
|
||||
print(json.dumps({"status": "error", "message": f"Unknown mode: {args.mode}"}))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user