Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/notes-citations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'lyra': patch
---

Meeting summaries now link to where they come from: each sentence of the summary, decision, action item and open question ends with a time, and clicking it shows that moment in the transcript. The notes are also more trustworthy. Decisions and open questions must quote what was said, like action items already did, so made-up ones are dropped. A decision now says what was settled rather than "they discussed". Vague tasks like "Discuss…" are no longer listed as action items, and each part of a long meeting keeps at most three open questions. Settings offers to rewrite older summaries.
67 changes: 53 additions & 14 deletions apps/lyra/src/main/meeting/notesFormat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ describe('cleanTitle', () => {
describe('tidyNotes', () => {
it('trims entries, drops empty ones and gives an ownerless task to Unassigned', () => {
const tidy = tidyNotes({
summary: ' What we covered. ',
decisions: [' Ship Monday ', '', ' '],
summary: [{ text: ' What we covered. ', at: 0 }],
decisions: [{ text: ' Ship Monday ', at: 4 }, { text: '', at: null }, { text: ' ', at: 5 }],
actionItems: [
{ owner: ' ', task: ' Send the draft ' },
{ owner: 'Bo', task: ' ' }
{ owner: ' ', task: ' Send the draft ', at: 9 },
{ owner: 'Bo', task: ' ', at: null }
],
openQuestions: [' ']
openQuestions: [{ text: ' ', at: null }]
})
expect(tidy).toEqual({
summary: 'What we covered.',
decisions: ['Ship Monday'],
actionItems: [{ owner: 'Unassigned', task: 'Send the draft' }],
summary: [{ text: 'What we covered.', at: 0 }],
decisions: [{ text: 'Ship Monday', at: 4 }],
actionItems: [{ owner: 'Unassigned', task: 'Send the draft', at: 9 }],
openQuestions: []
})
})
Expand All @@ -58,10 +58,10 @@ describe('tidyNotes', () => {
describe('renderNotes', () => {
it('writes every section, with "- None" for an empty one', () => {
const text = renderNotes({
summary: 'We met.',
summary: [{ text: 'We met.', at: null }],
decisions: [],
actionItems: [{ owner: 'Ana', task: 'Send it' }],
openQuestions: ['When?'],
actionItems: [{ owner: 'Ana', task: 'Send it', at: null }],
openQuestions: [{ text: 'When?', at: null }],
sections: []
})
expect(text).toBe(
Expand All @@ -80,6 +80,39 @@ describe('renderNotes', () => {
].join('\n')
)
})

it('cites each line where it comes from, and a sentence only where the moment changes', () => {
const text = renderNotes({
summary: [
{ text: 'Ana opened.', at: 5 },
{ text: 'Ana went on.', at: 5 },
{ text: 'Ben chose blue.', at: 3725 },
{ text: 'All agreed.', at: null }
],
decisions: [{ text: 'Use blue', at: 3725 }],
actionItems: [{ owner: 'Ben', task: 'Buy paint', at: 760 }],
openQuestions: [{ text: 'How much?', at: null }],
sections: [{ start: 0, end: 60, title: 'Colour', summary: 'Picked one.' }]
})
expect(text).toBe(
[
'Summary',
'Ana opened. [0:05] Ana went on. Ben chose blue. [1:02:05] All agreed.',
'',
'Sections',
'- 0:00 Colour: Picked one.',
'',
'Decisions',
'- Use blue [1:02:05]',
'',
'Action items',
'- [ ] Ben: Buy paint [12:40]',
'',
'Open questions',
'- How much?'
].join('\n')
)
})
})

describe('splitNotes', () => {
Expand All @@ -93,20 +126,26 @@ describe('splitNotes', () => {
})

it('round-trips rendered notes', () => {
const notes = { summary: 'S', decisions: ['D'], actionItems: [], openQuestions: [], sections: [] }
const notes = {
summary: [{ text: 'S', at: null }],
decisions: [{ text: 'D', at: 3 }],
actionItems: [],
openQuestions: [],
sections: []
}
const body = `${renderNotes(notes)}\n\n${TRANSCRIPT_DIVIDER}\n\nAna: hi`
expect(splitNotes(body).notes).toBe(renderNotes(notes))
})
})

describe('MeetingNotes', () => {
it('refuses a reply with fields it does not know or without one it needs', () => {
const notes = { summary: 'S', decisions: [], actionItems: [], openQuestions: [] }
const notes = { summary: [], decisions: [], actionItems: [], openQuestions: [] }
expect(MeetingNotes.safeParse(notes).success).toBe(true)
expect(MeetingNotes.safeParse({ ...notes, extra: 1 }).success).toBe(false)
expect(MeetingNotes.safeParse({ summary: 'S' }).success).toBe(false)
expect(
MeetingNotes.safeParse({ ...notes, actionItems: [{ owner: 'A', task: 'B', due: 'C' }] }).success
MeetingNotes.safeParse({ ...notes, actionItems: [{ owner: 'A', task: 'B', at: null, due: 'C' }] }).success
).toBe(false)
})
})
119 changes: 90 additions & 29 deletions apps/lyra/src/main/meeting/notesFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,49 @@ import { z } from 'zod'
/** On the notes worker's command line when the app is packaged (it can't ask `app` itself). */
export const PACKAGED_FLAG = '--packaged'

/**
* Where in the recording a line of the notes comes from: seconds from its start, for a link to
* that moment in the transcript. Null when Lyra couldn't tell (the model's words matched nothing).
*/
export const CiteAt = z.number().nullable()

/** A line of the notes (a decision, an open question, a sentence of the summary) and its source. */
export const Cited = z.strictObject({ text: z.string(), at: CiteAt })
export type Cited = z.infer<typeof Cited>

export const ActionItem = z.strictObject({
/** The speaker name exactly as written, or "Unassigned". */
owner: z.string(),
/** A short imperative ("Send the budget draft to finance"). */
task: z.string()
task: z.string(),
at: CiteAt
})
export type ActionItem = z.infer<typeof ActionItem>

/** A meeting's notes, put together from the calls below (notesPipeline.ts). */
export const MeetingNotes = z.strictObject({
decisions: z.array(z.string()),
decisions: z.array(Cited),
actionItems: z.array(ActionItem),
openQuestions: z.array(z.string()),
summary: z.string()
openQuestions: z.array(Cited),
/** The summary, a sentence at a time, so each can link to where it comes from. */
summary: z.array(Cited)
})
export type MeetingNotes = z.infer<typeof MeetingNotes>

/**
* What a notes call fills: the AI SDK's structured output, and llama.cpp's grammar (from
* `z.toJSONSchema`). Field order matters: constrained decoding fills fields in this order, and
* extracting the lists before writing the summary makes small models less likely to skip them.
* The action items get a call of their own (`ActionItemsFound`). Asked for in the same call, a small model files tasks as decisions or
* leaves the list empty; asked for alone, with the words that commit to each, it finds them.
* Each decision and question starts with the words that settle or raise it, copied from the
* transcript: copying first keeps a small model on what was said, an item it can't quote is one
* it made up (or took from the prompt's examples), and the quote is how Lyra finds the moment to
* link to. The action items get a call of their own (`ActionItemsFound`). Asked for in the same
* call, a small model files tasks as decisions or leaves the list empty; asked for alone, with
* the words that commit to each, it finds them.
*/
export const NotesDraft = z.strictObject({
decisions: z.array(z.string()),
openQuestions: z.array(z.string()),
decisions: z.array(z.strictObject({ quote: z.string(), decision: z.string() })),
openQuestions: z.array(z.strictObject({ quote: z.string(), question: z.string() })),
summary: z.string()
})
export type NotesDraft = z.infer<typeof NotesDraft>
Expand Down Expand Up @@ -66,12 +82,34 @@ export type NoteSection = z.infer<typeof NoteSection>
export const WrittenNotes = z.strictObject({ ...MeetingNotes.shape, sections: z.array(NoteSection) })
export type WrittenNotes = z.infer<typeof WrittenNotes>

/** What every notes prompt asks for in its lists, so a section and a whole meeting agree. */
/**
* What every notes prompt asks for in its lists, so a section and a whole meeting agree. The
* examples are made up and far from any real meeting: a small model copies an example it was
* shown into its answer ("let's ship it Monday" turned up as a decision), even with a real quote
* beside it, so the pipeline drops any decision that repeats one.
*/
export const PROMPT_EXAMPLES = ['Paint the shed green', 'The trip moves to May']

const LIST_RULES = [
'- decisions: plans, dates, or choices the group settled on ("let\'s ship it Monday",',
' "we\'ll go with option B"). A task someone takes on is not a decision. Empty only if',
' nothing was settled.',
'- openQuestions: questions raised but not answered. Empty if none.'
'- decisions: what the group settled: a choice made, a plan agreed, a date set, a rule adopted.',
' For each:',
' - quote: the words from the transcript that settle it, copied exactly.',
` - decision: the outcome as one short statement ("${PROMPT_EXAMPLES.join('", "')}").`,
' Never write "X and Y discussed…" or "X suggested…": say what was settled.',
' An idea someone floats, an opinion, a topic talked about, or a task someone takes on is not',
' a decision. Most stretches of talk settle nothing: then the list is empty.',
'- openQuestions: questions about the work that were left unanswered and still matter after',
' the meeting. For each:',
' - quote: the words that raise it, copied exactly.',
' - question: the question in one short line, clear without the transcript.',
' Not rhetorical questions, jokes, small talk, or questions answered soon after. At most 3.',
' Usually empty.'
]

/** How every summary is written: what happened, not that something was talked about. */
const SUMMARY_RULE = [
' Say what was concluded and why, with names and specifics (choices, numbers, dates, next',
' steps). Not "they discussed X": say what was said about X.'
]

/**
Expand All @@ -93,6 +131,7 @@ export const NOTES_SYSTEM_PROMPT = [
'Return:',
...LIST_RULES,
'- summary: 3-5 plain sentences on what the meeting covered and concluded.',
...SUMMARY_RULE,
'Use only what the transcript says. Be brief.',
...PEOPLE_RULE,
...DATA_RULE
Expand All @@ -105,7 +144,10 @@ export const SECTION_SYSTEM_PROMPT = [
'Return, for this part only:',
...LIST_RULES,
'- summary: 2-4 plain sentences on what this part covered and concluded.',
'- title: 2-6 plain words naming this part\'s topic ("Hiring plan", "Q3 budget").',
...SUMMARY_RULE,
'- title: 2-6 plain words naming this part\'s topic ("Hiring plan", "Q3 budget"). No filler',
' words like "discussion" or "meeting". If the recap\'s last part had the same topic, name',
' what is new in this one.',
'Use only what this part\'s transcript says. Be brief.',
...PEOPLE_RULE,
...DATA_RULE
Expand All @@ -114,8 +156,10 @@ export const SECTION_SYSTEM_PROMPT = [
export const OVERVIEW_SYSTEM_PROMPT = [
'You summarize a whole meeting from notes on its parts, given in order, each with its start',
'time and topic.',
'Return summary: 3-5 plain sentences on what the meeting covered and concluded, in the order',
'it happened. Use only what the notes say.',
'Return summary: 3-6 plain sentences on what the meeting concluded, in the order it happened,',
'one sentence per main topic. Say what was decided or found and what happens next, with names',
'and specifics. Not "the meeting covered" or "they discussed X": say what was said about X.',
'Leave out small talk. Use only what the notes say.',
...PEOPLE_RULE,
...DATA_RULE
].join('\n')
Expand All @@ -127,9 +171,12 @@ export const ACTION_SYSTEM_PROMPT = [
'Return actionItems, one per task, in the order they come up:',
'- quote: the words from the transcript that commit to the task, copied exactly.',
'- owner: the name of the person who will do it, exactly as written before a line, or',
' "Unassigned". In "Priya: Marcus, can you book the room?" the owner is Marcus.',
'- task: a short imperative ("Book the room", "Send the budget draft to finance").',
'A question or a decision is not an action item unless someone takes on the work.',
' "Unassigned". In "Priya: Marcus, can you book the room?" the owner is Marcus. "I" is the',
' person speaking the line.',
'- task: a short imperative that says what gets done, clear without the transcript ("Book the',
' room for Thursday", not "Do it" or "Get the info").',
'A question, a decision, a wish ("we should someday…") or a vague intention ("understand the',
'changes", "think about it") is not an action item unless someone takes on concrete work.',
'Return an empty list only if nobody took on anything. Use only what the transcript says.',
...DATA_RULE,
'',
Expand All @@ -139,6 +186,7 @@ export const ACTION_SYSTEM_PROMPT = [
'Ben: I will update the slides by Monday.',
'Ana: Ben, can you also invite the client?',
'Ben: Sure.',
'Ana: We should rethink the logo someday.',
'Answer: {"actionItems": [{"quote": "I will update the slides by Monday.", "owner": "Ben",',
'"task": "Update the slides by Monday"}, {"quote": "Ben, can you also invite the client?",',
'"owner": "Ben", "task": "Invite the client"}]}'
Expand Down Expand Up @@ -180,23 +228,20 @@ export function cleanTitle(title: string): string | null {
/** Separates generated notes (above) from the labeled transcript (below) in the export. */
export const TRANSCRIPT_DIVIDER = '──── Transcript ────'

/** Notes as a model returned them, trimmed, with empty entries dropped. */
/** Notes with every entry trimmed and the empty ones dropped. */
export function tidyNotes(notes: MeetingNotes): MeetingNotes {
const lines = (items: string[]): string[] => items.map((item) => item.trim()).filter(Boolean)
const lines = (items: Cited[]): Cited[] =>
items.map((item) => ({ ...item, text: item.text.trim() })).filter((item) => item.text)
return {
summary: notes.summary.trim(),
summary: lines(notes.summary),
decisions: lines(notes.decisions),
actionItems: notes.actionItems
.map((item) => ({ owner: item.owner.trim() || 'Unassigned', task: item.task.trim() }))
.map((item) => ({ ...item, owner: item.owner.trim() || 'Unassigned', task: item.task.trim() }))
.filter((item) => item.task),
openQuestions: lines(notes.openQuestions)
}
}

function list(items: string[]): string {
return items.length ? items.map((item) => `- ${item}`).join('\n') : '- None'
}

/** `0:05`, `12:40`, `1:02:03`: a time from the recording's start. */
export function clockTime(seconds: number): string {
const total = Math.max(0, Math.floor(seconds))
Expand All @@ -206,22 +251,38 @@ export function clockTime(seconds: number): string {
return hours ? `${String(hours)}:${String(minutes).padStart(2, '0')}:${secs}` : `${String(minutes)}:${secs}`
}

/** ` [12:40]` after a line of the notes: where it comes from (src/shared/notesCites.ts reads it back). */
function cite(at: number | null): string {
return at === null ? '' : ` [${clockTime(at)}]`
}

function list(items: Cited[]): string {
return items.length ? items.map((item) => `- ${item.text}${cite(item.at)}`).join('\n') : '- None'
}

/** The summary's sentences, each cited unless it comes from the same moment as the one before. */
function paragraph(sentences: Cited[]): string {
return sentences
.map((sentence, index) => `${sentence.text}${sentence.at === sentences[index - 1]?.at ? '' : cite(sentence.at)}`)
.join(' ')
}

/** Plain text that reads well in both .txt and .md files. Sections appear only when there are any. */
export function renderNotes(notes: WrittenNotes): string {
const sections = notes.sections.length
? ['Sections', ...notes.sections.map((section) => `- ${clockTime(section.start)} ${section.title}: ${section.summary}`), '']
: []
return [
'Summary',
notes.summary,
paragraph(notes.summary),
'',
...sections,
'Decisions',
list(notes.decisions),
'',
'Action items',
notes.actionItems.length
? notes.actionItems.map((item) => `- [ ] ${item.owner}: ${item.task}`).join('\n')
? notes.actionItems.map((item) => `- [ ] ${item.owner}: ${item.task}${cite(item.at)}`).join('\n')
: '- None',
'',
'Open questions',
Expand Down
12 changes: 10 additions & 2 deletions apps/lyra/src/main/meeting/notesLimits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ describe('limitNotesSchema', () => {
expect(limitNotesSchema(jsonSchema(SectionNotes))).toMatchObject({
type: 'object',
properties: {
decisions: { type: 'array', maxItems: 8, items: { type: 'string', maxLength: 200 } },
openQuestions: { type: 'array', maxItems: 8, items: { type: 'string', maxLength: 200 } },
decisions: {
type: 'array',
maxItems: 8,
items: { properties: { quote: { maxLength: 200 }, decision: { maxLength: 160 } } }
},
openQuestions: {
type: 'array',
maxItems: 4,
items: { properties: { quote: { maxLength: 200 }, question: { maxLength: 160 } } }
},
summary: { type: 'string', maxLength: 1200 },
title: { type: 'string', maxLength: 80 }
}
Expand Down
6 changes: 4 additions & 2 deletions apps/lyra/src/main/meeting/notesLimits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ const FIELD_CHARS: Readonly<Record<string, number>> = {
title: 80,
quote: 200,
owner: 40,
task: 120
task: 120,
decision: 160,
question: 160
}
/** A string in a list (a decision, an open question). */
const ITEM_CHARS = 200
const ITEMS: Readonly<Record<string, number>> = { actionItems: 12 }
const ITEMS: Readonly<Record<string, number>> = { actionItems: 12, openQuestions: 4 }
/** Decisions and open questions: more than this from one call is a model repeating itself. */
const LIST_ITEMS = 8

Expand Down
Loading
Loading