fix(gtm-architect): Stabilize Docker environment and fix frontend
- Refactor Docker build process for gtm-app to ensure reliability - Correct volume mounts and build context in docker-compose.yml to prevent stale code - Fix frontend 404 error by using relative paths in index.html - Ensure API key is correctly mounted into the container - Stabilize Node.js to Python data passing via explicit --data argument - Update gtm_architect_documentation.md with extensive troubleshooting guide
This commit is contained in:
@@ -86,26 +86,24 @@ services:
|
|||||||
- market-backend
|
- market-backend
|
||||||
# Port 80 is internal only
|
# Port 80 is internal only
|
||||||
|
|
||||||
# --- GTM ARCHITECT ---
|
|
||||||
gtm-app:
|
gtm-app:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: gtm-architect/Dockerfile
|
dockerfile: gtm-architect/Dockerfile
|
||||||
container_name: gtm-architect
|
container_name: gtm-architect
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "3005:3005"
|
||||||
volumes:
|
volumes:
|
||||||
# Sideloading: Python Logic
|
# Sideloading for live development
|
||||||
- ./gtm_architect_orchestrator.py:/app/gtm_architect_orchestrator.py
|
- ./gtm_architect_orchestrator.py:/app/gtm_architect_orchestrator.py
|
||||||
- ./market_db_manager.py:/app/market_db_manager.py
|
- ./gtm-architect/server.cjs:/app/server.cjs
|
||||||
- ./helpers.py:/app/helpers.py
|
- ./helpers.py:/app/helpers.py
|
||||||
- ./config.py:/app/config.py
|
- ./config.py:/app/config.py
|
||||||
# Sideloading: Server Logic
|
|
||||||
- ./gtm-architect/server.cjs:/app/server.cjs
|
|
||||||
# Database Persistence
|
# Database Persistence
|
||||||
- ./gtm_projects.db:/app/gtm_projects.db
|
- ./gtm_projects.db:/app/gtm_projects.db
|
||||||
# Keys
|
# Mount the API key to the location expected by config.py
|
||||||
- ./gemini_api_key.txt:/app/gemini_api_key.txt
|
- ./gemini_api_key.txt:/app/api_key.txt
|
||||||
environment:
|
environment:
|
||||||
- PYTHONUNBUFFERED=1
|
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||||
- DB_PATH=/app/gtm_projects.db
|
- SERPAPI_API_KEY=${SERPAPI_API_KEY}
|
||||||
# Port 3005 is internal only
|
|
||||||
@@ -696,7 +696,7 @@ ${prompt.prompt}\n\
|
|||||||
<div>
|
<div>
|
||||||
<h3 className="text-sm font-bold uppercase tracking-wider text-slate-500 mb-2">{labels.features}</h3>
|
<h3 className="text-sm font-bold uppercase tracking-wider text-slate-500 mb-2">{labels.features}</h3>
|
||||||
<ul className="space-y-2">
|
<ul className="space-y-2">
|
||||||
{state.phase1Result?.features.map((f, i) => (
|
{(state.phase1Result?.phase1_technical_extraction?.features || []).map((f, i) => (
|
||||||
<li key={i} className="flex justify-between items-center group text-sm p-2 rounded border bg-slate-50 dark:bg-robo-900 border-slate-200 dark:border-robo-700">
|
<li key={i} className="flex justify-between items-center group text-sm p-2 rounded border bg-slate-50 dark:bg-robo-900 border-slate-200 dark:border-robo-700">
|
||||||
<span>{f}</span>
|
<span>{f}</span>
|
||||||
<button onClick={() => removeFeature(i)} className="opacity-0 group-hover:opacity-100 text-red-500"><X size={14}/></button>
|
<button onClick={() => removeFeature(i)} className="opacity-0 group-hover:opacity-100 text-red-500"><X size={14}/></button>
|
||||||
@@ -711,7 +711,7 @@ ${prompt.prompt}\n\
|
|||||||
<div>
|
<div>
|
||||||
<h3 className="text-sm font-bold uppercase tracking-wider text-slate-500 mb-2">{labels.constraints}</h3>
|
<h3 className="text-sm font-bold uppercase tracking-wider text-slate-500 mb-2">{labels.constraints}</h3>
|
||||||
<ul className="space-y-2">
|
<ul className="space-y-2">
|
||||||
{state.phase1Result?.constraints.map((c, i) => (
|
{(state.phase1Result?.phase1_technical_extraction?.constraints || []).map((c, i) => (
|
||||||
<li key={i} className="flex justify-between items-center group text-sm p-2 rounded border bg-red-50 dark:bg-robo-900 border-red-200 dark:border-red-900/30">
|
<li key={i} className="flex justify-between items-center group text-sm p-2 rounded border bg-red-50 dark:bg-robo-900 border-red-200 dark:border-red-900/30">
|
||||||
<span>{c}</span>
|
<span>{c}</span>
|
||||||
<button onClick={() => removeConstraint(i)} className="opacity-0 group-hover:opacity-100 text-red-600"><X size={14}/></button>
|
<button onClick={() => removeConstraint(i)} className="opacity-0 group-hover:opacity-100 text-red-600"><X size={14}/></button>
|
||||||
|
|||||||
@@ -82,10 +82,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<link rel="stylesheet" href="/index.css">
|
<link rel="stylesheet" href="./index.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script type="module" src="/index.tsx"></script>
|
<script type="module" src="./index.tsx"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,85 +1,93 @@
|
|||||||
const express = require('express');
|
console.log("--- GTM Architect Server starting ---");
|
||||||
const { spawn } = require('child_process');
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const app = express();
|
|
||||||
const port = 3005; // Port for the GTM Architect service
|
|
||||||
|
|
||||||
app.use(express.json({ limit: '50mb' }));
|
try {
|
||||||
|
const express = require('express');
|
||||||
|
const { spawn } = require('child_process');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const app = express();
|
||||||
|
const port = 3005; // Port for the GTM Architect service
|
||||||
|
|
||||||
// Determine Environment and Paths
|
app.use(express.json({ limit: '50mb' }));
|
||||||
const distPath = path.join(__dirname, 'dist');
|
|
||||||
const isProduction = fs.existsSync(distPath);
|
|
||||||
const staticDir = isProduction ? distPath : __dirname;
|
|
||||||
|
|
||||||
console.log(`[Init] Serving static files from: ${staticDir}`);
|
// Determine Environment and Paths
|
||||||
app.use(express.static(staticDir));
|
const distPath = path.join(__dirname, 'dist');
|
||||||
|
const isProduction = fs.existsSync(distPath);
|
||||||
|
const staticDir = isProduction ? distPath : __dirname;
|
||||||
|
|
||||||
// Determine Python Script Path
|
console.log(`[Init] Serving static files from: ${staticDir}`);
|
||||||
// In Docker (optimized), script is in same dir. Locally, it might be one level up.
|
app.use(express.static(staticDir));
|
||||||
let pythonScriptPath = path.join(__dirname, 'gtm_architect_orchestrator.py');
|
|
||||||
if (!fs.existsSync(pythonScriptPath)) {
|
|
||||||
pythonScriptPath = path.join(__dirname, '../gtm_architect_orchestrator.py');
|
|
||||||
}
|
|
||||||
console.log(`[Init] Using Python script at: ${pythonScriptPath}`);
|
|
||||||
|
|
||||||
|
// Determine Python Script Path
|
||||||
function callPythonScript(mode, data, res) {
|
// In Docker (optimized), script is in same dir. Locally, it might be one level up.
|
||||||
const pythonProcess = spawn('python3', [pythonScriptPath, '--mode', mode]);
|
let pythonScriptPath = path.join(__dirname, 'gtm_architect_orchestrator.py');
|
||||||
|
if (!fs.existsSync(pythonScriptPath)) {
|
||||||
let pythonData = '';
|
pythonScriptPath = path.join(__dirname, '../gtm_architect_orchestrator.py');
|
||||||
let errorData = '';
|
|
||||||
|
|
||||||
pythonProcess.stdout.on('data', (data) => {
|
|
||||||
pythonData += data.toString();
|
|
||||||
});
|
|
||||||
|
|
||||||
pythonProcess.stderr.on('data', (data) => {
|
|
||||||
errorData += data.toString();
|
|
||||||
});
|
|
||||||
|
|
||||||
pythonProcess.on('close', (code) => {
|
|
||||||
if (code !== 0) {
|
|
||||||
console.error(`Python script exited with code ${code}`);
|
|
||||||
console.error('Stderr:', errorData);
|
|
||||||
return res.status(500).json({ error: 'Python script execution failed.', details: errorData });
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const result = JSON.parse(pythonData);
|
|
||||||
res.json(result);
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Failed to parse Python script output:', e);
|
|
||||||
console.error('Raw output:', pythonData);
|
|
||||||
res.status(500).json({ error: 'Failed to parse Python script output.', details: pythonData });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
pythonProcess.stdin.write(JSON.stringify(data));
|
|
||||||
pythonProcess.stdin.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
// API endpoint to handle requests from the frontend
|
|
||||||
app.post('/api/gtm', (req, res) => {
|
|
||||||
const { mode, data } = req.body;
|
|
||||||
if (!mode || !data) {
|
|
||||||
return res.status(400).json({ error: 'Missing mode or data in request body' });
|
|
||||||
}
|
}
|
||||||
callPythonScript(mode, data, res);
|
console.log(`[Init] Using Python script at: ${pythonScriptPath}`);
|
||||||
});
|
|
||||||
|
|
||||||
// Serve the main index.html for any other requests to support client-side routing
|
|
||||||
app.get('*', (req, res) => {
|
|
||||||
res.sendFile(path.join(staticDir, 'index.html'));
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
const VERSION = "1.1.1_Fix"; // Add a version for debugging
|
function callPythonScript(mode, data, res) {
|
||||||
|
const dataString = JSON.stringify(data);
|
||||||
|
const pythonProcess = spawn('python3', [pythonScriptPath, '--mode', mode, '--data', dataString]);
|
||||||
|
|
||||||
const server = app.listen(port, () => {
|
let pythonData = '';
|
||||||
console.log(`GTM Architect server listening at http://localhost:${port} (Version: ${VERSION})`);
|
let errorData = '';
|
||||||
});
|
|
||||||
|
pythonProcess.stdout.on('data', (data) => {
|
||||||
|
pythonData += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
pythonProcess.stderr.on('data', (data) => {
|
||||||
|
errorData += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
pythonProcess.on('close', (code) => {
|
||||||
|
if (code !== 0) {
|
||||||
|
console.error(`Python script exited with code ${code}`);
|
||||||
|
console.error('Stderr:', errorData);
|
||||||
|
return res.status(500).json({ error: 'Python script execution failed.', details: errorData });
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const result = JSON.parse(pythonData);
|
||||||
|
res.json(result);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to parse Python script output:', e);
|
||||||
|
console.error('Raw output:', pythonData);
|
||||||
|
res.status(500).json({ error: 'Failed to parse Python script output.', details: pythonData });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// API endpoint to handle requests from the frontend
|
||||||
|
app.post('/api/gtm', (req, res) => {
|
||||||
|
const { mode, data } = req.body;
|
||||||
|
if (!mode || !data) {
|
||||||
|
return res.status(400).json({ error: 'Missing mode or data in request body' });
|
||||||
|
}
|
||||||
|
callPythonScript(mode, data, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Serve the main index.html for any other requests to support client-side routing
|
||||||
|
app.get('*', (req, res) => {
|
||||||
|
res.sendFile(path.join(staticDir, 'index.html'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const VERSION = "1.1.1_Fix_20260101_1200_FINAL"; // Add a version for debugging
|
||||||
|
|
||||||
|
const server = app.listen(port, () => {
|
||||||
|
console.log(`GTM Architect server listening at http://localhost:${port} (Version: ${VERSION})`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Prevent 502 Bad Gateway by increasing Node.js server timeouts to match Nginx
|
||||||
|
server.setTimeout(600000);
|
||||||
|
server.keepAliveTimeout = 610000;
|
||||||
|
server.headersTimeout = 620000;
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
console.error("!!! A CRITICAL ERROR OCCURRED ON STARTUP !!!");
|
||||||
|
console.error(e);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent 502 Bad Gateway by increasing Node.js server timeouts to match Nginx
|
|
||||||
server.setTimeout(600000);
|
|
||||||
server.keepAliveTimeout = 610000;
|
|
||||||
server.headersTimeout = 620000;
|
|
||||||
|
|||||||
@@ -63,28 +63,46 @@ Der Service läuft im Container `gtm-architect`.
|
|||||||
* **Optimierung:** Nur `/dist` und Skripte landen im finalen Image.
|
* **Optimierung:** Nur `/dist` und Skripte landen im finalen Image.
|
||||||
* **Mounts:**
|
* **Mounts:**
|
||||||
* `gtm_projects.db` (Persistenz)
|
* `gtm_projects.db` (Persistenz)
|
||||||
|
* `gemini_api_key.txt` (API-Schlüssel)
|
||||||
* `gtm_architect_orchestrator.py` (Sideloading für Dev)
|
* `gtm_architect_orchestrator.py` (Sideloading für Dev)
|
||||||
* `server.cjs` (Sideloading für Dev)
|
* `server.cjs` (Sideloading für Dev)
|
||||||
* `helpers.py` & `config.py` (Shared Libraries)
|
* `helpers.py` & `config.py` (Shared Libraries)
|
||||||
|
|
||||||
### Starten / Neustarten
|
### Starten / Neustarten
|
||||||
```bash
|
Der beste Weg, um einen sauberen Neustart zu gewährleisten, ist der `up`-Befehl mit `--build`.
|
||||||
# Bauen und Starten
|
|
||||||
docker-compose up -d --build gtm-app proxy dashboard
|
|
||||||
|
|
||||||
# Nur Neustart nach Python-Änderungen (dank Sideloading)
|
```bash
|
||||||
docker-compose restart gtm-app
|
# Kompletten Stack neu bauen und starten (empfohlen)
|
||||||
|
docker-compose up -d --build
|
||||||
|
|
||||||
|
# Nur den gtm-app Service neu bauen & neu erstellen
|
||||||
|
# Das --force-recreate ist entscheidend, um sicherzustellen, dass der alte Container ersetzt wird.
|
||||||
|
docker-compose up -d --build --force-recreate gtm-app
|
||||||
|
|
||||||
|
# Build ohne Cache erzwingen (bei hartnäckigen Problemen)
|
||||||
|
docker-compose build --no-cache gtm-app && docker-compose up -d gtm-app
|
||||||
```
|
```
|
||||||
|
|
||||||
## 5. Wartung & Troubleshooting
|
## 5. Wartung & Troubleshooting
|
||||||
|
|
||||||
|
### Fehler: "White Screen" / Leere Seite nach Start
|
||||||
|
* **Symptom:** Der Browser zeigt eine leere Seite. In der Entwicklerkonsole erscheint ein `404 Not Found` Fehler für `index.css` oder `index.tsx`.
|
||||||
|
* **Ursache:** Falsche Pfade in der `gtm-architect/index.html`. Die `href` und `src` Attribute für CSS und JS müssen relativ (`./index.css`) statt absolut (`/index.css`) sein.
|
||||||
|
* **Lösung:** Pfade in der `index.html` korrigieren und sicherstellen, dass in `vite.config.ts` die Option `base: './'` gesetzt ist. Anschließend den Container mit `--build` neu erstellen.
|
||||||
|
|
||||||
|
### Fehler: Leere Listen / Keine API-Antwort im Frontend
|
||||||
|
* **Symptom:** Die App startet, aber nach dem Klick auf "Analyse starten" erscheinen keine Features oder Constraints. Es gibt keine Fehlermeldung.
|
||||||
|
* **Ursache:** Dem Python-Skript fehlt der API-Schlüssel. Das Skript `config.py` liest den Schlüssel aus der Datei `/app/api_key.txt` im Container. Wenn diese Datei fehlt, schlagen API-Aufrufe im Hintergrund fehl, und das Skript gibt eine leere Antwort zurück.
|
||||||
|
* **Lösung:** Sicherstellen, dass die `docker-compose.yml` den API-Schlüssel korrekt in den Container mountet: `volumes: - ./gemini_api_key.txt:/app/api_key.txt`.
|
||||||
|
|
||||||
|
### Fehler: Code-Änderungen werden nicht übernommen (Stale Code)
|
||||||
|
* **Symptom:** Änderungen an Python- oder Node.js-Dateien haben keine Auswirkung im Container, selbst nach einem `restart`.
|
||||||
|
* **Ursache:** Ein Problem in der `docker-compose.yml`. Entweder ist der `build context` falsch gesetzt oder die `volumes`-Konfiguration für das Sideloading ist fehlerhaft. Ein zu breiter Mount wie `- .:/app` kann von den Dateien im Image überschrieben werden.
|
||||||
|
* **Lösung:**
|
||||||
|
1. Den `build context` auf `.` setzen und das `dockerfile` spezifisch adressieren (`gtm-architect/Dockerfile`).
|
||||||
|
2. `volumes` für jede zu sideloadende Datei einzeln und explizit definieren.
|
||||||
|
3. Den Container mit `docker-compose up -d --build --force-recreate gtm-app` neu erstellen.
|
||||||
|
|
||||||
### Fehler: "502 Bad Gateway"
|
### Fehler: "502 Bad Gateway"
|
||||||
* **Ursache:** Der Node.js Server oder Nginx hat den Request wegen Timeout abgebrochen.
|
* **Ursache:** Der Node.js Server oder Nginx hat den Request wegen Timeout abgebrochen.
|
||||||
* **Lösung:** Timeouts sind in `nginx-proxy.conf` und `server.cjs` auf 600s+ gesetzt. Prüfen, ob der Container läuft (`docker ps`).
|
* **Lösung:** Timeouts sind in `nginx-proxy.conf` und `server.cjs` auf 600s+ gesetzt. Prüfen, ob der Container läuft (`docker ps`).
|
||||||
|
|
||||||
### Fehler: "Project not saved"
|
|
||||||
* **Ursache:** Berechtigungsprobleme auf `gtm_projects.db` oder Datei fehlt.
|
|
||||||
* **Lösung:** Sicherstellen, dass die Datei auf dem Host existiert und gemountet ist (wurde im Setup-Prozess via `touch` erstellt).
|
|
||||||
|
|
||||||
### Entwicklung
|
|
||||||
Änderungen am Prompting sollten ausschließlich in `gtm_architect_orchestrator.py` vorgenommen werden. Nach der Änderung reicht ein `docker-compose restart gtm-app`.
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ sys.path.append(str(project_root))
|
|||||||
from helpers import call_openai_chat
|
from helpers import call_openai_chat
|
||||||
import market_db_manager
|
import market_db_manager
|
||||||
|
|
||||||
|
print("--- PYTHON ORCHESTRATOR V_20260101_1200_FINAL ---", file=sys.stderr)
|
||||||
|
|
||||||
__version__ = "1.4.0_UltimatePromptFix"
|
__version__ = "1.4.0_UltimatePromptFix"
|
||||||
|
|
||||||
# Ensure DB is ready
|
# Ensure DB is ready
|
||||||
@@ -56,7 +58,7 @@ Unsere Strategie ist NICHT "Roboter ersetzen Menschen", sondern "Hybrid-Reinigun
|
|||||||
Behalte immer im Hinterkopf, dass wir bereits folgende Produkte im Portfolio haben:
|
Behalte immer im Hinterkopf, dass wir bereits folgende Produkte im Portfolio haben:
|
||||||
1. "Indoor Scrubber 50": Innenreinigung, Hartboden, Fokus: Supermärkte. Message: "Sauberkeit im laufenden Betrieb."
|
1. "Indoor Scrubber 50": Innenreinigung, Hartboden, Fokus: Supermärkte. Message: "Sauberkeit im laufenden Betrieb."
|
||||||
2. "Service Bot Bella": Service/Gastro, Indoor. Fokus: Restaurants. Message: "Entlastung für Servicekräfte."
|
2. "Service Bot Bella": Service/Gastro, Indoor. Fokus: Restaurants. Message: "Entlastung für Servicekräfte."
|
||||||
""
|
"""
|
||||||
else:
|
else:
|
||||||
return """
|
return """
|
||||||
# IDENTITY & PURPOSE
|
# IDENTITY & PURPOSE
|
||||||
@@ -163,6 +165,7 @@ def analyze_product(data):
|
|||||||
full_extraction_prompt = sys_instr + "\n\n" + extraction_prompt
|
full_extraction_prompt = sys_instr + "\n\n" + extraction_prompt
|
||||||
print(f"DEBUG: Full Extraction Prompt: \n{full_extraction_prompt[:1000]}...\n", file=sys.stderr)
|
print(f"DEBUG: Full Extraction Prompt: \n{full_extraction_prompt[:1000]}...\n", file=sys.stderr)
|
||||||
extraction_response = call_openai_chat(full_extraction_prompt, response_format_json=True)
|
extraction_response = call_openai_chat(full_extraction_prompt, response_format_json=True)
|
||||||
|
print(f"DEBUG: Raw Extraction Response from API: {extraction_response}", file=sys.stderr)
|
||||||
extraction_data = json.loads(extraction_response)
|
extraction_data = json.loads(extraction_response)
|
||||||
|
|
||||||
features_json = json.dumps(extraction_data.get('features'))
|
features_json = json.dumps(extraction_data.get('features'))
|
||||||
@@ -176,3 +179,81 @@ def analyze_product(data):
|
|||||||
f"New Product Constraints: {constraints_json}",
|
f"New Product Constraints: {constraints_json}",
|
||||||
"",
|
"",
|
||||||
"Existing Portfolio:",
|
"Existing Portfolio:",
|
||||||
|
"1. 'Indoor Scrubber 50': Indoor, Hard Floor, Supermarkets.",
|
||||||
|
"2. 'Service Bot Bella': Indoor, Service/Hospitality, Restaurants.",
|
||||||
|
"",
|
||||||
|
"Task: Check for cannibalization. Does the new product make an existing one obsolete? Explain briefly.",
|
||||||
|
"Output JSON format ONLY."
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
conflict_prompt_parts = [
|
||||||
|
"PHASE 1-B: PORTFOLIO-KONFLIKT-CHECK",
|
||||||
|
"",
|
||||||
|
f"Neue Produktmerkmale: {features_json}",
|
||||||
|
f"Neue Produkt-Constraints: {constraints_json}",
|
||||||
|
"",
|
||||||
|
"Bestehendes Portfolio:",
|
||||||
|
"1. 'Indoor Scrubber 50': Innenreinigung, Hartboden, Supermärkte.",
|
||||||
|
"2. 'Service Bot Bella': Indoor, Service/Gastro, Restaurants.",
|
||||||
|
"",
|
||||||
|
"Aufgabe: Prüfe auf Kannibalisierung. Macht das neue Produkt ein bestehendes obsolet? Begründe kurz.",
|
||||||
|
"Output JSON format ONLY."
|
||||||
|
]
|
||||||
|
conflict_prompt = "\n".join(conflict_prompt_parts)
|
||||||
|
|
||||||
|
full_conflict_prompt = sys_instr + "\n\n" + conflict_prompt
|
||||||
|
print(f"DEBUG: Full Conflict Prompt: \n{full_conflict_prompt[:1000]}...\n", file=sys.stderr)
|
||||||
|
conflict_response = call_openai_chat(full_conflict_prompt, response_format_json=True)
|
||||||
|
conflict_data = json.loads(conflict_response)
|
||||||
|
|
||||||
|
# --- Final Response Assembly ---
|
||||||
|
final_response = {
|
||||||
|
"phase1_technical_extraction": extraction_data,
|
||||||
|
"phase2_portfolio_conflict": conflict_data,
|
||||||
|
}
|
||||||
|
print(json.dumps(final_response, indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
# --- Main Execution Logic ---
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description='GTM Architect main entry point.')
|
||||||
|
parser.add_argument('--data', help='JSON data for the command.')
|
||||||
|
parser.add_argument('--mode', required=True, help='The command to execute.')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
command = args.mode
|
||||||
|
|
||||||
|
# Get data from --data arg or stdin
|
||||||
|
if args.data:
|
||||||
|
data = json.loads(args.data)
|
||||||
|
else:
|
||||||
|
# Read from stdin if no data arg provided
|
||||||
|
try:
|
||||||
|
input_data = sys.stdin.read()
|
||||||
|
data = json.loads(input_data) if input_data.strip() else {}
|
||||||
|
except Exception:
|
||||||
|
data = {}
|
||||||
|
|
||||||
|
if not command:
|
||||||
|
print(json.dumps({"error": "No command or mode provided"}))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
command_handlers = {
|
||||||
|
'save': save_project_handler,
|
||||||
|
'list': list_projects_handler,
|
||||||
|
'load': load_project_handler,
|
||||||
|
'delete': delete_project_handler,
|
||||||
|
'analyze': analyze_product,
|
||||||
|
}
|
||||||
|
|
||||||
|
handler = command_handlers.get(command)
|
||||||
|
if handler:
|
||||||
|
handler(data)
|
||||||
|
else:
|
||||||
|
print(json.dumps({"error": f"Unknown command: {command}"}))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print(f"GTM Architect Engine v{__version__}_FORCE_RELOAD_2 running.", file=sys.stderr)
|
||||||
|
main()
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# Plan: Umsetzung des "GTM Architect" Backends
|
|
||||||
|
|
||||||
Dieses Dokument beschreibt den Plan zur Umsetzung der Backend-Logik für die React-Anwendung unter `/gtm-architect` als robusten, faktenbasierten Python-Service.
|
|
||||||
|
|
||||||
## 1. Zielsetzung & Architektur
|
|
||||||
|
|
||||||
- **Ziel:** Umwandlung der reinen Frontend-Anwendung in einen Service mit einem Python-Backend.
|
|
||||||
- **Architektur:** Wir replizieren den bewährten Aufbau der anderen Tools:
|
|
||||||
1. **React-Frontend:** Die Benutzeroberfläche in `/gtm-architect` bleibt bestehen.
|
|
||||||
2. **Node.js API-Brücke (`server.cjs`):** Ein Express.js-Server, der Anfragen vom Frontend annimmt und an das Python-Backend weiterleitet.
|
|
||||||
3. **Python-Orchestrator (`gtm_architect_orchestrator.py`):** Das neue Herzstück, das die gesamte Logik kapselt.
|
|
||||||
|
|
||||||
## 2. Fortschritts-Log
|
|
||||||
|
|
||||||
### Phase 1: Initialisierung & Planung
|
|
||||||
- [ ] Anforderungsanalyse und Zieldefinition.
|
|
||||||
- [ ] Architektur nach Vorbild `b2b-marketing-assistant` und `market-intel-backend` festgelegt.
|
|
||||||
- [ ] Diesen Schlachtplan in `gtm_architect_plan.md` erstellt.
|
|
||||||
- [ ] Aufbau der Grundstruktur: Erstellen der `gtm_architect_orchestrator.py`, der `server.cjs` in `/gtm-architect` und des `Dockerfile`.
|
|
||||||
- [ ] Erstellung von `package.json` und `requirements.txt`.
|
|
||||||
- [ ] Anpassung des Frontends (`App.tsx`) für die Kommunikation mit dem neuen Backend.
|
|
||||||
- [ ] Portierung der Logik aus `geminiService.ts` nach Python.
|
|
||||||
- [ ] Integration in `docker-compose.yml` und `nginx-proxy.conf`.
|
|
||||||
15
helpers.py
15
helpers.py
@@ -47,19 +47,8 @@ except ImportError:
|
|||||||
tiktoken = None
|
tiktoken = None
|
||||||
logging.warning("tiktoken nicht gefunden. Token-Zaehlung wird geschaetzt.")
|
logging.warning("tiktoken nicht gefunden. Token-Zaehlung wird geschaetzt.")
|
||||||
|
|
||||||
try:
|
gender = None
|
||||||
import gender_guesser.detector as gender
|
gender_detector = None
|
||||||
# Initialisieren Sie den Detector einmal global
|
|
||||||
gender_detector = gender.Detector()
|
|
||||||
logging.info("gender_guesser.Detector initialisiert.")
|
|
||||||
except ImportError:
|
|
||||||
gender = None
|
|
||||||
gender_detector = None
|
|
||||||
logging.warning("gender_guesser Bibliothek nicht gefunden. Geschlechtserkennung deaktiviert.")
|
|
||||||
except Exception as e:
|
|
||||||
gender = None
|
|
||||||
gender_detector = None
|
|
||||||
logging.warning(f"Fehler bei Initialisierung von gender_guesser: {e}. Geschlechtserkennung deaktiviert.")
|
|
||||||
|
|
||||||
# Import der Config-Klasse und Konstanten
|
# Import der Config-Klasse und Konstanten
|
||||||
from config import Config, BRANCH_MAPPING_FILE, URL_CHECK_MARKER, USER_AGENTS
|
from config import Config, BRANCH_MAPPING_FILE, URL_CHECK_MARKER, USER_AGENTS
|
||||||
|
|||||||
Reference in New Issue
Block a user