mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-07-24 21:41:08 +02:00
feat(x): chat titles must be 2-5 words; few-shot the title prompt
Flash-lite under-complied with a bare word-count rule (returned one-word titles). Few-shot examples rein it in; a code guard rejects any remaining single-word output so the placeholder stays instead.
This commit is contained in:
parent
81c07b3a3f
commit
aa235d774c
1 changed files with 9 additions and 2 deletions
|
|
@ -7,10 +7,16 @@ import { withUseCase } from '../analytics/use_case.js';
|
|||
const SYSTEM_PROMPT = `You name chat conversations. Given the user's first message, reply with a concise title for the conversation.
|
||||
|
||||
Rules:
|
||||
- 3 to 5 words
|
||||
- At least 2 words, at most 5 — never a single word
|
||||
- Same language as the message
|
||||
- No quotation marks, no ending punctuation, no emoji
|
||||
- Output the title and nothing else`;
|
||||
- Output the title and nothing else
|
||||
|
||||
Examples:
|
||||
- "who are the investors in supabase" -> Supabase investor list
|
||||
- "help me write a python script that renames all files in a folder" -> Python file renaming script
|
||||
- "why is my docker build so slow" -> Slow Docker build debugging
|
||||
- "draft an email to my landlord about the broken heater" -> Broken heater landlord email`;
|
||||
|
||||
// Long first messages are usually pasted documents or code; the opening is
|
||||
// enough signal for a title and keeps the call cheap.
|
||||
|
|
@ -53,5 +59,6 @@ export async function generateChatTitle(firstMessage: string): Promise<string |
|
|||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
if (!title || title.length > MAX_TITLE_CHARS) return null;
|
||||
if (!title.includes(' ')) return null;
|
||||
return title;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue