Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.
TypeScript ai-meeting-assistantai-notetakerelectrongranola-alternativelinuxllama-cpplocal-ailocal-firstmacosmcpmeeting-minutesmeeting-notesoffline-firstopen-sourceprivacyspeech-to-texttranscriptionwhisperwhisper-cppwindows
Notes: when the graphics say the notes can't fit even with nothing on them (an Intel Arc), the model runs on the processor instead of every summary failing (#57)
christianmatafe3403dd695
diff --git a/app/src/engine/llm.ts b/app/src/engine/llm.tsindex 1bd8eaf5..57178a97 100644--- a/app/src/engine/llm.ts+++ b/app/src/engine/llm.ts@@ -14,6 +14,8 @@ const toHistory = (messages: EngineMessage[]): ChatHistoryItem[] =>*/export function createLlm() {let llama: Llama | undefined+ /** the processor alone, when the graphics have no room at all (#57) */+ let cpuLlama: Llama | undefinedlet model: LlamaModel | undefinedlet context: LlamaContext | undefined/** One sequence for the model's whole life: a request that starts like the last one only reads what's new */@@ -71,15 +73,22 @@ export function createLlm() {// notes' context then doesn't fit (InsufficientMemoryError, every summary failing). So: load again leaving room for// the smallest context we accept, then with nothing on the card. A computer where it fits loads once, as before.// A model that doesn't fit on the card at all can fail to load outright (#37): that gets the same fewer layers.- for (const gpuLayers of [undefined, { fitContext: { contextSize: size.min } }, 0] as const) {- try { model = await l.loadModel(gpuLayers === undefined ? { modelPath } : { modelPath, gpuLayers }) } catch (e) {- if (gpuLayers === 0) throw e- console.warn('the notes model did not load on the graphics card; loading it again with fewer layers there', (e as Error).message)+ // Integrated graphics can say the context won't fit even with no layers on them (an Intel Arc, #57): last, the+ // graphics are left out altogether and the processor does it all.+ const steps: Array<{ cpu?: true; gpuLayers?: { fitContext: { contextSize: number } } | 0 }> =+ [{}, { gpuLayers: { fitContext: { contextSize: size.min } } }, { gpuLayers: 0 }, ...(l.gpu ? [{ cpu: true as const }] : [])]+ let used = l+ for (const [i, step] of steps.entries()) {+ const last = i === steps.length - 1+ used = step.cpu ? (cpuLlama ??= await getLlama({ gpu: false })) : l+ try { model = await used.loadModel(step.gpuLayers === undefined ? { modelPath } : { modelPath, gpuLayers: step.gpuLayers }) } catch (e) {+ if (last) throw e+ console.warn('the notes model did not load; loading it again with fewer layers on the graphics', (e as Error).message)continue}- try { context = await model.createContext({ contextSize: size, ...threads(l) }); break } catch (e) {- if (!(e instanceof InsufficientMemoryError) || gpuLayers === 0 || model.gpuLayers === 0) throw e- console.warn('the notes did not fit next to the model on the graphics card; loading it again with fewer layers there', e.message)+ try { context = await model.createContext({ contextSize: size, ...threads(used) }); break } catch (e) {+ if (!(e instanceof InsufficientMemoryError) || last) throw e+ console.warn('the notes did not fit next to the model; loading it again with fewer layers on the graphics', e.message)await model.dispose(); model = undefined}}@@ -87,7 +96,7 @@ export function createLlm() {main = context.getSequence()// the first evaluation pages the weights in from disk: pay it here, not on the first word of the notesawait main.evaluateWithoutGeneratingNewTokens(model.tokenize('Hello'))- return { contextSize: context.contextSize, gpu: model.gpuLayers === 0 ? false : l.gpu, gpuLayers: model.gpuLayers }+ return { contextSize: context.contextSize, gpu: model.gpuLayers === 0 ? false : used.gpu, gpuLayers: model.gpuLayers }},count(texts: string[]): number[] {if (!model) throw new Error('No model loaded')diff --git a/app/test/llm.test.ts b/app/test/llm.test.tsindex 5ac3307f..c38bff8f 100644--- a/app/test/llm.test.ts+++ b/app/test/llm.test.ts@@ -2,17 +2,17 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'import { Gemma4ChatWrapper, type LlamaChatSessionOptions } from 'node-llama-cpp'import { createLlm } from '../src/engine/llm'-const fake = vi.hoisted(() => ({ architecture: 'gemma4', sessions: [] as unknown[], loads: [] as unknown[], disposed: 0, contextFails: 0, loadFails: 0, contextError: undefined as (() => Error) | undefined }))+const fake = vi.hoisted(() => ({ architecture: 'gemma4', sessions: [] as unknown[], loads: [] as unknown[], llamas: [] as unknown[], disposed: 0, contextFails: 0, loadFails: 0, contextError: undefined as (() => Error) | undefined }))vi.mock('node-llama-cpp', async (original) => {const actual = await original<typeof import('node-llama-cpp')>()const sequence = { contextTokens: [], tokenMeter: { usedInputTokens: 0 }, evaluateWithoutGeneratingNewTokens: async () => {} }return {...actual,- getLlama: async () => ({ gpu: 'vulkan', loadModel: async (o: { gpuLayers?: unknown }) => {+ getLlama: async (opts?: { gpu?: false }) => (fake.llamas.push(opts), { gpu: opts?.gpu === false ? false : 'vulkan', loadModel: async (o: { gpuLayers?: unknown }) => {fake.loads.push(o.gpuLayers)if (fake.loadFails > 0 && o.gpuLayers !== 0) { fake.loadFails--; throw new Error('Failed to load model') }return {- fileInfo: { metadata: { general: { architecture: fake.architecture } } }, gpuLayers: o.gpuLayers === 0 ? 0 : 20,+ fileInfo: { metadata: { general: { architecture: fake.architecture } } }, gpuLayers: o.gpuLayers === 0 || opts?.gpu === false ? 0 : 20,tokenize: () => [], dispose: async () => { fake.disposed++ },createContext: async () => {if (fake.contextFails > 0) { fake.contextFails--; throw fake.contextError?.() ?? new actual.InsufficientMemoryError('A context size of 8192 is too large for the available VRAM') }@@ -30,7 +30,7 @@ vi.mock('node-llama-cpp', async (original) => {}})-beforeEach(() => { fake.sessions.length = 0; fake.loads.length = 0; fake.disposed = 0; fake.contextFails = 0; fake.loadFails = 0; fake.contextError = undefined })+beforeEach(() => { fake.sessions.length = 0; fake.loads.length = 0; fake.llamas.length = 0; fake.disposed = 0; fake.contextFails = 0; fake.loadFails = 0; fake.contextError = undefined })describe('model prompt wrapper', () => {it.each(['gemma4', 'qwen3', 'gpt-oss'])('preload and answers use the same format for %s', async (architecture) => {@@ -74,8 +74,14 @@ describe('too little room on the graphics card for the notes', () => {expect(await llm.load('fixture.gguf', 32768, 8192)).toMatchObject({ gpu: false, gpuLayers: 0 })expect(fake.loads).toEqual([undefined, { fitContext: { contextSize: 8192 } }, 0])})- it('gives up when the processor alone does not fit either', async () => {+ it('with graphics that say they have no room even with no layers on them (an Intel Arc, #57), runs with the graphics off', async () => {fake.contextFails = 3+ const r = await createLlm().load('fixture.gguf', 32768, 8192)+ expect(r).toMatchObject({ gpu: false, gpuLayers: 0 })+ expect(fake.llamas.at(-1)).toEqual({ gpu: false })+ })+ it('gives up when the processor alone does not fit either', async () => {+ fake.contextFails = 4await expect(createLlm().load('fixture.gguf', 32768, 8192)).rejects.toThrow(/too large/)})it('a model too big for the card that fails to load at all loads again with fewer layers there (#37)', async () => {