Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
361ea3c
vram indicator on linux and windows
securitybrahh Sep 8, 2026
dd0da3d
test(generation): guard that cancelling an ended job leaves the worke…
kevin9327 Oct 4, 2026
3cf0fb2
fix(storage): guard destructive directory moves and deletion
JayceeB1 Oct 9, 2026
6481e15
fix(storage): copy safely into empty destination without EEXIST
JayceeB1 Oct 9, 2026
2180a12
feat(agent): stream chat responses as typed SSE events
lightningpixel Oct 20, 2026
407ef72
Merge pull request #380 from lightningpixel/fix/300-streaming-to-dev
lightningpixel Oct 20, 2026
dc87d3f
Merge pull request #381 from lightningpixel/main
lightningpixel Oct 20, 2026
6bae496
fix(llm): pick CUDA only when an NVIDIA GPU actually answers, add eng…
Lorchie Oct 26, 2026
cd16feb
test(mesh-ops): fix two tests failing on a clean dev checkout
Lorchie Oct 26, 2026
66c1d3f
Merge pull request #388 from lightningpixel/fix/llm-nvidia-detection
lightningpixel Oct 28, 2026
86a23dc
Keep TripoSG and the texture model loaded together
ahgsql Oct 30, 2026
7f13d13
modly-cli: start the API with the same setup as the desktop app
ahgsql Oct 30, 2026
4bf4795
fix(registry): unload stale models when leaving a resident pair, gate…
lightningpixel Oct 31, 2026
ca1b909
Merge pull request #390 from ahgsql/perf/keep-geometry-texture-models…
lightningpixel Oct 31, 2026
2fcc0fb
modly-cli: drop the caller's Python env and prefer the app venv, like…
lightningpixel Oct 31, 2026
c34655a
Merge pull request #391 from ahgsql/fix/cli-serve-api-desktop-env
lightningpixel Oct 31, 2026
421d56e
Merge branch 'dev' into fix/storage-destructive-operations
lightningpixel Nov 1, 2026
5ee7dea
fix(storage): stage moves, allow data-drive folders, surface guard er…
lightningpixel Nov 1, 2026
b367638
Merge pull request #370 from JayceeB1/fix/storage-destructive-operations
lightningpixel Nov 1, 2026
8e11cff
fix(generation): never kill a worker another job is using on cancel
lightningpixel Nov 7, 2026
71aafe0
Merge pull request #366 from kevin9327/test/cancel-ended-job-keeps-wo…
lightningpixel Nov 7, 2026
e78d4bd
feat(agent): generate mesh tools from the mesh_ops registry
lightningpixel Nov 8, 2026
36ffbd3
chore: ignore local task notes
lightningpixel Nov 8, 2026
04e1ca0
Merge pull request #394 from lightningpixel/feat/301-agent-tools-from…
lightningpixel Nov 8, 2026
db8dcdc
fix(startup): say why the backend failed to start instead of a generi…
lightningpixel Nov 8, 2026
4f150ab
feat(startup): move the backend to a free port when 8765 is taken
lightningpixel Nov 8, 2026
d88322d
Merge pull request #395 from lightningpixel/fix/167-startup-error
lightningpixel Nov 8, 2026
b8b5155
Merge pull request #396 from lightningpixel/feat/167-port-fallback
lightningpixel Nov 8, 2026
d4467dd
fix(storage): only move or delete what Modly created
lightningpixel Nov 8, 2026
496ebcb
Merge pull request #397 from lightningpixel/fix/351-storage-delete-sa…
lightningpixel Nov 8, 2026
dde2b80
fix(extensions): say why an extension subprocess died
lightningpixel Nov 8, 2026
4cd298c
fix(extensions): tie a crash report to its own process
lightningpixel Nov 8, 2026
fdf7555
Merge pull request #398 from lightningpixel/fix/369-subprocess-died-r…
lightningpixel Nov 8, 2026
d74170e
fix(extensions): accept .git clone URLs and stop blaming the manifest…
lightningpixel Nov 11, 2026
ea63a9b
fix(workflow-runs): report undeclared params and reject malformed par…
lightningpixel Nov 11, 2026
9c51f7d
Merge pull request #399 from lightningpixel/fix/280-github-install
lightningpixel Nov 11, 2026
169c717
Merge pull request #400 from lightningpixel/fix/384-texture-resolutio…
lightningpixel Nov 11, 2026
a12b146
feat(agent): stop runaway tool loops with a budget, a per-tool timeou…
lightningpixel Nov 11, 2026
0d23ec2
Merge pull request #401 from lightningpixel/feat/302-tool-loop-guardr…
lightningpixel Nov 11, 2026
a39e421
feat(agent): ping Ollama and explain why it isn't answering
lightningpixel Nov 11, 2026
374b8e5
fix(agent): only probe local Ollama addresses from the health check
lightningpixel Nov 11, 2026
f7270ab
Merge pull request #402 from lightningpixel/feat/303-ollama-error-ux
lightningpixel Nov 11, 2026
129f4c3
feat(notifications): notify on failed workflow branches and name the …
lightningpixel Nov 11, 2026
81f9740
Merge pull request #403 from lightningpixel/feat/293-run-error-notifi…
lightningpixel Nov 11, 2026
6d3f28d
feat(generate): multi-level mesh undo with a bounded per-model stack
lightningpixel Nov 11, 2026
b88b056
Merge pull request #404 from lightningpixel/feat/304-multi-level-undo
lightningpixel Nov 11, 2026
465ef60
feat(mesh-ops): intent-driven presets for printing, game and web
lightningpixel Nov 12, 2026
8a651a4
feat(generate): mesh edit panel driven by the mesh-ops registry
lightningpixel Nov 12, 2026
27bd960
fix(mesh-ops): turn inside-out faces outwards and create a missing te…
lightningpixel Nov 12, 2026
cb7fedf
feat(generate): list the steps of composite ops in the edit panel
lightningpixel Nov 12, 2026
2c7d54e
Merge pull request #430 from lightningpixel/feat/299-intent-presets
lightningpixel Nov 12, 2026
276eb96
Merge pull request #431 from lightningpixel/feat/306-mesh-edit-panel
lightningpixel Nov 12, 2026
1883fcd
chore(sculpt): contract for the sculpt core
lightningpixel Nov 12, 2026
0c7b8c5
feat(optimize): patch-vertices endpoint to write sculpted positions i…
lightningpixel Nov 12, 2026
39321fe
feat(sculpt): brush core with weld map, spatial hash and stroke undo
lightningpixel Nov 12, 2026
2403be7
Merge branch 'feat/432-sculpt-core' into feat/432-sculpt-mode
lightningpixel Nov 12, 2026
2521a1b
feat(generate): sculpt mode in the viewer and the edit panel
lightningpixel Nov 12, 2026
858d33b
Merge branch 'feat/432-sculpt-viewer' into feat/432-sculpt-mode
lightningpixel Nov 12, 2026
50463fe
fix(deps): declare Pillow so mesh ops keep their textures
lightningpixel Nov 12, 2026
6c988d9
Merge branch 'fix/pillow-textures' into feat/432-sculpt-mode
lightningpixel Nov 12, 2026
cca63fd
fix(sculpt): repoint every primitive sharing the patched POSITION acc…
lightningpixel Nov 12, 2026
37dca66
Merge pull request #435 from lightningpixel/fix/pillow-textures
lightningpixel Nov 12, 2026
e5a5e3a
Merge pull request #436 from lightningpixel/feat/432-sculpt-mode
lightningpixel Nov 12, 2026
f56701b
docs(agent): design for the global agent side panel
lightningpixel Nov 12, 2026
70fe74e
feat(agent): client tool bridge and app-wide tools for the side panel
lightningpixel Nov 12, 2026
be52892
feat(agent): persist agent conversations as JSON files over IPC
lightningpixel Nov 12, 2026
4e791fd
feat(agent): global right-side agent panel
lightningpixel Nov 12, 2026
df1d2c8
feat(agent): parse client_tool events and the generate_from_image pay…
lightningpixel Nov 12, 2026
28119bb
refactor(generate): extract the image generation path out of useGener…
lightningpixel Nov 12, 2026
918a3a0
feat(agent): add client tools, confirm card and agent context
lightningpixel Nov 12, 2026
f2624dd
Merge branch 'worktree-agent-ac0079fb2b934a974' into feat/agent-side-…
lightningpixel Nov 12, 2026
750a87f
Merge branch 'worktree-agent-a31df1b7bf9bd33bf' into feat/agent-side-…
lightningpixel Nov 12, 2026
e3d3ca5
feat(agent): wire client tools, confirm cards and app-wide context in…
lightningpixel Nov 12, 2026
02d77c6
fix(agent): confirm extension installs, and enforce confirmation in t…
lightningpixel Nov 12, 2026
119ce1c
fix(agent): review fixes for the side panel
lightningpixel Nov 12, 2026
e580e27
feat(agent): slide the side panel in and out
lightningpixel Nov 12, 2026
362d939
style(agent): Claude-like composer in the side panel
lightningpixel Nov 12, 2026
a8c44e6
fix(agent): review fixes for the side panel and conversation saving
lightningpixel Nov 12, 2026
5ee3a0b
Merge pull request #437 from lightningpixel/feat/agent-side-panel
lightningpixel Nov 12, 2026
8653653
feat(nav): page registry and grouped sidebar
lightningpixel Nov 12, 2026
90d6787
feat(library): cache asset thumbnails per workspace path and file ver…
lightningpixel Nov 13, 2026
44071c8
feat(library): serve thumbnails over modly-thumb:// and expose status…
lightningpixel Nov 13, 2026
4cf073d
feat(library): render thumbnails offscreen and backfill the library
lightningpixel Nov 13, 2026
9482306
Merge branch 'feat/page-registry' into feat/library-page
lightningpixel Nov 13, 2026
4bb794f
feat(library): publish finished thumbnails to a store so open views r…
lightningpixel Nov 13, 2026
5a46e07
feat(library): filtering, sorting and grid windowing for the Library …
lightningpixel Nov 13, 2026
be2f226
test: run the page registry tests under the extensionless TS loader
lightningpixel Nov 13, 2026
bb435ed
feat(library): Library page with a virtualized thumbnail grid
lightningpixel Nov 13, 2026
e0ce3eb
feat(generate): link the library picker to the Library page
lightningpixel Nov 13, 2026
289c128
Merge pull request #440 from lightningpixel/feat/page-registry
lightningpixel Nov 13, 2026
8bb7653
Merge pull request #441 from lightningpixel/feat/library-page
lightningpixel Nov 13, 2026
d3e6a5b
feat(runs): add a persisted run history store
lightningpixel Nov 13, 2026
adc686f
feat(runs): record generations and mesh ops, list them at GET /workfl…
lightningpixel Nov 13, 2026
2afa540
feat(runs): persist workflow runs from the renderer
lightningpixel Nov 13, 2026
a48a077
Merge pull request #442 from lightningpixel/feat/run-history
lightningpixel Nov 13, 2026
6c2c61c
fix(workflows): accept object-shaped manifest inputs in preflight
lightningpixel Nov 14, 2026
d21a306
fix(linux): keep AppImage library paths out of extension setup
lightningpixel Nov 14, 2026
7de7160
Merge pull request #443 from lightningpixel/fix/preflight-object-inputs
lightningpixel Nov 14, 2026
02e976e
Merge pull request #444 from lightningpixel/fix/appimage-child-env
lightningpixel Nov 14, 2026
266c0d1
feat(home): add a Home page with recent creations and quick start
lightningpixel Nov 14, 2026
67a2b53
Merge pull request #447 from lightningpixel/feat/home-page
lightningpixel Nov 16, 2026
b9150fa
fix(workflows): resolve Mesh Exporter output paths against the workspace
lightningpixel Nov 16, 2026
a188562
docs(workflows): say that Mesh Exporter replaces an existing output file
lightningpixel Nov 16, 2026
72eb962
Merge pull request #448 from lightningpixel/fix/mesh-export-output-path
lightningpixel Nov 16, 2026
2bae751
Merge dev into vram indicator
lightningpixel Nov 16, 2026
4605972
fix(system): make the VRAM indicator cheap, independent and quiet
lightningpixel Nov 16, 2026
1f506a3
Merge pull request #334 from securitybrahh/main
lightningpixel Nov 16, 2026
953bb89
feat(queue): add a Queue page with running, queued and past runs
lightningpixel Nov 16, 2026
fa8aae9
feat(image-studio): add an Image Studio page and paste images into Ge…
lightningpixel Nov 16, 2026
3a1f250
Merge pull request #450 from lightningpixel/feat/queue-and-image-studio
lightningpixel Nov 16, 2026
1a93db2
feat(image-studio): remove an image's background on the CPU
lightningpixel Nov 16, 2026
771ddd0
fix(image-studio): accept the background-removal setup only as POST
lightningpixel Nov 16, 2026
fd09eab
refactor(image-studio): show the selected image only, without a befor…
lightningpixel Nov 16, 2026
14c0c1a
Merge pull request #457 from lightningpixel/feat/background-removal
lightningpixel Nov 16, 2026
a7e2a79
feat(mesh-ops): declare an asset's real-world scale with set_real_scale
lightningpixel Nov 17, 2026
c07c2a3
feat(image-studio): add crop and auto-frame image ops
lightningpixel Nov 17, 2026
47f88a9
feat(print): add a Print page with a build-plate view
lightningpixel Nov 17, 2026
4a4f45b
feat(image-studio): show what the model sees
lightningpixel Nov 17, 2026
2e60aac
fix(image-studio): read image transparency correctly for crop and aut…
lightningpixel Nov 17, 2026
428ce0d
fix(image-studio): run one image operation at a time
lightningpixel Nov 17, 2026
a0a643f
fix(mesh-ops): keep the declared real size through ops and exports
lightningpixel Nov 17, 2026
16f9cb0
fix(print): drop stale load errors and ignore outdated model choices
lightningpixel Nov 17, 2026
fb34dc3
fix(image): only run image ops on files inside the workspace
lightningpixel Nov 17, 2026
9a9226e
fix(image): describe the prepare endpoint as POST only
lightningpixel Nov 17, 2026
40ce5c6
fix(image-studio): run an op with its current params after the setup …
lightningpixel Nov 17, 2026
fdb3fed
fix(image-studio): reload a mask shown again after it was hidden
lightningpixel Nov 17, 2026
4a59336
fix(image-studio): type image op requirements as the backend describe…
lightningpixel Nov 17, 2026
d163c84
fix(api): agree on real sizes across imports, exports and normalize_s…
lightningpixel Nov 17, 2026
51b2412
feat(print): show uncalibrated models at the slicer's provisional size
lightningpixel Nov 17, 2026
f8f6964
feat(viewer): frame models shown at their real size
lightningpixel Nov 17, 2026
5eafbff
feat(workflows): write real-size assets in millimetres from Mesh Expo…
lightningpixel Nov 17, 2026
57af031
Merge pull request #460 from lightningpixel/feat/image-crop-pad
lightningpixel Nov 17, 2026
45b0639
Merge pull request #461 from lightningpixel/feat/print-page
lightningpixel Nov 17, 2026
deba562
feat(queue): move the Queue page into a top bar panel
lightningpixel Nov 18, 2026
bb71686
feat(print): take the Print page out of the sidebar for now
lightningpixel Nov 18, 2026
492ee7a
Merge pull request #462 from lightningpixel/feat/queue-popover
lightningpixel Nov 18, 2026
754fee7
feat(security): keep web pages off the local API, Ollama-style
lightningpixel Nov 18, 2026
0340010
feat(security): let allowed sites' <img> and <video> tags in by their…
lightningpixel Nov 18, 2026
7fe5ec4
Merge pull request #463 from lightningpixel/feat/api-origins
lightningpixel Nov 18, 2026
5c9f675
fix(models): never treat a truncated weight download as complete
lightningpixel Nov 18, 2026
e12aaf1
fix(export): write the material and texture next to OBJ exports
lightningpixel Nov 18, 2026
3f32302
Merge pull request #465 from lightningpixel/fix/incomplete-model-weights
lightningpixel Nov 18, 2026
f815517
Merge pull request #466 from lightningpixel/fix/obj-export-texture
lightningpixel Nov 18, 2026
890386c
docs: design and plan for the Image Studio tool icons and crop
lightningpixel Nov 18, 2026
0f697a1
feat(image-ops): let crop take fractional edge percentages
lightningpixel Nov 18, 2026
0046b78
feat(image-studio): add the crop frame geometry
lightningpixel Nov 18, 2026
fb399ba
feat(image-studio): show the image ops as tool icons with an options bar
lightningpixel Nov 18, 2026
76d9476
feat(image-studio): crop by dragging a frame on the image
lightningpixel Nov 18, 2026
1ff6a1e
fix(image-studio): let a crop edge reach 100% so a thin far-side fram…
lightningpixel Nov 18, 2026
7e6b99a
fix(image-studio): leave Enter to the focused control and end a drag …
lightningpixel Nov 18, 2026
eb3bab5
docs: crop edges go up to 100%
lightningpixel Nov 18, 2026
08b19f6
Merge pull request #467 from lightningpixel/feat/image-studio-tools
lightningpixel Nov 18, 2026
7fbdc18
docs: design for the generation logo loader
lightningpixel Nov 18, 2026
6686eab
feat(generate): play with a 3D Modly logo while a mesh generates
lightningpixel Nov 18, 2026
14cbfd9
fix(generate): straight logo edges and a triangulated back face
lightningpixel Nov 18, 2026
81f826d
Merge pull request #468 from lightningpixel/feat/generation-logo-loader
lightningpixel Nov 18, 2026
6570cd3
dump version 0.5.0
lightningpixel Nov 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ Thumbs.db
# Local dev helpers
install.bat
launch.bat

# Local task notes (plans, lessons), never committed
/tasks/
18 changes: 18 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ pip install -r requirements.txt
uvicorn main:app --host 127.0.0.1 --port 8765 --reload
```

## Calling the API from other apps

Scripts, CLIs and other programs (curl, `modly-cli`, the MCP server, OrcaSlicer…) can call the API
with no token or setup.

**Web pages** are refused (403), so a site open in your browser cannot drive Modly. To let a web app
in, list its origin in `MODLY_ORIGINS` before starting Modly (comma-separated, `*` wildcards):

```bash
MODLY_ORIGINS="http://localhost:3000,chrome-extension://*" # or "*" for every page
```

`<img>` / `<video>` tags send no `Origin`, so the page's `Referer` is used instead. Browsers drop it
from an HTTPS page to the HTTP API: on an HTTPS site, add `crossorigin="anonymous"` to those tags.

The request's `Host` must be `localhost` or an IP address (this blocks DNS rebinding). To reach the
API by a machine name, list it in `MODLY_HOSTS`, e.g. `MODLY_HOSTS=jetson.local`.

## Key endpoints

| Method | Path | Description |
Expand Down
29 changes: 16 additions & 13 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,32 @@
import logging
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse
from fastapi import HTTPException

from services.stdio_utf8 import ensure_utf8_stdio
ensure_utf8_stdio() # must run before any print/logging hits the pipe

from routers import generation, model, optimize, status, settings, extensions, export, workflow_runs, agent, llm
from services import api_guard

from routers import generation, model, optimize, status, settings, extensions, export, workflow_runs, agent, llm, image


@asynccontextmanager
async def lifespan(app: FastAPI):
# Startup: initialize the registry (instantiates all adapters)
from services.generator_registry import generator_registry
generator_registry.initialize()
# Persisted run history at the workspace root; read per call so a relocated
# workspace is followed. Loading marks runs a previous backend left running as
# interrupted.
import services.generator_registry as registry
from services.run_history import RUN_HISTORY_FILENAME, run_history
run_history.start(lambda: registry.WORKSPACE_DIR / RUN_HISTORY_FILENAME)
yield
# Shutdown: unload all models and stop the local LLM server
# Shutdown: runs still in flight will never finish
run_history.stop()
# Unload all models and stop the local LLM server
generator_registry.unload_all()
from services.llm_server import llama_pool
llama_pool.unload_all(force=True)
Expand All @@ -36,19 +45,12 @@ def filter(self, record):

app = FastAPI(
title="Modly API",
version="0.4.3",
version="0.5.0",
lifespan=lifespan,
)

app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["*"],
allow_headers=["*"],
# drei's SplatLoader reads Content-Length to size its buffers; cross-origin
# JS can only see it when the server explicitly exposes the header.
expose_headers=["Content-Length"],
)
# Web pages off the API (MODLY_ORIGINS / MODLY_HOSTS), and CORS.
api_guard.configure(app)

app.include_router(status.router)
app.include_router(settings.router)
Expand All @@ -60,6 +62,7 @@ def filter(self, record):
app.include_router(workflow_runs.router, prefix="/workflow-runs")
app.include_router(agent.router)
app.include_router(llm.router, prefix="/llm")
app.include_router(image.router, prefix="/image")

# Serve generated files from workspace — dynamic so path changes take effect immediately
@app.get("/workspace/{full_path:path}")
Expand Down
56 changes: 40 additions & 16 deletions api/mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,41 @@
}
}
Requires Modly's FastAPI backend to be running on http://localhost:8765.
Requires Modly to be running. Its API is found through MODLY_API_URL, else the
port the app writes to <userData>/api-port, else http://127.0.0.1:8765.
"""

import asyncio
import json
import mimetypes
import os
import sys
from pathlib import Path

import httpx
from mcp.server import Server
from mcp.server.stdio import stdio_server
from mcp.types import Tool, TextContent

API_BASE = "http://localhost:8765"
def _modly_user_data() -> Path:
"""Electron's userData folder for Modly, where the app writes api-port."""
if sys.platform == "win32":
return Path(os.environ.get("APPDATA") or Path.home() / "AppData" / "Roaming") / "Modly"
if sys.platform == "darwin":
return Path.home() / "Library" / "Application Support" / "Modly"
return Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config") / "Modly"


def resolve_api_url() -> str:
"""MODLY_API_URL, else the port the running app wrote to api-port, else 8765."""
env = os.environ.get("MODLY_API_URL")
if env:
return env.rstrip("/")
try:
port = int((_modly_user_data() / "api-port").read_text().strip())
return f"http://127.0.0.1:{port}"
except (OSError, ValueError):
return "http://127.0.0.1:8765"

server = Server("modly")

Expand Down Expand Up @@ -229,12 +252,13 @@ async def list_tools() -> list[Tool]:

@server.call_tool()
async def call_tool(name: str, arguments: dict) -> list[TextContent]:
async with httpx.AsyncClient(timeout=60.0) as client:
api_url = resolve_api_url() # per call: the app may restart on another port
async with httpx.AsyncClient(base_url=api_url, timeout=60.0) as client:
try:
result = await _dispatch(client, name, arguments)
except httpx.ConnectError:
result = (
"Cannot connect to Modly API at http://localhost:8765. "
f"Cannot connect to Modly API at {api_url}. "
"Make sure Modly is running."
)
except httpx.HTTPStatusError as e:
Expand All @@ -247,15 +271,15 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:

async def _dispatch(client: httpx.AsyncClient, name: str, args: dict) -> str:
if name == "modly_list_models":
r = await client.get(f"{API_BASE}/model/all")
r = await client.get("/model/all")
r.raise_for_status()
models = [m for m in r.json() if m.get("downloaded")]
if not models:
return "No models downloaded yet. Download one from the Models tab in Modly."
return "\n".join(f"- {m['id']}: {m.get('name', m['id'])}" for m in models)

elif name == "modly_switch_model":
r = await client.post(f"{API_BASE}/model/switch", params={"model_id": args["model_id"]})
r = await client.post("/model/switch", params={"model_id": args["model_id"]})
r.raise_for_status()
return f"Switched active model to: {args['model_id']}"

Expand All @@ -273,7 +297,7 @@ async def _dispatch(client: httpx.AsyncClient, name: str, args: dict) -> str:
form_data["model_id"] = args["model_id"]

r = await client.post(
f"{API_BASE}/generate/from-image",
"/generate/from-image",
files={"image": (filename, img_bytes, mime)},
data=form_data,
timeout=30.0,
Expand All @@ -286,7 +310,7 @@ async def _dispatch(client: httpx.AsyncClient, name: str, args: dict) -> str:
)

elif name == "modly_get_generation_status":
r = await client.get(f"{API_BASE}/generate/status/{args['job_id']}")
r = await client.get(f"/generate/status/{args['job_id']}")
r.raise_for_status()
s = r.json()
parts = [f"Status: {s['status']}", f"Progress: {s.get('progress', 0)}%"]
Expand All @@ -300,14 +324,14 @@ async def _dispatch(client: httpx.AsyncClient, name: str, args: dict) -> str:

elif name in ("modly_inspect_mesh", "modly_suggest_fixes"):
op = name.removeprefix("modly_")
r = await client.post(f"{API_BASE}/optimize/op/{op}", json={"path": args["path"]})
r = await client.post(f"/optimize/op/{op}", json={"path": args["path"]})
r.raise_for_status()
return json.dumps(r.json(), indent=2)

elif name == "modly_repair_mesh":
params = {} if args.get("fill_holes") is None else {"fill_holes": bool(args["fill_holes"])}
r = await client.post(
f"{API_BASE}/optimize/op/repair_mesh",
"/optimize/op/repair_mesh",
json={"path": args["path"], "params": params},
)
r.raise_for_status()
Expand All @@ -316,7 +340,7 @@ async def _dispatch(client: httpx.AsyncClient, name: str, args: dict) -> str:
elif name == "modly_arrange_mesh":
scale = {k: args[k] for k in ("size", "unit", "dimension") if args.get(k) is not None}
r = await client.post(
f"{API_BASE}/optimize/arrange",
"/optimize/arrange",
json={
"path": args["path"],
"steps": args.get("steps") or [],
Expand All @@ -328,7 +352,7 @@ async def _dispatch(client: httpx.AsyncClient, name: str, args: dict) -> str:

elif name == "modly_decimate_mesh":
r = await client.post(
f"{API_BASE}/optimize/mesh",
"/optimize/mesh",
json={"path": args["path"], "target_faces": args["target_faces"]},
)
r.raise_for_status()
Expand All @@ -337,26 +361,26 @@ async def _dispatch(client: httpx.AsyncClient, name: str, args: dict) -> str:

elif name == "modly_smooth_mesh":
r = await client.post(
f"{API_BASE}/optimize/smooth",
"/optimize/smooth",
json={"path": args["path"], "iterations": args["iterations"]},
)
r.raise_for_status()
data = r.json()
return f"Smoothed mesh ({args['iterations']} iterations). New file: {data.get('url', '')}"

elif name == "modly_import_mesh":
r = await client.post(f"{API_BASE}/optimize/import-by-path", json={"path": args["path"]})
r = await client.post("/optimize/import-by-path", json={"path": args["path"]})
r.raise_for_status()
data = r.json()
return f"Mesh imported. URL: {data.get('url', '')}"

elif name == "modly_unload_models":
r = await client.post(f"{API_BASE}/model/unload-all")
r = await client.post("/model/unload-all")
r.raise_for_status()
return "All 3D generation models unloaded from VRAM."

elif name == "modly_get_settings":
r = await client.get(f"{API_BASE}/settings/paths")
r = await client.get("/settings/paths")
r.raise_for_status()
data = r.json()
return f"Models directory: {data.get('models_dir')}\nWorkspace directory: {data.get('workspace_dir')}"
Expand Down
3 changes: 3 additions & 0 deletions api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ pymeshlab>=2023.12
# trimesh's graph engine: connected parts, hole loops and vertex merging in
# inspect_mesh / repair_mesh. Optional for trimesh, so never pulled in by it.
scipy>=1.10
# trimesh decodes glTF images with Pillow. Optional for trimesh: without it,
# every op that reloads a mesh silently drops its textures.
Pillow>=10.0

# Model downloads (HuggingFace)
huggingface_hub>=0.27.0
Expand Down
Loading
Loading