Spaces:
Running
Running
noahlee1234 commited on
Commit ·
f371495
1
Parent(s): c4fd681
ui: hide generated code in logs by default via NATURALCAD_SHOW_CODE flag
Browse files
apps/gradio-demo/README.md
CHANGED
|
@@ -65,6 +65,7 @@ Optional environment variables:
|
|
| 65 |
- `NATURALCAD_BACKEND_URL` (leave unset for a pure Space-only MVP, or set it to enable backend-assisted spec generation + artifact upload)
|
| 66 |
- `NATURALCAD_API_KEY`
|
| 67 |
- `NATURALCAD_BACKEND_TIMEOUT` (default `4` seconds)
|
|
|
|
| 68 |
- `BUILD123D_PYTHON` (defaults to the current Python runtime, which is better for Hugging Face Space deployment)
|
| 69 |
|
| 70 |
When backend is enabled and returns a `job.id`, the app will POST STL/STEP files to:
|
|
@@ -75,4 +76,4 @@ Runtime artifacts:
|
|
| 75 |
- archived runs in `artifacts/runs/` (GLB preview is ephemeral and regenerated locally)
|
| 76 |
- lightweight run logs in `artifacts/logs/runs.jsonl`
|
| 77 |
|
| 78 |
-
Open http://localhost:7860
|
|
|
|
| 65 |
- `NATURALCAD_BACKEND_URL` (leave unset for a pure Space-only MVP, or set it to enable backend-assisted spec generation + artifact upload)
|
| 66 |
- `NATURALCAD_API_KEY`
|
| 67 |
- `NATURALCAD_BACKEND_TIMEOUT` (default `4` seconds)
|
| 68 |
+
- `NATURALCAD_SHOW_CODE` (default `false`; set `true` to show generated build123d code in UI logs)
|
| 69 |
- `BUILD123D_PYTHON` (defaults to the current Python runtime, which is better for Hugging Face Space deployment)
|
| 70 |
|
| 71 |
When backend is enabled and returns a `job.id`, the app will POST STL/STEP files to:
|
|
|
|
| 76 |
- archived runs in `artifacts/runs/` (GLB preview is ephemeral and regenerated locally)
|
| 77 |
- lightweight run logs in `artifacts/logs/runs.jsonl`
|
| 78 |
|
| 79 |
+
Open http://localhost:7860
|
apps/gradio-demo/app/main.py
CHANGED
|
@@ -24,6 +24,7 @@ BUILD123D_PYTHON = os.getenv("BUILD123D_PYTHON", sys.executable)
|
|
| 24 |
BACKEND_URL = os.getenv("NATURALCAD_BACKEND_URL", os.getenv("NL_CAD_BACKEND_URL", "")).strip()
|
| 25 |
BACKEND_API_KEY = os.getenv("NATURALCAD_API_KEY", os.getenv("NL_CAD_API_KEY", ""))
|
| 26 |
BACKEND_TIMEOUT_SECONDS = float(os.getenv("NATURALCAD_BACKEND_TIMEOUT", "60"))
|
|
|
|
| 27 |
ARTIFACTS_DIR = Path(__file__).parent.parent / "artifacts"
|
| 28 |
RUNS_DIR = ARTIFACTS_DIR / "runs"
|
| 29 |
LOGS_DIR = ARTIFACTS_DIR / "logs"
|
|
@@ -552,7 +553,10 @@ def generate_from_prompt(prompt: str, mode: str, output_type: str):
|
|
| 552 |
print(f"DEBUG: STEP download failed: {e}")
|
| 553 |
step_file = None
|
| 554 |
|
| 555 |
-
|
|
|
|
|
|
|
|
|
|
| 556 |
combined_logs += "Execution complete. Artifacts uploaded to Supabase."
|
| 557 |
if job_id:
|
| 558 |
combined_logs += f"\nJob ID: {job_id}"
|
|
|
|
| 24 |
BACKEND_URL = os.getenv("NATURALCAD_BACKEND_URL", os.getenv("NL_CAD_BACKEND_URL", "")).strip()
|
| 25 |
BACKEND_API_KEY = os.getenv("NATURALCAD_API_KEY", os.getenv("NL_CAD_API_KEY", ""))
|
| 26 |
BACKEND_TIMEOUT_SECONDS = float(os.getenv("NATURALCAD_BACKEND_TIMEOUT", "60"))
|
| 27 |
+
SHOW_GENERATED_CODE = os.getenv("NATURALCAD_SHOW_CODE", "false").strip().lower() in {"1", "true", "yes", "on"}
|
| 28 |
ARTIFACTS_DIR = Path(__file__).parent.parent / "artifacts"
|
| 29 |
RUNS_DIR = ARTIFACTS_DIR / "runs"
|
| 30 |
LOGS_DIR = ARTIFACTS_DIR / "logs"
|
|
|
|
| 553 |
print(f"DEBUG: STEP download failed: {e}")
|
| 554 |
step_file = None
|
| 555 |
|
| 556 |
+
if SHOW_GENERATED_CODE:
|
| 557 |
+
combined_logs = f"Generated build123d code:\n\n{code}\n\n"
|
| 558 |
+
else:
|
| 559 |
+
combined_logs = "Generation complete. (Code hidden; set NATURALCAD_SHOW_CODE=true to display.)\n\n"
|
| 560 |
combined_logs += "Execution complete. Artifacts uploaded to Supabase."
|
| 561 |
if job_id:
|
| 562 |
combined_logs += f"\nJob ID: {job_id}"
|