char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
e21152dc9
char/aliceai-t5-moe
1import { BUILD_CONFIG } from '../src/lib/constants/pwa.constants' ; 2import { existsSync , writeFileSync } from 'node:fs' ; 3import { resolve } from 'path' ; 4import type { Plugin } from 'vite' ; 5 6let processed = false ; 7 8const OUTPUT_DIR = process . env . LLAMA_UI_OUT_DIR ?? BUILD_CONFIG . OUTPUT_DIR ; 9 10/** 11* Write build.json with the llama.cpp release build number. 12* 13* LLAMA_BUILD_NUMBER is passed from CMake -> npm -> vite via env var. 14* Used for display of the current llama-server release (e.g. "b1234"). 15*/ 16export function buildInfoPlugin () :Plugin { 17return { 18apply :'build' , 19closeBundle () { 20setTimeout (() => { 21try { 22if ( processed ) return ; 23 24processed = true ; 25 26const buildNumber = process . env . LLAMA_BUILD_NUMBER || 'b0000' ; 27const outDir = resolve ( OUTPUT_DIR ); 28const indexPath = resolve ( outDir , 'index.html' ); 29 30if ( ! existsSync ( indexPath )) return ; 31 32const buildJsonPath = resolve ( outDir , 'build.json' ); 33 34writeFileSync ( buildJsonPath , JSON . stringify ({ version :buildNumber }), 'utf-8' ); 35console . log ( `Created build.json (version: ${ buildNumber } )` ); 36} catch ( error ) { 37console . error ( 'Failed to write build.json:' , error ); 38} 39}, 100 ); 40}, 41name :'llamacpp:build-info' 42}; 43}