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
Ask: how a meeting went is answered from its notes and best moments; a follow-up stays on the meetings before it
christianmat694615395cee
diff --git a/app/src/main/library/conversations.ts b/app/src/main/library/conversations.tsindex 3e916dbb..a888d1ee 100644--- a/app/src/main/library/conversations.ts+++ b/app/src/main/library/conversations.ts@@ -74,6 +74,13 @@ export function hookConversations(p: Deps) {return chips.length === 1 && chips[0].kind === 'meeting' && scope?.length === 1 ? scope[0] : undefined}+ /** the meetings an answer was about: those it cites, else all it was given (an answer saying nothing fits cites none) */+ const followOn = (t: ConversationTurn | undefined) => {+ if (!t) return undefined+ const cited = new Set(citedIn(t.answer)), used = t.sources.filter((s) => cited.has(s.n))+ return [...new Set((used.length ? used : t.sources).map((s) => s.meetingId))]+ }+/** the sources that fit the room left, best first; a single one too big is cut */async function fit(llm: Awaited<ReturnType<NotesModel['llm']>>, items: Item[], question: string, history: History, spelling: string): Promise<{ items: Item[]; history: History }> {const total = llm.contextSize - ANSWER_TOKENS - MARGIN_TOKENS@@ -144,7 +151,7 @@ export function hookConversations(p: Deps) {p.library.startTurn(turn.id)turn.status = 'answering'; turn.step = { kind: 'searching' }; later()try {- const got = await retrieve(p, question, { now: now(), scope, context: done.at(-1)?.question })+ const got = await retrieve(p, question, { now: now(), scope, context: done.at(-1)?.question, follow: followOn(done.at(-1)) })if (p.model.needsLoad?.()) { turn.step = { kind: 'loading' }; later() }const llm = await p.model.llm(signal)// the names of every meeting found, spelled rightdiff --git a/app/src/main/library/kind.ts b/app/src/main/library/kind.tsindex b0f3941e..0cf4a6dd 100644--- a/app/src/main/library/kind.ts+++ b/app/src/main/library/kind.ts@@ -4,20 +4,24 @@ import type { Filters } from './filters'* What a question across meetings wants, by simple rules (swappable for something smarter later):* - find: where or what someone said: the best chunks of transcript;* - across: something gathered over many meetings (to-dos, decisions, a recap): each matching meeting's notes,- * which already sum it up.+ * which already sum it up;+ * - overview: how a meeting went, or what to make of it: a judgement of the whole meeting, so its notes and its best+ * moments, not loose pieces (retrieve treats it as find when nothing narrows the meetings).*/-export type Kind = 'find' | 'across'+export type Kind = 'find' | 'across' | 'overview'const GATHER = /\b(?:action items?|to-?dos?|tasks|next steps|follow[- ]?ups?|decisions?|takeaways?)\b/iconst ALL = /\b(?:all|every|each|across|any)\b/iconst MINE = /\b(?:my|our)\s+(?:open\s+)?(?:action items?|to-?dos?|tasks|next steps|follow[- ]?ups?)\b/iconst DECIDED = /\bwhat\s+(?:did|have|has)\s+(?:we|they|i|the team)\s+(?:decide|decided|agree|agreed)\b/iconst RECAP = /\b(?:summari[sz]e|sum up|recap|overview|catch me up|what happened)\b/i+const WENT = /\bhow\s+(?:did|do|does)\b.*\b(?:go|went)\b|\bhow\s+(?:was|were)\b|\bwhat\s+(?:did|do)\s+\p{L}+\s+(?:think|make)\s+of\b|\b(?:vibe|impression|gist)s?\b/iuexport function questionKind(question: string, f: Filters): Kind {const dated = f.from !== undefinedif (MINE.test(question) || DECIDED.test(question)) return 'across'if (GATHER.test(question) && (ALL.test(question) || dated)) return 'across'- if (RECAP.test(question) && (dated || /\bmeetings\b/i.test(question))) return 'across'+ if ((RECAP.test(question) || WENT.test(question)) && (dated || /\bmeetings\b/i.test(question))) return 'across'+ if (RECAP.test(question) || WENT.test(question)) return 'overview'return 'find'}diff --git a/app/src/main/library/retrieve.ts b/app/src/main/library/retrieve.tsindex 2387c418..4b0df537 100644--- a/app/src/main/library/retrieve.ts+++ b/app/src/main/library/retrieve.ts@@ -12,6 +12,9 @@ export const FIND_CHUNKS = 12/** meetings whose notes go to the model for an "across" question (newest first when dated, best first otherwise) */export const ACROSS_MEETINGS = 12const UNDATED_MEETINGS = 8+/** meetings given for an "overview" question (how one went), best first, each with its notes and best chunks */+export const OVERVIEW_MEETINGS = 3+const OVERVIEW_CHUNKS = 4/** each search's list before fusing */const EACH = 50@@ -21,7 +24,7 @@ export type Retrieved = { kind: Kind; filters: Filters; items: Item[] }/** words that say nothing about what to find */const STOP = new Set(('what when where which while who whom whose why how did does doing done the and for about say said says tell told was were are is that this these those with from have has had having our ours my mine you your yours they them their there here been being will would could should can may might any all some also into just like then than out get got its his her hers she him one two from please give show list want need know meeting meetings call calls talk talked talking mention mentioned think thought anything something everything really very much many more most other others same such only own over under again further once ' +- 'did not yes').split(' '))+ 'did not yes went going goes gone felt feel').split(' '))const wordsOf = (q: string) => [...new Set(q.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter((w) => w.length > 2 && !STOP.has(w)))]type Deps = { store: Pick<Store, 'meeting' | 'notes'>; library: Library; indexer: Pick<Indexer, 'ensure' | 'vectors'>; embedder: Pick<Embedder, 'query' | 'ready'> }@@ -30,9 +33,11 @@ type Deps = { store: Pick<Store, 'meeting' | 'notes'>; library: Library; indexer* What to answer from, for a question across meetings: dates and people (and a scope, say a folder) narrow the* meetings; then words (the transcript's search index) and meaning (the embedding model, once it is in) each rank* chunks, fused by reciprocal rank. A "find" question gets the best chunks; an "across" one each matching meeting's- * notes. context: the question before, so a follow-up ("and the price?") is searched for what it follows on from.+ * notes; an "overview" one (how a meeting went) the few best meetings, each with its notes and best chunks.+ * context: the question before, so a follow-up ("and the price?") is searched for what it follows on from.+ * follow: the meetings the answer before used, searched instead of all when the question narrows nothing itself.*/-export async function retrieve(d: Deps, question: string, o: { now: number; scope?: string[]; context?: string }): Promise<Retrieved> {+export async function retrieve(d: Deps, question: string, o: { now: number; scope?: string[]; context?: string; follow?: string[] }): Promise<Retrieved> {let meetings = d.library.finished(!!o.scope)if (o.scope) { const s = new Set(o.scope); meetings = meetings.filter((m) => s.has(m.id)) }const people = new Map(d.library.people().map((p) => [p.meetingId, p.people]))@@ -44,10 +49,20 @@ export async function retrieve(d: Deps, question: string, o: { now: number; scopconst all = meetings.filter((m) => filters.people.every((p) => whoOf(m).has(p)))meetings = all.length ? all : meetings.filter((m) => filters.people.some((p) => whoOf(m).has(p)))}- const narrowed = !!o.scope || filters.from !== undefined || filters.people.length > 0+ // "how did you think it went?" is about the meeting just discussed, unless its words are found only elsewhere (a new subject)+ let followed = false+ if (!o.scope && filters.from === undefined && !filters.people.length && o.follow?.length) {+ const before = new Set(o.follow)+ const kept = meetings.filter((m) => before.has(m.id))+ const hits = d.library.chunks(d.library.wordHits(wordsOf(filters.rest), undefined, EACH)).map((c) => c.meetingId)+ if (kept.length && (!hits.length || hits.some((id) => before.has(id)))) { meetings = kept; followed = true }+ }+ const narrowed = !!o.scope || filters.from !== undefined || filters.people.length > 0 || followedconst ids = meetings.map((m) => m.id)const byId = new Map(meetings.map((m) => [m.id, m]))- const kind = questionKind(question, filters)+ let kind = questionKind(question, filters)+ // how "it" went needs to know which meeting: with nothing narrowing them, search like any question+ if (kind === 'overview' && !narrowed) kind = 'find'if (!meetings.length) return { kind, filters, items: [] }d.indexer.ensure(ids)@@ -67,6 +82,18 @@ export async function retrieve(d: Deps, question: string, o: { now: number; scop// the line its words were found on, else where it startsreturn { meetingId: c.meetingId, title: m.title, startedAt: m.startedAt, atMs: lineAt.get(c.id) ?? c.startMs, text: spelled(c.meetingId, c.text), transcriptRange: { startMs: c.startMs, endMs: c.endMs } }}+ const notesOf = (id: string) => { const n = d.store.notes(id); return (n.enhanced?.trim() || n.mine.trim()).replace(/<\/?mine>/g, '') }+ if (kind === 'overview') {+ // a judgement of the whole meeting: its notes say what it came to, its best chunks how it was said+ const order = [...new Set([...ranked.map((c) => c.meetingId), ...ids])].slice(0, OVERVIEW_MEETINGS)+ const items = order.flatMap((id): Item[] => {+ const m = byId.get(id)!, notes = notesOf(id)+ const best = ranked.filter((c) => c.meetingId === id)+ const chunks = [...best, ...d.library.chunksOf(id).filter((c) => !best.some((b) => b.id === c.id))].slice(0, OVERVIEW_CHUNKS)+ return [...(notes ? [{ meetingId: id, title: m.title, startedAt: m.startedAt, atMs: null, text: spelled(id, notes) }] : []), ...chunks.map(chunkItem)]+ })+ return { kind, filters, items }+ }if (kind === 'find') {const items = ranked.slice(0, FIND_CHUNKS).map(chunkItem)// A prepared note can have typed context before it has any transcript to index.@@ -85,8 +112,7 @@ export async function retrieve(d: Deps, question: string, o: { now: number; scopif (!narrowed && !words.length) order.splice(0, order.length, ...ids.slice(0, UNDATED_MEETINGS))const items = order.map((id): Item => {const m = byId.get(id)!- const n = d.store.notes(id)- const notes = (n.enhanced?.trim() || n.mine.trim()).replace(/<\/?mine>/g, '')+ const notes = notesOf(id)if (notes) return { meetingId: id, title: m.title, startedAt: m.startedAt, atMs: null, text: spelled(id, notes) }// no notes yet: its best chunkconst c = ranked.find((x) => x.meetingId === id) ?? d.library.chunksOf(id)[0]diff --git a/app/test/libraryChat.test.ts b/app/test/libraryChat.test.tsindex 33aca621..a467afe3 100644--- a/app/test/libraryChat.test.ts+++ b/app/test/libraryChat.test.ts@@ -102,6 +102,18 @@ describe('conversations across meetings', () => {expect(t.chats.list()).toHaveLength(1)})+ it('a follow-up that names no meeting stays on the meetings the answer before used', async () => {+ const t = await rig()+ const wedding = t.store.createMeeting({ title: 'Wedding plans', startedAt: now - 3_600_000, endedAt: now, eventId: null, app: null, attendees: [{ name: 'Dee Ray', email: null }], state: 'done' })+ t.store.addSegments([{ meetingId: wedding.id, track: 'them', startMs: 1000, endMs: 2000, text: 'The tasting went really well.', speaker: 'Dee Ray' }])+ await t.deps.indexer.schedule()+ const first = t.chats.ask(null, 'What did Tarun say about the price?')+ await first.done+ await t.chats.ask(first.id, "that's the call! how did you think it went?").done+ expect(t.prompts[1]).toContain('Meeting: Pricing call')+ expect(t.prompts[1]).not.toContain('Wedding plans')+ })+it('rename and delete; the list is newest first', async () => {const t = await rig()const a = t.chats.ask(null, 'First?'); await a.donediff --git a/app/test/libraryFilters.test.ts b/app/test/libraryFilters.test.tsindex 9852430d..8d5604a1 100644--- a/app/test/libraryFilters.test.ts+++ b/app/test/libraryFilters.test.ts@@ -68,4 +68,15 @@ describe('the kind of question', () => {expect(k('what are my next steps?')).toBe('across')expect(k('recap of this week')).toBe('across')})+ it('how a meeting went, or what to make of it, is "overview"', () => {+ expect(k('how did the call with Tarun go?')).toBe('overview')+ expect(k('how was the call?')).toBe('overview')+ expect(k('what happened in the call with Bo?')).toBe('overview')+ expect(k("that's the call! how did you think it went?")).toBe('overview')+ expect(k('what did you think of it?')).toBe('overview')+ // a capital May is a person, not the month+ expect(questionKind('how did the call with May go?', parseFilters('how did the call with May go?', { now, names: ['May Lin'] }))).toBe('overview')+ // many meetings at once still gather their notes+ expect(k('how did my meetings go this week?')).toBe('across')+ })})diff --git a/app/test/libraryRetrieve.test.ts b/app/test/libraryRetrieve.test.tsindex d45f743b..e3aa4ad5 100644--- a/app/test/libraryRetrieve.test.ts+++ b/app/test/libraryRetrieve.test.ts@@ -43,8 +43,8 @@ async function rig(o: { embeds?: boolean } = {}) {const launch = add('Weekly sync', daysAgo(9), ['Bo Park'], [[null, 'Where are we?'], ['Bo Park', 'The site goes live on Tuesday.']], '## Launch\n- Live on Tuesday.\n## Next steps\n- **Bo Park:** Write the release notes.')const hiring = add('Hiring loop', daysAgo(2), ['Ann Lee'], [['Ann Lee', 'The candidate was strong on systems.']])await indexer.schedule()- const r = (q: string, x: { scope?: string[]; context?: string } = {}) => retrieve({ store, library, indexer, embedder }, q, { now, ...x })- return { store, library, indexer, r, pricing, launch, hiring }+ const r = (q: string, x: { scope?: string[]; context?: string; follow?: string[] } = {}) => retrieve({ store, library, indexer, embedder }, q, { now, ...x })+ return { store, library, indexer, r, add, pricing, launch, hiring }}describe('finding what was said across meetings', () => {@@ -83,6 +83,55 @@ describe('finding what was said across meetings', () => {})})+describe('how a meeting went', () => {+ it('a meeting named by who was on it gives its notes and its best moments, not loose pieces', async () => {+ const t = await rig()+ const got = await t.r('how did the call with Tarun go?')+ expect(got.kind).toBe('overview')+ expect(got.items.every((i) => i.meetingId === t.pricing.id)).toBe(true)+ expect(got.items[0]).toMatchObject({ atMs: null, text: expect.stringContaining('Send the quote') })+ expect(got.items.some((i) => i.text.includes('Twenty dollars a seat is what we can do'))).toBe(true)+ })+ it('a meeting without notes yet still gives what was said', async () => {+ const t = await rig()+ const got = await t.r('how was the call with Ann?')+ expect(got.items.map((i) => i.meetingId)).toEqual([t.hiring.id])+ expect(got.items[0].text).toContain('strong on systems')+ })+ it('a few meetings at most, best first', async () => {+ const t = await rig()+ for (let n = 0; n < 5; n++) t.add(`Check-in ${n}`, daysAgo(3 + n), ['Cy Moss'], [['Cy Moss', `Check-in number ${n} went fine.`]], `## Check-in ${n}\n- Fine.`)+ await t.indexer.schedule()+ const got = await t.r('how did the calls with Cy go?')+ expect(new Set(got.items.map((i) => i.meetingId)).size).toBe(3)+ })+ it('with nothing to narrow it, it is a search like any other', async () => {+ const t = await rig()+ expect((await t.r('how did it go?')).kind).toBe('find')+ })+})++describe('a follow-up stays on the meetings before it', () => {+ it('a question with no person, day or scope of its own searches the meetings the last answer used', async () => {+ const t = await rig()+ t.add('Wedding plans', daysAgo(1), ['Dee Ray'], [['Dee Ray', 'The tasting went really well, I think.']], '## Food\n- The tasting went well.')+ await t.indexer.schedule()+ const got = await t.r("that's the call! how did you think it went?", { follow: [t.pricing.id] })+ expect(got.kind).toBe('overview')+ expect(got.items.every((i) => i.meetingId === t.pricing.id)).toBe(true)+ expect(got.items[0].text).toContain('Send the quote')+ })+ it('a question naming its own person, or asked within a scope, searches that instead', async () => {+ const t = await rig()+ expect(new Set((await t.r('what did Ann say?', { follow: [t.pricing.id] })).items.map((i) => i.meetingId))).toEqual(new Set([t.hiring.id]))+ expect((await t.r('twenty dollars', { scope: [t.launch.id], follow: [t.pricing.id] })).items.every((i) => i.meetingId === t.launch.id)).toBe(true)+ })+ it('a new subject found only in other meetings searches them all', async () => {+ const t = await rig()+ expect((await t.r('when does the site go live?', { follow: [t.pricing.id] })).items[0].meetingId).toBe(t.launch.id)+ })+})+describe('gathering across meetings', () => {it('uses each matching meeting\'s notes, newest first, when the question has a date', async () => {const t = await rig()