feat: 템플릿(6종) + 강도 조절(3단계) + 커스텀 프롬프트

회의록 외 다양한 용도로 쓸 수 있도록 출력 구조와 요약 깊이를 분리.

템플릿:
- 🗂️ 회의록 (표준, 라이브 O)
- 🎓 강의·세미나 노트 (상세, 라이브 O)
- 🤝 1:1 미팅 (표준, 라이브 O)
- 💡 브레인스토밍 (상세, 라이브 O)
- 🎤 인터뷰 (표준, 라이브 X — Q&A 포맷)
- 📝 원문 정리 (상세 고정, 라이브 X — 요약 없이 문단화만)
- ⚙️ 커스텀 (자유 프롬프트)

강도: 간결 / 표준 / 상세 — 템플릿별 기본값 프리셋, 언제든 override.

변경:
- src/lib/templates.ts 신규 — 프리셋 + 프롬프트 빌더
- minutes-generator / live-summary 가 buildPrompt 공유
- /api/summarize{-live} 가 template/depth/customPrompt 파라미터 수용
- page.tsx UI: 템플릿 픽커, 강도 라디오, 커스텀 textarea
- LiveRecorder 가 설정을 useLiveSummary 로 전달 (ref 기반 최신값)
- 단순 변환 모드는 기존 동작 유지 (템플릿 미적용)
- 프롬프트 빌더 단위 테스트 19개 (총 57 tests)
This commit is contained in:
nad4 committed 2026-04-21 19:38:24 +09:00
1 parent 6e104cbca1
commit 0101e4b0d2
9 files changed
+675 -64

No files matched your search

