first commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { createRequire } from 'node:module';
|
||||
import path from 'node:path';
|
||||
|
||||
const harnessPath = process.env.JARVIS_HARNESS_PATH || '/home/raven/dev/agent-harness';
|
||||
const require = createRequire(import.meta.url);
|
||||
process.env.QVAC_CONFIG_PATH ||= path.resolve(new URL('../qvac.config.json', import.meta.url).pathname);
|
||||
const Agent = require(path.join(harnessPath, 'index.js'));
|
||||
|
||||
let loadPromise = null;
|
||||
let ownerCount = 0;
|
||||
|
||||
export const QVAC_MASTER = Object.freeze({
|
||||
configPath: process.env.QVAC_CONFIG_PATH,
|
||||
model: process.env.JARVIS_QVAC_MODEL || 'qwen3.5-4b',
|
||||
device: 'gpu',
|
||||
gpuLayers: 99,
|
||||
});
|
||||
|
||||
export async function acquireQvac() {
|
||||
ownerCount += 1;
|
||||
if (!loadPromise) {
|
||||
loadPromise = Agent.engine.load({
|
||||
model: QVAC_MASTER.model,
|
||||
tools: true,
|
||||
device: 'gpu',
|
||||
gpu_layers: QVAC_MASTER.gpuLayers,
|
||||
mmprojUseGpu: true,
|
||||
}).then((loaded) => {
|
||||
if (loaded.device !== 'gpu') {
|
||||
throw new Error(`Jarvis requires GPU QVAC inference; loaded device was ${loaded.device}`);
|
||||
}
|
||||
return loaded;
|
||||
}).catch((error) => {
|
||||
loadPromise = null;
|
||||
ownerCount = Math.max(0, ownerCount - 1);
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
return loadPromise;
|
||||
}
|
||||
|
||||
export function releaseQvac() { ownerCount = Math.max(0, ownerCount - 1); }
|
||||
|
||||
export async function closeQvac() {
|
||||
if (ownerCount > 0) return;
|
||||
loadPromise = null;
|
||||
await Agent.engine.close();
|
||||
}
|
||||
|
||||
export function qvacStatus() {
|
||||
return { ...QVAC_MASTER, owners: ownerCount, loaded: Agent.engine.getLoaded() };
|
||||
}
|
||||
|
||||
export { Agent };
|
||||
Reference in New Issue
Block a user