2 Commits
0.2.1 ... 0.2.2

Author SHA1 Message Date
ca5a2334bb bump 2.2.0
All checks were successful
Publish Library / Build NPM Project (push) Successful in 43s
Publish Library / Tag Version (push) Successful in 11s
2025-12-22 11:02:53 -05:00
3cd7b12f5f Configure model path for all libraries
Some checks failed
Publish Library / Tag Version (push) Has been cancelled
Publish Library / Build NPM Project (push) Has been cancelled
2025-12-22 11:02:24 -05:00
4 changed files with 6 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@ztimson/ai-utils",
"version": "0.2.1",
"version": "0.2.2",
"description": "AI Utility library",
"author": "Zak Timson",
"license": "MIT",

View File

@@ -8,9 +8,9 @@ export type AiOptions = LLMOptions & {
binary: string;
/** Model: `ggml-base.en.bin` */
model: string;
/** Path to models */
path: string;
}
/** Path to models */
path: string;
}
export class Ai {
@@ -25,6 +25,7 @@ export class Ai {
vision!: Vision;
constructor(public readonly options: AiOptions) {
process.env.TRANSFORMERS_CACHE = options.path;
this.audio = new Audio(this);
this.language = new LLM(this);
this.vision = new Vision(this);

View File

@@ -48,7 +48,7 @@ export class Audio {
async downloadAsrModel(model: string = this.whisperModel): Promise<string> {
if(!this.ai.options.whisper?.binary) throw new Error('Whisper not configured');
if(!model.endsWith('.bin')) model += '.bin';
const p = Path.join(this.ai.options.whisper.path, model);
const p = Path.join(this.ai.options.path, model);
if(await fs.stat(p).then(() => true).catch(() => false)) return p;
if(!!this.downloads[model]) return this.downloads[model];
this.downloads[model] = fetch(`https://huggingface.co/ggerganov/whisper.cpp/resolve/main/${model}`)

View File

@@ -15,7 +15,7 @@ export class Vision {
return {
abort: () => { worker?.terminate(); },
response: new Promise(async res => {
worker = await createWorker('eng');
worker = await createWorker('eng', 1, {langPath: this.ai.options.path});
const {data} = await worker.recognize(path);
await worker.terminate();
res(data.text.trim() || null);