diff --git a/artifacts/code/server.ts b/artifacts/code/server.ts index 0b74019e7d..45a80845ae 100644 --- a/artifacts/code/server.ts +++ b/artifacts/code/server.ts @@ -6,13 +6,13 @@ import { createDocumentHandler } from '@/lib/artifacts/server'; export const codeDocumentHandler = createDocumentHandler<'code'>({ kind: 'code', - onCreateDocument: async ({ title, dataStream }) => { + onCreateDocument: async ({ title, description, dataStream }) => { let draftContent = ''; const { fullStream } = streamObject({ model: myProvider.languageModel('artifact-model'), system: codePrompt, - prompt: title, + prompt: `${title}\n\n${description}`, schema: z.object({ code: z.string(), }), diff --git a/artifacts/image/server.ts b/artifacts/image/server.ts index 96c2bc5fce..458615f1de 100644 --- a/artifacts/image/server.ts +++ b/artifacts/image/server.ts @@ -4,12 +4,12 @@ import { experimental_generateImage } from 'ai'; export const imageDocumentHandler = createDocumentHandler<'image'>({ kind: 'image', - onCreateDocument: async ({ title, dataStream }) => { + onCreateDocument: async ({ title, description, dataStream }) => { let draftContent = ''; const { image } = await experimental_generateImage({ model: myProvider.imageModel('small-model'), - prompt: title, + prompt: `${title}\n\n${description}`, n: 1, }); diff --git a/artifacts/sheet/server.ts b/artifacts/sheet/server.ts index 7a557bdeff..46a108a3ff 100644 --- a/artifacts/sheet/server.ts +++ b/artifacts/sheet/server.ts @@ -6,13 +6,13 @@ import { z } from 'zod'; export const sheetDocumentHandler = createDocumentHandler<'sheet'>({ kind: 'sheet', - onCreateDocument: async ({ title, dataStream }) => { + onCreateDocument: async ({ title, description, dataStream }) => { let draftContent = ''; const { fullStream } = streamObject({ model: myProvider.languageModel('artifact-model'), system: sheetPrompt, - prompt: title, + prompt: `${title}\n\n${description}`, schema: z.object({ csv: z.string().describe('CSV data'), }), diff --git a/artifacts/text/server.ts b/artifacts/text/server.ts index 58578bf17d..aadafee79c 100644 --- a/artifacts/text/server.ts +++ b/artifacts/text/server.ts @@ -5,7 +5,7 @@ import { updateDocumentPrompt } from '@/lib/ai/prompts'; export const textDocumentHandler = createDocumentHandler<'text'>({ kind: 'text', - onCreateDocument: async ({ title, dataStream }) => { + onCreateDocument: async ({ title, description, dataStream }) => { let draftContent = ''; const { fullStream } = streamText({ @@ -13,7 +13,7 @@ export const textDocumentHandler = createDocumentHandler<'text'>({ system: 'Write about the given topic. Markdown is supported. Use headings wherever appropriate.', experimental_transform: smoothStream({ chunking: 'word' }), - prompt: title, + prompt: `${title}\n\n${description}`, }); for await (const delta of fullStream) { diff --git a/lib/ai/tools/create-document.ts b/lib/ai/tools/create-document.ts index 40c9ddd9a6..3046d0bb56 100644 --- a/lib/ai/tools/create-document.ts +++ b/lib/ai/tools/create-document.ts @@ -18,9 +18,10 @@ export const createDocument = ({ session, dataStream }: CreateDocumentProps) => 'Create a document for a writing or content creation activities. This tool will call other functions that will generate the contents of the document based on the title and kind.', parameters: z.object({ title: z.string(), + description: z.string().describe('A detailed description of what the document should contain'), kind: z.enum(artifactKinds), }), - execute: async ({ title, kind }) => { + execute: async ({ title, description, kind }) => { const id = generateUUID(); dataStream.writeData({ @@ -55,6 +56,7 @@ export const createDocument = ({ session, dataStream }: CreateDocumentProps) => await documentHandler.onCreateDocument({ id, title, + description, dataStream, session, }); diff --git a/lib/artifacts/server.ts b/lib/artifacts/server.ts index a2896e4287..a2cc755ad4 100644 --- a/lib/artifacts/server.ts +++ b/lib/artifacts/server.ts @@ -19,6 +19,7 @@ export interface SaveDocumentProps { export interface CreateDocumentCallbackProps { id: string; title: string; + description: string; dataStream: DataStreamWriter; session: Session; } @@ -47,6 +48,7 @@ export function createDocumentHandler(config: { const draftContent = await config.onCreateDocument({ id: args.id, title: args.title, + description: args.description, dataStream: args.dataStream, session: args.session, });