Langflow¶
Langflow serves as the visual flow manager for MDU's AI decision layer. While flows are designed in the Langflow UI, execution happens via direct OpenAI GPT-4o API calls for reliability and speed.
Setup¶
- Container:
mdu-langflowat/opt/langflow/ - Port:
127.0.0.1:7860(internal only) - Credentials:
langflow/langflow - Access: Nginx restricts to
127.0.0.1,10.x,172.xonly
Flows¶
Flow 1 — Prompt Optimizer¶
ID: 072376c5
Used by: routes.js (mdu-api, ~line 1323)
Trigger: Before generate-model for text-only requests
Optimizes user prompts for better 3D generation:
- Enhances prompt with miniature-specific details
- Selects optimal provider (Tripo vs Meshy)
- Adds pose, scale, and detail level hints
Flow 2 — Quality Assessor¶
ID: 871c5ea1
Used by: main.py (stl-pipeline, line 335)
Trigger: After admesh repair in STL pipeline
Routes meshes through quality tiers:
| Decision | Action |
|---|---|
| FAST | Skip detailed validation |
| FULL | Run complete validation suite |
| REJECT | Fail the job immediately |
Flow 3 — Remix Decision¶
ID: 0dfbf800
Used by: main.py (stl-pipeline, line 384)
Trigger: After STL validation
Evaluates final output quality:
| Decision | Action |
|---|---|
| PASS | Model is print-ready |
| REMIX | Badge stored in metadata (suggest re-gen) |
| ESCALATE | Flag for manual review |
Flow 4 — Base Customizer¶
ID: d547d13c
Used by: routes.js (mdu-api, ~line 2838)
Trigger: POST /api/generate-base
Generates build123d Python code for parametric bases:
Execution Architecture¶
Langflow UI (flow design)
|
v
Flow definitions (JSON)
|
v
callLangflow() in routes.js / _call_flow() in main.py
|
v
Direct GPT-4o API call (NOT Langflow container)
|
v
Parsed response → action
Info
callLangflow() in langflow.cjs can call the Langflow container via x-api-key header, but the primary execution path uses direct OpenAI calls for reliability. The function returns null on any error (graceful degradation).
Integration Module¶
/opt/mdu-api/langflow.cjs — CommonJS module that wraps Langflow container calls:
- API key: Set in
.envasLANGFLOW_API_KEY - Used by Flow 1 (prompt-optimizer) and Flow 4 (base-customizer)
- Returns
nullon any error — generation proceeds without optimization