chore: update to ai sdk v5 beta (#1074)
This commit is contained in:
parent
7d8e71383f
commit
4c281fe09d
54 changed files with 1372 additions and 1060 deletions
|
|
@ -10,7 +10,7 @@ import {
|
|||
RedoIcon,
|
||||
UndoIcon,
|
||||
} from '@/components/icons';
|
||||
import { Suggestion } from '@/lib/db/schema';
|
||||
import type { Suggestion } from '@/lib/db/schema';
|
||||
import { toast } from 'sonner';
|
||||
import { getSuggestions } from '../actions';
|
||||
|
||||
|
|
@ -29,22 +29,19 @@ export const textArtifact = new Artifact<'text', TextArtifactMetadata>({
|
|||
});
|
||||
},
|
||||
onStreamPart: ({ streamPart, setMetadata, setArtifact }) => {
|
||||
if (streamPart.type === 'suggestion') {
|
||||
if (streamPart.type === 'data-suggestion') {
|
||||
setMetadata((metadata) => {
|
||||
return {
|
||||
suggestions: [
|
||||
...metadata.suggestions,
|
||||
streamPart.content as Suggestion,
|
||||
],
|
||||
suggestions: [...metadata.suggestions, streamPart.data],
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (streamPart.type === 'text-delta') {
|
||||
if (streamPart.type === 'data-textDelta') {
|
||||
setArtifact((draftArtifact) => {
|
||||
return {
|
||||
...draftArtifact,
|
||||
content: draftArtifact.content + (streamPart.content as string),
|
||||
content: draftArtifact.content + streamPart.data,
|
||||
isVisible:
|
||||
draftArtifact.status === 'streaming' &&
|
||||
draftArtifact.content.length > 400 &&
|
||||
|
|
@ -90,9 +87,7 @@ export const textArtifact = new Artifact<'text', TextArtifactMetadata>({
|
|||
onSaveContent={onSaveContent}
|
||||
/>
|
||||
|
||||
{metadata &&
|
||||
metadata.suggestions &&
|
||||
metadata.suggestions.length > 0 ? (
|
||||
{metadata?.suggestions && metadata.suggestions.length > 0 ? (
|
||||
<div className="md:hidden h-dvh w-12 shrink-0" />
|
||||
) : null}
|
||||
</div>
|
||||
|
|
@ -155,22 +150,30 @@ export const textArtifact = new Artifact<'text', TextArtifactMetadata>({
|
|||
{
|
||||
icon: <PenIcon />,
|
||||
description: 'Add final polish',
|
||||
onClick: ({ appendMessage }) => {
|
||||
appendMessage({
|
||||
onClick: ({ sendMessage }) => {
|
||||
sendMessage({
|
||||
role: 'user',
|
||||
content:
|
||||
'Please add final polish and check for grammar, add section titles for better structure, and ensure everything reads smoothly.',
|
||||
parts: [
|
||||
{
|
||||
type: 'text',
|
||||
text: 'Please add final polish and check for grammar, add section titles for better structure, and ensure everything reads smoothly.',
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: <MessageIcon />,
|
||||
description: 'Request suggestions',
|
||||
onClick: ({ appendMessage }) => {
|
||||
appendMessage({
|
||||
onClick: ({ sendMessage }) => {
|
||||
sendMessage({
|
||||
role: 'user',
|
||||
content:
|
||||
'Please add suggestions you have that could improve the writing.',
|
||||
parts: [
|
||||
{
|
||||
type: 'text',
|
||||
text: 'Please add suggestions you have that could improve the writing.',
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue