Restore Ultracite + fix sidebar (#1233)
This commit is contained in:
parent
8fbfc253fa
commit
947ed094a6
177 changed files with 6908 additions and 8306 deletions
|
|
@ -1,42 +1,42 @@
|
|||
import { tool, type UIMessageStreamWriter } from 'ai';
|
||||
import type { Session } from 'next-auth';
|
||||
import { z } from 'zod';
|
||||
import { getDocumentById } from '@/lib/db/queries';
|
||||
import { documentHandlersByArtifactKind } from '@/lib/artifacts/server';
|
||||
import type { ChatMessage } from '@/lib/types';
|
||||
import { tool, type UIMessageStreamWriter } from "ai";
|
||||
import type { Session } from "next-auth";
|
||||
import { z } from "zod";
|
||||
import { documentHandlersByArtifactKind } from "@/lib/artifacts/server";
|
||||
import { getDocumentById } from "@/lib/db/queries";
|
||||
import type { ChatMessage } from "@/lib/types";
|
||||
|
||||
interface UpdateDocumentProps {
|
||||
type UpdateDocumentProps = {
|
||||
session: Session;
|
||||
dataStream: UIMessageStreamWriter<ChatMessage>;
|
||||
}
|
||||
};
|
||||
|
||||
export const updateDocument = ({ session, dataStream }: UpdateDocumentProps) =>
|
||||
tool({
|
||||
description: 'Update a document with the given description.',
|
||||
description: "Update a document with the given description.",
|
||||
inputSchema: z.object({
|
||||
id: z.string().describe('The ID of the document to update'),
|
||||
id: z.string().describe("The ID of the document to update"),
|
||||
description: z
|
||||
.string()
|
||||
.describe('The description of changes that need to be made'),
|
||||
.describe("The description of changes that need to be made"),
|
||||
}),
|
||||
execute: async ({ id, description }) => {
|
||||
const document = await getDocumentById({ id });
|
||||
|
||||
if (!document) {
|
||||
return {
|
||||
error: 'Document not found',
|
||||
error: "Document not found",
|
||||
};
|
||||
}
|
||||
|
||||
dataStream.write({
|
||||
type: 'data-clear',
|
||||
type: "data-clear",
|
||||
data: null,
|
||||
transient: true,
|
||||
});
|
||||
|
||||
const documentHandler = documentHandlersByArtifactKind.find(
|
||||
(documentHandlerByArtifactKind) =>
|
||||
documentHandlerByArtifactKind.kind === document.kind,
|
||||
documentHandlerByArtifactKind.kind === document.kind
|
||||
);
|
||||
|
||||
if (!documentHandler) {
|
||||
|
|
@ -50,13 +50,13 @@ export const updateDocument = ({ session, dataStream }: UpdateDocumentProps) =>
|
|||
session,
|
||||
});
|
||||
|
||||
dataStream.write({ type: 'data-finish', data: null, transient: true });
|
||||
dataStream.write({ type: "data-finish", data: null, transient: true });
|
||||
|
||||
return {
|
||||
id,
|
||||
title: document.title,
|
||||
kind: document.kind,
|
||||
content: 'The document has been updated successfully.',
|
||||
content: "The document has been updated successfully.",
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue