File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7070 personal_token : ${{ secrets.MODELSCRIPT_SITE_DEPLOY_PAT }}
7171 external_repository : modelscript/modelscript.github.io
7272 publish_dir : ./packages/site/build/client
73+ - name : Cache WebLLM Model
74+ id : cache-model
75+ uses : actions/cache@v4
76+ with :
77+ path : packages/ide/models
78+ key : ${{ runner.os }}-qwen3-0.6b-q4f16_1-mlc-v1
79+ - name : Download WebLLM Model
80+ if : steps.cache-model.outputs.cache-hit != 'true'
81+ run : bash packages/ide/scripts/download-model.sh
7382 - name : Build IDE Static
7483 if : github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
7584 run : npm run build-static --workspace=@modelscript/ide
85+ - name : Copy model to IDE static output
86+ if : github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
87+ run : cp -r packages/ide/models packages/ide/dist/static/api/models
7688 - name : Deploy IDE
7789 uses : peaceiris/actions-gh-pages@v4
7890 if : github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
Original file line number Diff line number Diff line change @@ -119,6 +119,14 @@ EXPOSE 80
119119# ==============================================================================
120120# IDE
121121# ==============================================================================
122+
123+ # Download WebLLM model weights (cached layer)
124+ FROM node:22-alpine AS download-model
125+ RUN apk add --no-cache curl bash
126+ WORKDIR /models
127+ COPY packages/ide/scripts/download-model.sh /tmp/download-model.sh
128+ RUN bash /tmp/download-model.sh /models
129+
122130FROM deps AS build-ide-false
123131COPY scripts scripts
124132COPY packages/core packages/core
@@ -164,6 +172,7 @@ COPY --from=build-ide /app/packages/vscode/syntaxes packages/vscode/syntaxes
164172COPY --from=build-ide /app/packages/vscode/language-configuration.json packages/vscode/
165173COPY --from=build-ide /app/packages/morsel/public packages/morsel/public
166174COPY --from=build-ide /app/node_modules/@vscode node_modules/@vscode
175+ COPY --from=download-model /models packages/ide/models
167176EXPOSE 3200
168177ENV NODE_ENV=production
169178ENV PORT=3200
Original file line number Diff line number Diff line change @@ -92,6 +92,16 @@ This launches:
9292| API | http://localhost:3000 | REST API for simulation, publishing, queries |
9393| IDE (VS Code Web) | http://localhost:3200 | Browser-based VS Code with Modelica support |
9494
95+ #### AI Chat (Optional)
96+
97+ The IDE includes a browser-local AI assistant powered by WebLLM (Qwen3-0.6B). To enable it, download the model weights (~ 350 MB, one-time):
98+
99+ ``` bash
100+ npm run download-model --workspace=@modelscript/ide
101+ ```
102+
103+ Once downloaded, restart ` npm run dev ` and open the ** ModelScript AI** panel in the IDE sidebar.
104+
95105### CLI Usage
96106
97107After building, the CLI is available as ` msc ` :
Original file line number Diff line number Diff line change 1010 "build-server" : " npx esbuild src/server.ts --bundle --platform=node --format=esm --outfile=dist/server.js --external:express --external:http-proxy-middleware" ,
1111 "build-static" : " npm run download-vscode && npm run build-github-fs && npx tsx src/build-static.ts" ,
1212 "dev" : " npm run download-vscode && npx tsx src/server.ts" ,
13+ "download-model" : " bash scripts/download-model.sh" ,
1314 "download-vscode" : " npx tsx src/download-vscode.ts" ,
1415 "lint" : " eslint src --ext ts"
1516 },
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # Download Qwen3-0.6B-q4f16_1-MLC model weights and WASM for WebLLM.
3+ # Files are cached — re-running is a no-op if all files already exist.
4+ #
5+ # Usage: ./scripts/download-model.sh [target_dir]
6+ # Default target_dir: packages/ide/models
7+
8+ set -euo pipefail
9+
10+ SCRIPT_DIR=" $( cd " $( dirname " $0 " ) " && pwd) "
11+ REPO_ROOT=" $( cd " $SCRIPT_DIR /.." && pwd) "
12+ TARGET=" ${1:- $REPO_ROOT / models} "
13+
14+ MODEL_DIR=" $TARGET /Qwen3-0.6B-q4f16_1-MLC"
15+ WASM_FILE=" $TARGET /Qwen3-0.6B-q4f16_1-ctx4k_cs1k-webgpu.wasm"
16+
17+ HF_BASE=" https://huggingface.co/mlc-ai/Qwen3-0.6B-q4f16_1-MLC/resolve/main"
18+ WASM_URL=" https://huggingface.co/mlc-ai/binary-mlc-llm-libs/resolve/main/Qwen3-0.6B-q4f16_1-ctx4k_cs1k-webgpu.wasm"
19+
20+ # Files to download from the HuggingFace model repo
21+ MODEL_FILES=(
22+ mlc-chat-config.json
23+ ndarray-cache.json
24+ tokenizer.json
25+ tokenizer_config.json
26+ vocab.json
27+ merges.txt
28+ params_shard_0.bin
29+ params_shard_1.bin
30+ params_shard_2.bin
31+ params_shard_3.bin
32+ params_shard_4.bin
33+ params_shard_5.bin
34+ params_shard_6.bin
35+ params_shard_7.bin
36+ params_shard_8.bin
37+ )
38+
39+ echo " ==> Downloading Qwen3-0.6B-q4f16_1-MLC model to $TARGET "
40+
41+ mkdir -p " $MODEL_DIR "
42+
43+ # Download model files
44+ for file in " ${MODEL_FILES[@]} " ; do
45+ if [ -f " $MODEL_DIR /$file " ]; then
46+ echo " [cached] $file "
47+ else
48+ echo " [downloading] $file "
49+ curl -fSL --retry 3 " $HF_BASE /$file " -o " $MODEL_DIR /$file "
50+ fi
51+ done
52+
53+ # Download WASM
54+ if [ -f " $WASM_FILE " ]; then
55+ echo " [cached] $( basename " $WASM_FILE " ) "
56+ else
57+ echo " [downloading] $( basename " $WASM_FILE " ) "
58+ curl -fSL --retry 3 " $WASM_URL " -o " $WASM_FILE "
59+ fi
60+
61+ echo " ==> Model download complete"
You can’t perform that action at this time.
0 commit comments