Skip to content

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.

Ask: an answer starts with the answer, never "Based on the provided transcript"

christianmat9ac72259b2bc
diff --git a/app/src/main/chat.ts b/app/src/main/chat.ts
index 50a331bd..ef38eb13 100644
--- a/app/src/main/chat.ts
+++ b/app/src/main/chat.ts
@@ -1,3 +1,4 @@
+import { withoutPreamble } from '../shared/answerPreamble'
import type { Meeting, Notes, Segment, Store } from './store'
import type { NotesModel } from './notes/model'
import type { Queue } from './notes/queue'
@@ -307,9 +308,9 @@ export function hookChat(p: Deps & {
onStart: () => { turn.status = 'answering'; later() },
onRestart: () => { written = ''; completed = undefined; turn.answer = ''; turn.status = 'waiting'; later() },
onComplete: (answer) => { completed = answer },
- })) { written += t; turn.answer = written; later() }
+ })) { written += t; turn.answer = withoutPreamble(written, { streaming: true }); later() }
// Final cleanup may remove text already streamed; stopped answers keep only what arrived before Stop.
- turn.answer = (completed ?? written).trim()
+ turn.answer = withoutPreamble((completed ?? written).trim())
turn.status = ac.signal.aborted ? 'stopped' : 'done'
p.store.setChatAnswer(turn.id, turn.answer, turn.status === 'stopped')
} catch (e) {
diff --git a/app/src/main/library/conversations.ts b/app/src/main/library/conversations.ts
index 03f2b84d..3e916dbb 100644
--- a/app/src/main/library/conversations.ts
+++ b/app/src/main/library/conversations.ts
@@ -8,6 +8,7 @@ import type { Library } from './store'
import type { Indexer } from './indexer'
import type { Embedder } from './embedder'
import { retrieve, type Item } from './retrieve'
+import { withoutPreamble } from '../../shared/answerPreamble'
import { byMeeting, libraryPrompt, type History } from './prompt'
import { citedIn, tidyCitations } from '../../shared/citations'
import { attachContext } from '../../shared/askContext'
@@ -136,7 +137,7 @@ export function hookConversations(p: Deps) {
onStep: (step) => { turn.step = step; later() },
onRestart: () => { written = ''; completed = undefined; turn.answer = ''; turn.status = 'waiting'; turn.step = undefined; later() },
onComplete: answer => { completed = answer },
- })) { written += text; turn.answer = written; later() }
+ })) { written += text; turn.answer = withoutPreamble(written, { streaming: true }); later() }
})() : p.queue.enqueue(async (stop) => {
if (ac.signal.aborted) return
const signal = AbortSignal.any([stop, ac.signal])
@@ -170,7 +171,7 @@ export function hookConversations(p: Deps) {
if (signal.aborted) return
const answer = await llm.chat(libraryPrompt({ items, question, history: recent, now: now(), spelling }), (t) => {
if (signal.aborted) return
- written += t; turn.answer = written; later()
+ written += t; turn.answer = withoutPreamble(written, { streaming: true }); later()
}, { maxTokens: ANSWER_TOKENS })
if (!signal.aborted) completed = answer
} finally {
@@ -184,7 +185,8 @@ export function hookConversations(p: Deps) {
const finished = (async () => {
try {
await Promise.race([job, stopped])
- turn.answer = single ? (completed ?? written).trim() : tidyCitations((completed ?? written).trim(), turn.sources)
+ const answer = withoutPreamble((completed ?? written).trim())
+ turn.answer = single ? answer : tidyCitations(answer, turn.sources)
turn.status = ac.signal.aborted ? 'stopped' : 'done'
turn.step = undefined
const cited = new Set(citedIn(turn.answer))
diff --git a/app/src/shared/answerPreamble.ts b/app/src/shared/answerPreamble.ts
new file mode 100644
index 00000000..39abe72e
--- /dev/null
+++ b/app/src/shared/answerPreamble.ts
@@ -0,0 +1,24 @@
+/**
+ * Small models open an answer with where it came from ("Based on the provided transcript:") even when told not to.
+ * The person sees their own meetings, not a "provided transcript", so that opening goes. Only an opening that names
+ * the sources themselves goes: "Based on what Dana said, ..." is part of the answer and stays.
+ */
+const LEAD = /^\s*(?:based on|according to|going by)\s+(?:the\s+)?(?:provided\s+|given\s+|available\s+|above\s+)?(?:meeting\s+)?(?:transcripts?|sources?|notes|meetings?|context|excerpts?|information|records?)(?:\s+(?:provided|given|above|available))?(?:,?\s+here(?:'s| is| are)\b[^:\n]{0,80})?\s*([:,])[ \t]*/i
+const OPENERS = ['based on ', 'according to ', 'going by ']
+/** past this many characters without a colon or comma, the start is no such opening */
+const DECIDED_AT = 120
+
+/** The answer without that opening. While it streams, the first words wait until it is clear they aren't one. */
+export function withoutPreamble(text: string, o: { streaming?: boolean } = {}): string {
+ const m = LEAD.exec(text)
+ if (m) {
+ const rest = text.slice(m[0].length).replace(/^\s+/, '')
+ return m[1] === ',' && rest ? rest[0].toLocaleUpperCase() + rest.slice(1) : rest
+ }
+ if (o.streaming) {
+ const start = text.trimStart().toLocaleLowerCase()
+ const mayBe = OPENERS.some((w) => w.startsWith(start) || start.startsWith(w))
+ if (mayBe && start.length < DECIDED_AT && !/[:,.\n]/.test(start)) return ''
+ }
+ return text
+}
diff --git a/app/test/answerPreamble.test.ts b/app/test/answerPreamble.test.ts
new file mode 100644
index 00000000..0a1bc548
--- /dev/null
+++ b/app/test/answerPreamble.test.ts
@@ -0,0 +1,27 @@
+import { describe, expect, it } from 'vitest'
+import { withoutPreamble } from '../src/shared/answerPreamble'
+
+describe('withoutPreamble: an answer starts with the answer, never with where it came from', () => {
+ it('drops a line that only says what the answer is based on', () => {
+ expect(withoutPreamble('Based on the provided transcript:\n- **Last week:** no open PRs [1]')).toBe('- **Last week:** no open PRs [1]')
+ expect(withoutPreamble('Based on the provided transcripts:\n\nMicah is on the product map [2].')).toBe('Micah is on the product map [2].')
+ expect(withoutPreamble('According to the meeting notes:\n- a')).toBe('- a')
+ expect(withoutPreamble('Based on the sources provided, here is what Micah is working on:\n- a')).toBe('- a')
+ })
+ it('drops the clause before the answer in the same sentence, and starts it with a capital', () => {
+ expect(withoutPreamble('Based on the transcript, Micah had no open PRs [1].')).toBe('Micah had no open PRs [1].')
+ expect(withoutPreamble('According to the provided sources, the launch moved to May [3].')).toBe('The launch moved to May [3].')
+ })
+ it('keeps answers that only start like one', () => {
+ expect(withoutPreamble('Based on what Dana said, the launch moved [1].')).toBe('Based on what Dana said, the launch moved [1].')
+ expect(withoutPreamble('Micah had no open PRs [1].')).toBe('Micah had no open PRs [1].')
+ expect(withoutPreamble('According to Dana, the launch moved [1].')).toBe('According to Dana, the launch moved [1].')
+ })
+ it('while streaming, holds back the first words until it is clear they are no such line', () => {
+ expect(withoutPreamble('Based on the pro', { streaming: true })).toBe('')
+ expect(withoutPreamble('Based on the provided transcript:', { streaming: true })).toBe('')
+ expect(withoutPreamble('Based on the provided transcript:\n- **Last', { streaming: true })).toBe('- **Last')
+ expect(withoutPreamble('Micah', { streaming: true })).toBe('Micah')
+ expect(withoutPreamble('Based on what Dana said,', { streaming: true })).toBe('Based on what Dana said,')
+ })
+})