diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1c1db71 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM node:18-buster-slim + +ARG MODEL_NAME=alpaca +ARG MODEL_VERSION=7B + +EXPOSE 3000 + +RUN apt-get update \ + && apt-get install -y \ + build-essential \ + curl \ + g++ \ + make \ + python3-venv \ + software-properties-common + +RUN apt-get update + +COPY . . +WORKDIR /root/ + +# Install dalai and its dependencies +RUN npm install + +# # Install a model +RUN npx dalai ${MODEL_NAME} install ${MODEL_VERSION} + +# # Run the dalai server +ENTRYPOINT [ "npx", "dalai", "serve" ] \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..d3972ab --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,11 @@ +version: '3.9' + +services: + serve-dalai-7b: + build: + context: . + args: + MODEL_NAME: alpaca + MODEL_VERSION: 7B + ports: + - "3000:3000" diff --git a/index.js b/index.js index a030ad5..5eabb7c 100644 --- a/index.js +++ b/index.js @@ -304,19 +304,20 @@ class Dalai { // temporary - let models_path = path.resolve(engine.home, "models") - let temp_path = path.resolve(this.home, "tmp") - let temp_models_path = path.resolve(temp_path, "models") - await fs.promises.mkdir(temp_path, { recursive: true }).catch((e) => { }) + let models_path = path.resolve(engine.home, "models"); + await fs.promises.mkdir(models_path, { recursive: true }).catch((e) => { }); + let temp_path = path.resolve(this.home, "tmp"); + let temp_models_path = path.resolve(temp_path, "models"); + await fs.promises.mkdir(temp_path, { recursive: true }).catch((e) => { }); // 1. move the models folder to ../tmp - await fs.promises.rename(models_path, temp_models_path) + await fs.promises.rename(models_path, temp_models_path); // 2. wipe out the folder - await fs.promises.rm(engine.home, { recursive: true }).catch((e) => { console.log(e) }) + await fs.promises.rm(models_path, { recursive: true }).catch((e) => { console.log(e) }); // 3. install engine - await this.add(core) + await this.add(core); // 4. move back the files inside /tmp - await fs.promises.rename(temp_models_path, models_path) - + await fs.promises.rename(temp_models_path, models_path); + // next add the models let res = await this.cores[core].add(...models) return res