Spaces:
Runtime error
Runtime error
refactor: remove SKIP_LLAMA_CPP_BUILD argument and related logic from workflows and configuration
Browse files- .github/workflows/deploy-prod.yml +0 -1
- .github/workflows/lint-and-test.yml +0 -1
- Dockerfile +0 -2
- vite.config.ts +0 -67
.github/workflows/deploy-prod.yml
CHANGED
|
@@ -49,7 +49,6 @@ jobs:
|
|
| 49 |
APP_BASE=/chat
|
| 50 |
PUBLIC_APP_COLOR=yellow
|
| 51 |
PUBLIC_COMMIT_SHA=${{ env.GITHUB_SHA_SHORT }}
|
| 52 |
-
SKIP_LLAMA_CPP_BUILD=true
|
| 53 |
deploy:
|
| 54 |
name: Deploy on prod
|
| 55 |
runs-on: ubuntu-latest
|
|
|
|
| 49 |
APP_BASE=/chat
|
| 50 |
PUBLIC_APP_COLOR=yellow
|
| 51 |
PUBLIC_COMMIT_SHA=${{ env.GITHUB_SHA_SHORT }}
|
|
|
|
| 52 |
deploy:
|
| 53 |
name: Deploy on prod
|
| 54 |
runs-on: ubuntu-latest
|
.github/workflows/lint-and-test.yml
CHANGED
|
@@ -53,7 +53,6 @@ jobs:
|
|
| 53 |
run: |
|
| 54 |
docker build \
|
| 55 |
--build-arg INCLUDE_DB=true \
|
| 56 |
-
--build-arg SKIP_LLAMA_CPP_BUILD=true \
|
| 57 |
-t chat-ui-test:latest .
|
| 58 |
|
| 59 |
- name: Run Docker container
|
|
|
|
| 53 |
run: |
|
| 54 |
docker build \
|
| 55 |
--build-arg INCLUDE_DB=true \
|
|
|
|
| 56 |
-t chat-ui-test:latest .
|
| 57 |
|
| 58 |
- name: Run Docker container
|
Dockerfile
CHANGED
|
@@ -52,9 +52,7 @@ COPY --link --chown=1000 package-lock.json package.json ./
|
|
| 52 |
|
| 53 |
ARG APP_BASE=
|
| 54 |
ARG PUBLIC_APP_COLOR=blue
|
| 55 |
-
ARG SKIP_LLAMA_CPP_BUILD
|
| 56 |
ENV BODY_SIZE_LIMIT=15728640
|
| 57 |
-
ENV SKIP_LLAMA_CPP_BUILD=$SKIP_LLAMA_CPP_BUILD
|
| 58 |
|
| 59 |
RUN --mount=type=cache,target=/app/.npm \
|
| 60 |
npm set cache /app/.npm && \
|
|
|
|
| 52 |
|
| 53 |
ARG APP_BASE=
|
| 54 |
ARG PUBLIC_APP_COLOR=blue
|
|
|
|
| 55 |
ENV BODY_SIZE_LIMIT=15728640
|
|
|
|
| 56 |
|
| 57 |
RUN --mount=type=cache,target=/app/.npm \
|
| 58 |
npm set cache /app/.npm && \
|
vite.config.ts
CHANGED
|
@@ -2,10 +2,6 @@ import { sveltekit } from "@sveltejs/kit/vite";
|
|
| 2 |
import Icons from "unplugin-icons/vite";
|
| 3 |
import { promises } from "fs";
|
| 4 |
import { defineConfig } from "vitest/config";
|
| 5 |
-
import { resolve } from "path";
|
| 6 |
-
import fs from "fs-extra";
|
| 7 |
-
import { spawn } from "child_process";
|
| 8 |
-
import type { Plugin } from "vite";
|
| 9 |
|
| 10 |
// used to load fonts server side for thumbnail generation
|
| 11 |
function loadTTFAsArrayBuffer() {
|
|
@@ -20,68 +16,6 @@ function loadTTFAsArrayBuffer() {
|
|
| 20 |
},
|
| 21 |
};
|
| 22 |
}
|
| 23 |
-
const isViteNode = process.argv.some((arg) => arg.includes("vite-node")) || !!process.env.VITE_NODE;
|
| 24 |
-
const skipLlamaCppBuild = process.env.SKIP_LLAMA_CPP_BUILD === "true";
|
| 25 |
-
const shouldCopyLlama =
|
| 26 |
-
process.env.npm_lifecycle_event === "build" && !isViteNode && !skipLlamaCppBuild; // Copy node-llama-cpp/llama files to build output
|
| 27 |
-
|
| 28 |
-
function copyLlamaFiles() {
|
| 29 |
-
return {
|
| 30 |
-
name: "copy-llama-files",
|
| 31 |
-
apply: "build" as const,
|
| 32 |
-
closeBundle: async () => {
|
| 33 |
-
try {
|
| 34 |
-
// Run npx command first and pipe IO
|
| 35 |
-
console.log("Running node-llama-cpp source download...");
|
| 36 |
-
|
| 37 |
-
await new Promise((resolve, reject) => {
|
| 38 |
-
const npxProcess = spawn("npx", ["--no", "node-llama-cpp", "source", "download"], {
|
| 39 |
-
stdio: "inherit", // Pipe all IO to parent process
|
| 40 |
-
shell: true,
|
| 41 |
-
});
|
| 42 |
-
|
| 43 |
-
npxProcess.on("close", (code) => {
|
| 44 |
-
if (code === 0) {
|
| 45 |
-
console.log("✓ Successfully downloaded llama source files");
|
| 46 |
-
resolve(code);
|
| 47 |
-
} else {
|
| 48 |
-
reject(new Error(`npx command failed with code ${code}`));
|
| 49 |
-
}
|
| 50 |
-
});
|
| 51 |
-
|
| 52 |
-
npxProcess.on("error", (err) => {
|
| 53 |
-
reject(err);
|
| 54 |
-
});
|
| 55 |
-
});
|
| 56 |
-
|
| 57 |
-
const sourcePath = resolve("node_modules/node-llama-cpp/llama");
|
| 58 |
-
const destPath = resolve("build/server/llama");
|
| 59 |
-
|
| 60 |
-
// Ensure destination directory exists
|
| 61 |
-
await fs.ensureDir(destPath);
|
| 62 |
-
|
| 63 |
-
// Copy files - using a filter to prevent copying files to subdirectories of themselves
|
| 64 |
-
await fs.copy(sourcePath, destPath, {
|
| 65 |
-
filter: (src, dest) => {
|
| 66 |
-
// Skip if source path is inside destination path or vice versa
|
| 67 |
-
if (src.includes(destPath) || dest.includes(sourcePath)) {
|
| 68 |
-
console.log(`Skipping problematic copy: ${src} -> ${dest}`);
|
| 69 |
-
return false;
|
| 70 |
-
}
|
| 71 |
-
return true;
|
| 72 |
-
},
|
| 73 |
-
overwrite: true,
|
| 74 |
-
dereference: true,
|
| 75 |
-
});
|
| 76 |
-
|
| 77 |
-
console.log("✓ Successfully copied llama files to build output");
|
| 78 |
-
} catch (error) {
|
| 79 |
-
console.error("Error in llama files process:", error);
|
| 80 |
-
}
|
| 81 |
-
},
|
| 82 |
-
} satisfies Plugin;
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
export default defineConfig({
|
| 86 |
plugins: [
|
| 87 |
sveltekit(),
|
|
@@ -89,7 +23,6 @@ export default defineConfig({
|
|
| 89 |
compiler: "svelte",
|
| 90 |
}),
|
| 91 |
loadTTFAsArrayBuffer(),
|
| 92 |
-
...(shouldCopyLlama ? [copyLlamaFiles()] : []),
|
| 93 |
],
|
| 94 |
// Allow external access via ngrok tunnel host
|
| 95 |
server: {
|
|
|
|
| 2 |
import Icons from "unplugin-icons/vite";
|
| 3 |
import { promises } from "fs";
|
| 4 |
import { defineConfig } from "vitest/config";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
// used to load fonts server side for thumbnail generation
|
| 7 |
function loadTTFAsArrayBuffer() {
|
|
|
|
| 16 |
},
|
| 17 |
};
|
| 18 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
export default defineConfig({
|
| 20 |
plugins: [
|
| 21 |
sveltekit(),
|
|
|
|
| 23 |
compiler: "svelte",
|
| 24 |
}),
|
| 25 |
loadTTFAsArrayBuffer(),
|
|
|
|
| 26 |
],
|
| 27 |
// Allow external access via ngrok tunnel host
|
| 28 |
server: {
|