+21 -27
View File
@@ -1,34 +1,22 @@
import {
buildPrompt,
resolveDepth,
type SummaryDepth,
type TemplateId,
} from './templates'
type LiveSummaryResult =
| { success: true; markdown: string }
| { success: false; error: string; rateLimited?: boolean }
interface LiveSummaryOptions {
apiKey: string
template?: TemplateId
depth?: SummaryDepth
customPrompt?: string
fetchFn?: typeof fetch
}
const LIVE_PROMPT = `회의가 아직 진행 중입니다. 지금까지의 발화 내용을 기반으로 짧고 구조화된 중간 요약을 작성하세요.
형식 (마크다운):
## 요약
(핵심 내용 3줄 이내)
## 주요 논의 사항
1. ...
2. ...
## 액션 아이템
- [ ] ...
규칙:
- 확정되지 않은 결정은 "(논의 중)"으로 표시
- 액션 아이템은 담당자/기한이 명확한 것만 포함
- 한국어로, 간결하게
---
음성 인식 텍스트:
`
export async function generateLiveSummary(
transcript: string,
options: LiveSummaryOptions,
@@ -44,6 +32,16 @@ export async function generateLiveSummary(
return { success: false, error: '요약할 텍스트가 비어 있습니다.' }
}
const templateId = options.template ?? 'meeting'
const depth = resolveDepth(templateId, options.depth)
const prompt = buildPrompt({
templateId,
depth,
transcript: trimmed,
live: true,
customPrompt: options.customPrompt,
})
const url =
'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-lite:generateContent'
@@ -55,11 +53,7 @@ export async function generateLiveSummary(
'x-goog-api-key': apiKey,
},
body: JSON.stringify({
contents: [
{
parts: [{ text: `${LIVE_PROMPT}${trimmed}` }],
},
],
contents: [{ parts: [{ text: prompt }] }],
}),
})
+21 -19
View File
@@ -1,7 +1,17 @@
import {
buildPrompt,
resolveDepth,
type SummaryDepth,
type TemplateId,
} from './templates'
export interface MinutesInput {
title: string
date: Date
transcript: string
template?: TemplateId
depth?: SummaryDepth
customPrompt?: string
}
type GeminiResult =
@@ -39,20 +49,6 @@ ${content}
`
}
const GEMINI_PROMPT = `당신은 회의록 작성 전문가입니다. 아래 음성 인식 텍스트를 분석하여 구조화된 회의록을 마크다운 형식으로 작성해주세요.
포함할 섹션:
- ## 요약 (핵심 내용 3-5줄)
- ## 주요 논의 사항 (번호 매기기)
- ## 액션 아이템 (체크리스트 형식)
- ## 다음 단계
간결하고 명확하게 작성해주세요. 한국어로 작성합니다.
---
음성 인식 텍스트:
`
export async function generateGeminiMinutes(
input: MinutesInput,
options: GeminiOptions,
@@ -63,6 +59,16 @@ export async function generateGeminiMinutes(
return { success: false, error: 'Gemini API 키가 필요합니다.' }
}
const templateId = input.template ?? 'meeting'
const depth = resolveDepth(templateId, input.depth)
const prompt = buildPrompt({
templateId,
depth,
transcript: input.transcript,
live: false,
customPrompt: input.customPrompt,
})
const url =
'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-lite:generateContent'
@@ -74,11 +80,7 @@ export async function generateGeminiMinutes(
'x-goog-api-key': apiKey,
},
body: JSON.stringify({
contents: [
{
parts: [{ text: `${GEMINI_PROMPT}${input.transcript}` }],
},
],
contents: [{ parts: [{ text: prompt }] }],
}),
})
+262
View File
@@ -0,0 +1,262 @@
export type TemplateId =
| 'meeting'
| 'lecture'
| 'one_on_one'
| 'brainstorm'
| 'interview'
| 'raw'
| 'custom'
export type SummaryDepth = 'concise' | 'standard' | 'detailed'
export interface Template {
id: TemplateId
name: string
icon: string
description: string
defaultDepth: SummaryDepth
liveSupported: boolean
depthAdjustable: boolean
basePrompt: string
}
export const DEFAULT_TEMPLATE_ID: TemplateId = 'meeting'
export const DEFAULT_DEPTH: SummaryDepth = 'standard'
export const TEMPLATES: Record<Exclude<TemplateId, 'custom'>, Template> = {
meeting: {
id: 'meeting',
name: '회의록',
icon: '🗂️',
description: '참석자 / 액션 아이템 중심',
defaultDepth: 'standard',
liveSupported: true,
depthAdjustable: true,
basePrompt: `당신은 회의록 작성 전문가입니다. 아래 발화 내용을 분석하여 마크다운 회의록을 작성하세요.
포함할 섹션:
## 요약
(3~5줄 핵심 내용)
## 주요 논의 사항
1. 순번 매기기
## 액션 아이템
- [ ] 담당자와 기한이 명확한 항목만
## 결정 사항
- 합의 또는 확정된 것만
한국어로 작성하세요.`,
},
lecture: {
id: 'lecture',
name: '강의·세미나 노트',
icon: '🎓',
description: '주제별 핵심 개념과 예시',
defaultDepth: 'detailed',
liveSupported: true,
depthAdjustable: true,
basePrompt: `당신은 학습용 노트를 작성하는 전문가입니다. 강의/세미나 녹취를 구조화된 학습 자료로 정리하세요.
포함할 섹션:
## 주요 주제
(한 줄 요약)
## 핵심 개념
각 개념마다 ### 소제목 + 설명 + 구체 예시
## 기억할 인용·예시
> 중요한 문장 인용 형식으로
## 후속 질문
- 스스로 탐구해볼 만한 질문
한국어로 작성하세요.`,
},
one_on_one: {
id: 'one_on_one',
name: '1:1 미팅',
icon: '🤝',
description: '고민 / 피드백 / 다음 액션',
defaultDepth: 'standard',
liveSupported: true,
depthAdjustable: true,
basePrompt: `당신은 1:1 미팅 정리 전문가입니다. 개인적이고 신뢰 기반의 대화임을 존중하며 정리하세요.
포함할 섹션:
## 이번 세션 요지
(2~3줄)
## 논의한 주제
- 주요 대화 흐름
## 고민·블로커
- 공유된 어려움
## 받은·제공한 피드백
- 건설적 피드백 위주
## 다음 미팅까지 할 일
- [ ] 합의된 후속 조치
한국어로 작성하세요.`,
},
brainstorm: {
id: 'brainstorm',
name: '브레인스토밍',
icon: '💡',
description: '아이디어 카테고리화 + 우선순위',
defaultDepth: 'detailed',
liveSupported: true,
depthAdjustable: true,
basePrompt: `당신은 브레인스토밍 세션을 정리하는 전문가입니다. 나온 아이디어를 분류하고 실행 가능성 관점에서 정리하세요.
포함할 섹션:
## 세션 개요
(1~2줄 — 주제/목표)
## 아이디어 (카테고리별)
### [카테고리 이름]
- 아이디어 요약
## 즉시 시도 가능
- 빠르게 검증 가능한 것
## 보류·탈락
- 사유 간단히
## 다음 스텝
- 구체적인 후속 행동
한국어로 작성하세요.`,
},
interview: {
id: 'interview',
name: '인터뷰',
icon: '🎤',
description: 'Q&A 포맷 + 인상적 발언',
defaultDepth: 'standard',
liveSupported: false,
depthAdjustable: true,
basePrompt: `당신은 인터뷰 녹취를 Q&A 형식으로 정리하는 전문가입니다.
포함할 섹션:
## 개요
(인터뷰 대상/주제 1~2줄)
## Q&A
**Q: [질문]**
A: [답변 요약]
(의미있는 Q&A 쌍을 순서대로)
## 인상적 발언
> 직접 인용
## 종합 인상
- 전반적 테마 / 놓치지 말 것
한국어로 작성하세요.`,
},
raw: {
id: 'raw',
name: '원문 정리',
icon: '📝',
description: '요약 없이 문단화·오탈자 정리만',
defaultDepth: 'detailed',
liveSupported: false,
depthAdjustable: false,
basePrompt: `당신은 음성 인식 텍스트의 편집자입니다. 요약이나 재해석 없이 다음만 수행하세요:
- 문장을 자연스러운 문단으로 묶기
- 명백한 오탈자 교정
- 의미 없는 반복 / 군더더기 최소한 제거
- 시간 순서 유지
엄격한 규칙:
- 내용을 삭제하거나 축약하지 마세요
- 구조적 제목(## 섹션)을 덧붙이지 마세요
- 타임스탬프가 있으면 그대로 유지하세요
- 한국어로 작성하세요.`,
},
}
const DEPTH_MODIFIERS: Record<SummaryDepth, string> = {
concise:
'작성 강도: **간결**. 각 섹션은 3줄 이내로 핵심만. 부연 설명과 맥락은 생략하세요.',
standard:
'작성 강도: **표준**. 읽는 사람이 맥락을 이해할 수 있도록 적절한 상세도로 작성하세요.',
detailed:
'작성 강도: **상세**. 원문의 주요 세부사항·수치·고유명사를 누락 없이 포함하세요. 구조만 바꾸고 내용은 최대한 보존합니다.',
}
const LIVE_MODIFIER = `회의가 아직 진행 중입니다. 지금까지의 내용을 기반으로 **중간 정리**를 작성하세요. 확정되지 않은 결정은 "(논의 중)"으로 표시하세요.`
export interface BuildPromptArgs {
templateId: TemplateId
depth: SummaryDepth
transcript: string
live?: boolean
customPrompt?: string
}
export function getTemplate(id: TemplateId): Template | null {
if (id === 'custom') return null
return TEMPLATES[id] ?? null
}
export function resolveDepth(
templateId: TemplateId,
depth?: SummaryDepth,
): SummaryDepth {
if (templateId === 'custom') return depth ?? DEFAULT_DEPTH
const template = TEMPLATES[templateId]
if (!template) return DEFAULT_DEPTH
if (!template.depthAdjustable) return template.defaultDepth
return depth ?? template.defaultDepth
}
export function buildPrompt(args: BuildPromptArgs): string {
const { templateId, depth, transcript, live = false, customPrompt } = args
let instruction: string
if (templateId === 'custom') {
const custom = customPrompt?.trim()
if (!custom) {
instruction = TEMPLATES.meeting.basePrompt
} else {
instruction = custom
}
} else {
const template = TEMPLATES[templateId] ?? TEMPLATES.meeting
const parts: string[] = [template.basePrompt]
if (template.depthAdjustable) {
parts.push(DEPTH_MODIFIERS[depth])
}
if (live && template.liveSupported) {
parts.push(LIVE_MODIFIER)
}
instruction = parts.join('\n\n')
}
return `${instruction}\n\n---\n음성 인식 텍스트:\n${transcript}`
}
export function liveEnabledFor(templateId: TemplateId): boolean {
if (templateId === 'custom') return true
return TEMPLATES[templateId]?.liveSupported ?? true
}
export function depthAdjustableFor(templateId: TemplateId): boolean {
if (templateId === 'custom') return false
return TEMPLATES[templateId]?.depthAdjustable ?? true
}