Fix: generate title from user message — use only text parts (#1279)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
6a02d4fa9a
commit
d366de3c86
3 changed files with 12 additions and 8 deletions
|
|
@ -112,3 +112,9 @@ export const updateDocumentPrompt = (
|
|||
|
||||
${currentContent}`;
|
||||
};
|
||||
|
||||
export const titlePrompt = `\n
|
||||
- you will generate a short title based on the first message a user begins a conversation with
|
||||
- ensure it is not more than 80 characters long
|
||||
- the title should be a summary of the user's message
|
||||
- do not use quotes or colons`
|
||||
|
|
|
|||
|
|
@ -108,9 +108,9 @@ export function convertToUIMessages(messages: DBMessage[]): ChatMessage[] {
|
|||
}));
|
||||
}
|
||||
|
||||
export function getTextFromMessage(message: ChatMessage): string {
|
||||
export function getTextFromMessage(message: ChatMessage | UIMessage): string {
|
||||
return message.parts
|
||||
.filter((part) => part.type === 'text')
|
||||
.map((part) => part.text)
|
||||
.map((part) => (part as { type: 'text'; text: string}).text)
|
||||
.join('');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue