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
|
|
@ -1,18 +1,19 @@
|
|||
import { DataStreamWriter, tool } from 'ai';
|
||||
import { Session } from 'next-auth';
|
||||
import { tool, type UIMessageStreamWriter } from 'ai';
|
||||
import type { Session } from 'next-auth';
|
||||
import { z } from 'zod';
|
||||
import { getDocumentById, saveDocument } from '@/lib/db/queries';
|
||||
import { getDocumentById } from '@/lib/db/queries';
|
||||
import { documentHandlersByArtifactKind } from '@/lib/artifacts/server';
|
||||
import type { ChatMessage } from '@/lib/types';
|
||||
|
||||
interface UpdateDocumentProps {
|
||||
session: Session;
|
||||
dataStream: DataStreamWriter;
|
||||
dataStream: UIMessageStreamWriter<ChatMessage>;
|
||||
}
|
||||
|
||||
export const updateDocument = ({ session, dataStream }: UpdateDocumentProps) =>
|
||||
tool({
|
||||
description: 'Update a document with the given description.',
|
||||
parameters: z.object({
|
||||
inputSchema: z.object({
|
||||
id: z.string().describe('The ID of the document to update'),
|
||||
description: z
|
||||
.string()
|
||||
|
|
@ -27,9 +28,10 @@ export const updateDocument = ({ session, dataStream }: UpdateDocumentProps) =>
|
|||
};
|
||||
}
|
||||
|
||||
dataStream.writeData({
|
||||
type: 'clear',
|
||||
content: document.title,
|
||||
dataStream.write({
|
||||
type: 'data-clear',
|
||||
data: null,
|
||||
transient: true,
|
||||
});
|
||||
|
||||
const documentHandler = documentHandlersByArtifactKind.find(
|
||||
|
|
@ -48,7 +50,7 @@ export const updateDocument = ({ session, dataStream }: UpdateDocumentProps) =>
|
|||
session,
|
||||
});
|
||||
|
||||
dataStream.writeData({ type: 'finish', content: '' });
|
||||
dataStream.write({ type: 'data-finish', data: null, transient: true });
|
||||
|
||||
return {
|
||||
id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue