refactor: replace message.content with message.parts (#868)
This commit is contained in:
parent
553a3d825a
commit
47a630fd53
25 changed files with 1311 additions and 311 deletions
|
|
@ -32,8 +32,6 @@ export function PureMessageActions({
|
|||
|
||||
if (isLoading) return null;
|
||||
if (message.role === 'user') return null;
|
||||
if (message.toolInvocations && message.toolInvocations.length > 0)
|
||||
return null;
|
||||
|
||||
return (
|
||||
<TooltipProvider delayDuration={0}>
|
||||
|
|
@ -44,7 +42,18 @@ export function PureMessageActions({
|
|||
className="py-1 px-2 h-fit text-muted-foreground"
|
||||
variant="outline"
|
||||
onClick={async () => {
|
||||
await copyToClipboard(message.content as string);
|
||||
const textFromParts = message.parts
|
||||
?.filter((part) => part.type === 'text')
|
||||
.map((part) => part.text)
|
||||
.join('\n')
|
||||
.trim();
|
||||
|
||||
if (!textFromParts) {
|
||||
toast.error("There's no text to copy!");
|
||||
return;
|
||||
}
|
||||
|
||||
await copyToClipboard(textFromParts);
|
||||
toast.success('Copied to clipboard!');
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue