@felipenmoura/laya-node 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.dockerignore ADDED
@@ -0,0 +1,7 @@
1
+ node_modules
2
+ venv
3
+ .env
4
+ .daemon.pid
5
+ .git
6
+ .gitignore
7
+ *.log
package/Dockerfile ADDED
@@ -0,0 +1,40 @@
1
+ # Use a Python base image because AI models require heavy Python dependencies
2
+ FROM python:3.10-slim
3
+
4
+ # Install Node.js (required for the wrapper)
5
+ RUN apt-get update && apt-get install -y curl && \
6
+ curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
7
+ apt-get install -y nodejs && \
8
+ npm install -g pnpm && \
9
+ rm -rf /var/lib/apt/lists/*
10
+
11
+ # Set the working directory
12
+ WORKDIR /app
13
+
14
+ # Copy package configurations
15
+ COPY package.json pnpm-lock.yaml* ./
16
+
17
+ # Install node dependencies
18
+ # (The postinstall script automatically skips the interactive python setup in Docker)
19
+ RUN pnpm install
20
+
21
+ # Copy application files
22
+ COPY . .
23
+
24
+ # Explicitly setup the python virtual environment inside the container
25
+ RUN python -m venv venv && \
26
+ ./venv/bin/pip install --no-cache-dir fastapi uvicorn laya
27
+
28
+ # Pre-download the Laya model weights during the docker build to save time on container startup
29
+ RUN ./venv/bin/python -c "import warnings; warnings.filterwarnings('ignore'); from laya import Router; Router(preload=True)"
30
+
31
+ # Set environment variables
32
+ ENV PORT=4000
33
+ ENV MAX_LEN=8192
34
+ ENV SECRET_API_KEY=""
35
+
36
+ # Expose the API port
37
+ EXPOSE 4000
38
+
39
+ # Start the Node wrapper
40
+ CMD ["pnpm", "start"]
package/README.md CHANGED
@@ -66,6 +66,20 @@ pnpm stop
66
66
  npm run stop
67
67
  ```
68
68
 
69
+ ### Running with Docker
70
+
71
+ You can easily containerize this wrapper and run it anywhere using Docker. The included `Dockerfile` will automatically fetch the model weights during the build phase so container startups remain fast.
72
+
73
+ To build the image:
74
+ ```bash
75
+ docker build -t laya-node-wrapper .
76
+ ```
77
+
78
+ To run the container (exposing port 4000):
79
+ ```bash
80
+ docker run -p 4000:4000 -e SECRET_API_KEY="my-secure-key" laya-node-wrapper
81
+ ```
82
+
69
83
  ## Making Predictions
70
84
 
71
85
  Once running, send a `POST` request to `/predict`. Be sure to include your Bearer token if you enabled API Key protection during setup.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@felipenmoura/laya-node",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Node wrapper for laya text classification",
5
5
  "license": "MIT",
6
6
  "author": "Felipe N. Moura",