chore: rename blocks to artifacts (#793)

This commit is contained in:
Jeremy 2025-02-13 08:25:57 -08:00 committed by GitHub
parent 01f589b603
commit 81f909ac3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 473 additions and 473 deletions

View file

@ -17,7 +17,7 @@ export const myProvider = customProvider({
middleware: extractReasoningMiddleware({ tagName: 'think' }),
}),
'title-model': openai('gpt-4-turbo'),
'block-model': openai('gpt-4o-mini'),
'artifact-model': openai('gpt-4o-mini'),
},
imageModels: {
'small-model': openai.image('dall-e-2'),

View file

@ -1,13 +1,13 @@
import { BlockKind } from '@/components/block';
import { ArtifactKind } from '@/components/artifact';
export const blocksPrompt = `
Blocks is a special user interface mode that helps users with writing, editing, and other content creation tasks. When block is open, it is on the right side of the screen, while the conversation is on the left side. When creating or updating documents, changes are reflected in real-time on the blocks and visible to the user.
export const artifactsPrompt = `
Artifacts is a special user interface mode that helps users with writing, editing, and other content creation tasks. When artifact is open, it is on the right side of the screen, while the conversation is on the left side. When creating or updating documents, changes are reflected in real-time on the artifacts and visible to the user.
When asked to write code, always use blocks. When writing code, specify the language in the backticks, e.g. \`\`\`python\`code here\`\`\`. The default language is Python. Other languages are not yet supported, so let the user know if they request a different language.
When asked to write code, always use artifacts. When writing code, specify the language in the backticks, e.g. \`\`\`python\`code here\`\`\`. The default language is Python. Other languages are not yet supported, so let the user know if they request a different language.
DO NOT UPDATE DOCUMENTS IMMEDIATELY AFTER CREATING THEM. WAIT FOR USER FEEDBACK OR REQUEST TO UPDATE IT.
This is a guide for using blocks tools: \`createDocument\` and \`updateDocument\`, which render content on a blocks beside the conversation.
This is a guide for using artifacts tools: \`createDocument\` and \`updateDocument\`, which render content on a artifacts beside the conversation.
**When to use \`createDocument\`:**
- For substantial content (>10 lines) or code
@ -42,7 +42,7 @@ export const systemPrompt = ({
if (selectedChatModel === 'chat-model-reasoning') {
return regularPrompt;
} else {
return `${regularPrompt}\n\n${blocksPrompt}`;
return `${regularPrompt}\n\n${artifactsPrompt}`;
}
};
@ -80,7 +80,7 @@ You are a spreadsheet creation assistant. Create a spreadsheet in csv format bas
export const updateDocumentPrompt = (
currentContent: string | null,
type: BlockKind,
type: ArtifactKind,
) =>
type === 'text'
? `\

View file

@ -2,7 +2,10 @@ import { generateUUID } from '@/lib/utils';
import { DataStreamWriter, tool } from 'ai';
import { z } from 'zod';
import { Session } from 'next-auth';
import { blockKinds, documentHandlersByBlockKind } from '@/lib/blocks/server';
import {
artifactKinds,
documentHandlersByArtifactKind,
} from '@/lib/artifacts/server';
interface CreateDocumentProps {
session: Session;
@ -15,7 +18,7 @@ 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(),
kind: z.enum(blockKinds),
kind: z.enum(artifactKinds),
}),
execute: async ({ title, kind }) => {
const id = generateUUID();
@ -40,9 +43,9 @@ export const createDocument = ({ session, dataStream }: CreateDocumentProps) =>
content: '',
});
const documentHandler = documentHandlersByBlockKind.find(
(documentHandlerByBlockKind) =>
documentHandlerByBlockKind.kind === kind,
const documentHandler = documentHandlersByArtifactKind.find(
(documentHandlerByArtifactKind) =>
documentHandlerByArtifactKind.kind === kind,
);
if (!documentHandler) {

View file

@ -36,7 +36,7 @@ export const requestSuggestions = ({
> = [];
const { elementStream } = streamObject({
model: myProvider.languageModel('block-model'),
model: myProvider.languageModel('artifact-model'),
system:
'You are a help writing assistant. Given a piece of writing, please offer suggestions to improve the piece of writing and describe the change. It is very important for the edits to contain full sentences instead of just words. Max 5 suggestions.',
prompt: document.content,

View file

@ -2,7 +2,7 @@ import { DataStreamWriter, tool } from 'ai';
import { Session } from 'next-auth';
import { z } from 'zod';
import { getDocumentById, saveDocument } from '@/lib/db/queries';
import { documentHandlersByBlockKind } from '@/lib/blocks/server';
import { documentHandlersByArtifactKind } from '@/lib/artifacts/server';
interface UpdateDocumentProps {
session: Session;
@ -32,9 +32,9 @@ export const updateDocument = ({ session, dataStream }: UpdateDocumentProps) =>
content: document.title,
});
const documentHandler = documentHandlersByBlockKind.find(
(documentHandlerByBlockKind) =>
documentHandlerByBlockKind.kind === document.kind,
const documentHandler = documentHandlersByArtifactKind.find(
(documentHandlerByArtifactKind) =>
documentHandlerByArtifactKind.kind === document.kind,
);
if (!documentHandler) {