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
|
|
@ -12,8 +12,8 @@ import { toast } from 'sonner';
|
|||
import { generateUUID } from '@/lib/utils';
|
||||
import {
|
||||
Console,
|
||||
ConsoleOutput,
|
||||
ConsoleOutputContent,
|
||||
type ConsoleOutput,
|
||||
type ConsoleOutputContent,
|
||||
} from '@/components/console';
|
||||
|
||||
const OUTPUT_HANDLERS = {
|
||||
|
|
@ -76,10 +76,10 @@ export const codeArtifact = new Artifact<'code', Metadata>({
|
|||
});
|
||||
},
|
||||
onStreamPart: ({ streamPart, setArtifact }) => {
|
||||
if (streamPart.type === 'code-delta') {
|
||||
if (streamPart.type === 'data-codeDelta') {
|
||||
setArtifact((draftArtifact) => ({
|
||||
...draftArtifact,
|
||||
content: streamPart.content as string,
|
||||
content: streamPart.data,
|
||||
isVisible:
|
||||
draftArtifact.status === 'streaming' &&
|
||||
draftArtifact.content.length > 300 &&
|
||||
|
|
@ -249,20 +249,30 @@ export const codeArtifact = new Artifact<'code', Metadata>({
|
|||
{
|
||||
icon: <MessageIcon />,
|
||||
description: 'Add comments',
|
||||
onClick: ({ appendMessage }) => {
|
||||
appendMessage({
|
||||
onClick: ({ sendMessage }) => {
|
||||
sendMessage({
|
||||
role: 'user',
|
||||
content: 'Add comments to the code snippet for understanding',
|
||||
parts: [
|
||||
{
|
||||
type: 'text',
|
||||
text: 'Add comments to the code snippet for understanding',
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: <LogsIcon />,
|
||||
description: 'Add logs',
|
||||
onClick: ({ appendMessage }) => {
|
||||
appendMessage({
|
||||
onClick: ({ sendMessage }) => {
|
||||
sendMessage({
|
||||
role: 'user',
|
||||
content: 'Add logs to the code snippet for debugging',
|
||||
parts: [
|
||||
{
|
||||
type: 'text',
|
||||
text: 'Add logs to the code snippet for debugging',
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -26,9 +26,10 @@ export const codeDocumentHandler = createDocumentHandler<'code'>({
|
|||
const { code } = object;
|
||||
|
||||
if (code) {
|
||||
dataStream.writeData({
|
||||
type: 'code-delta',
|
||||
content: code ?? '',
|
||||
dataStream.write({
|
||||
type: 'data-codeDelta',
|
||||
data: code ?? '',
|
||||
transient: true,
|
||||
});
|
||||
|
||||
draftContent = code;
|
||||
|
|
@ -58,9 +59,10 @@ export const codeDocumentHandler = createDocumentHandler<'code'>({
|
|||
const { code } = object;
|
||||
|
||||
if (code) {
|
||||
dataStream.writeData({
|
||||
type: 'code-delta',
|
||||
content: code ?? '',
|
||||
dataStream.write({
|
||||
type: 'data-codeDelta',
|
||||
data: code ?? '',
|
||||
transient: true,
|
||||
});
|
||||
|
||||
draftContent = code;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue