Skip to content

Commit 244e3ac

Browse files
authored
Merge pull request #1243 from getlarge/moltnet/00bbac38-2c65-4cf6-8e2e-a70f1a1d1a04/consider-dropping-baked-in-embedding-model-in-favor-of-start
feat(rest-api): drop baked-in embedding model
2 parents a80d3ce + 6f24da9 commit 244e3ac

3 files changed

Lines changed: 6 additions & 33 deletions

File tree

apps/rest-api/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,13 @@ LABEL org.opencontainers.image.description="MoltNet REST API"
5555
LABEL org.opencontainers.image.licenses="MIT"
5656

5757
ENV NODE_ENV=production \
58-
EMBEDDING_CACHE_DIR=/app/dist/models \
59-
EMBEDDING_ALLOW_REMOTE_MODELS=false
58+
EMBEDDING_CACHE_DIR=/app/models \
59+
EMBEDDING_ALLOW_REMOTE_MODELS=true
6060
WORKDIR /app
6161

6262
# Runtime tree: app + production node_modules, linux-native.
6363
# `pnpm deploy` copies only the package's `files` glob (dist/, public/) plus
6464
# the trimmed node_modules; dev configs and source are excluded automatically.
65-
# `dist/models/` rides along inside `dist/` (host-built by `download-model`).
6665
COPY --from=build /out ./
6766

6867
# Drizzle migration SQL — consumed by the migrate entrypoint and Fly.io

apps/rest-api/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ docker compose --env-file .env.local up -d
1717

1818
### Embedding model (one-time setup)
1919

20-
The API eagerly warms the ONNX embedding pipeline on startup. The model must be
21-
pre-downloaded locally before running in offline mode.
20+
The API eagerly warms the ONNX embedding pipeline on startup. By default, the model will be downloaded from Hugging Face at startup time.
21+
22+
For offline development or to avoid repeated downloads, you can pre-download the model:
2223

2324
**Why `apps/rest-api/models/` and not the repo root?**
2425
pnpm sets the process cwd to `apps/rest-api/` when running the dev script, so

apps/rest-api/package.json

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -111,36 +111,9 @@
111111
"{projectRoot}/dist/migrate.js"
112112
]
113113
},
114-
"download-model": {
115-
"cache": true,
116-
"dependsOn": [
117-
"build"
118-
],
119-
"executor": "nx:run-commands",
120-
"inputs": [
121-
{
122-
"runtime": "node --version"
123-
},
124-
"{workspaceRoot}/tools/download-embedding-model.mjs",
125-
{
126-
"externalDependencies": [
127-
"@huggingface/transformers",
128-
"onnxruntime-node"
129-
]
130-
}
131-
],
132-
"options": {
133-
"command": "node tools/download-embedding-model.mjs --cache-dir apps/rest-api/dist/models",
134-
"cwd": "{workspaceRoot}"
135-
},
136-
"outputs": [
137-
"{projectRoot}/dist/models"
138-
]
139-
},
140114
"docker:build": {
141115
"dependsOn": [
142-
"build:migrate",
143-
"download-model"
116+
"build:migrate"
144117
]
145118
},
146119
"e2e": {

0 commit comments

Comments
 (0)