Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
refactor: AI improvements (#2461)
Giuseppeb2ffc4b0b679
diff --git a/apps/builder/app/builder/features/ai/ai-fetch-result.ts b/apps/builder/app/builder/features/ai/ai-fetch-result.tsindex fd1a9769dc..dcf48f2943 100644--- a/apps/builder/app/builder/features/ai/ai-fetch-result.ts+++ b/apps/builder/app/builder/features/ai/ai-fetch-result.ts@@ -93,6 +93,11 @@ export const fetchResult = async (body: JSON.stringify({...requestParams,command,+ jsx:+ // Delete instances don't need CSS.+ command === operations.deleteInstanceName+ ? jsx+ : requestParams.jsx,}),signal: abortSignal,}),diff --git a/apps/builder/app/routes/rest.ai.detect.ts b/apps/builder/app/routes/rest.ai.detect.tsindex bd91a35ddd..ae101ba40e 100644--- a/apps/builder/app/routes/rest.ai.detect.ts+++ b/apps/builder/app/routes/rest.ai.detect.ts@@ -91,7 +91,7 @@ export const action = async ({ request }: ActionArgs) => {prompt,commands: {[copywriter.name]:- "writes, rewrites, rephrases, shortens, increases length or translates text",+ "rewrites, rephrases, shortens, increases length or translates text",[operations.editStyles.name]: "edits styles",[operations.generateTemplatePrompt.name]:"handles a user interface generation request",diff --git a/apps/builder/app/routes/rest.ai.ts b/apps/builder/app/routes/rest.ai.tsindex 82e0e4001d..e922fdf9d0 100644--- a/apps/builder/app/routes/rest.ai.ts+++ b/apps/builder/app/routes/rest.ai.ts@@ -221,7 +221,12 @@ export const action = async ({ request }: ActionArgs) => {const result = await generationChain({model: generationModel,context: {- prompt: operation.llmPrompt,+ prompt:+ operation.llmPrompt ++ (operation.classNames.length > 0+ ? `.\nSuggested Tailwind classes: ${operation.classNames}`+ : ""),+components,},});diff --git a/packages/ai/src/chains/copywriter/__generated__/copy.system.prompt.ts b/packages/ai/src/chains/copywriter/__generated__/copy.system.prompt.tsindex 6b93393274..2162224e6f 100644--- a/packages/ai/src/chains/copywriter/__generated__/copy.system.prompt.ts+++ b/packages/ai/src/chains/copywriter/__generated__/copy.system.prompt.ts@@ -2,7 +2,7 @@ export const prompt = `You are a copywriter AI and your task is to produce an arThe user will provide a description and a list of copy snippets that you should generate text for.-The copy must pop, be unique and in line with the user request, so do not generate generic lorem ipsum text nor use generic names. Unless specified usually the new text should have similar length of the existing one.+The copy must pop, be unique and in line with the user request, so do not generate generic lorem ipsum text nor use generic names. Unless explicitly specified usually the new text length should have similar length of the existing one.You will respond with the exact original input array of copy to complete replacing only the \`text\` property with the generated copy.diff --git a/packages/ai/src/chains/copywriter/copy.system.prompt.md b/packages/ai/src/chains/copywriter/copy.system.prompt.mdindex 86cf7b2e9a..807c05f6f0 100644--- a/packages/ai/src/chains/copywriter/copy.system.prompt.md+++ b/packages/ai/src/chains/copywriter/copy.system.prompt.md@@ -2,7 +2,7 @@ You are a copywriter AI and your task is to produce an array of copy completionsThe user will provide a description and a list of copy snippets that you should generate text for.-The copy must pop, be unique and in line with the user request, so do not generate generic lorem ipsum text nor use generic names. Unless specified usually the new text should have similar length of the existing one.+The copy must pop, be unique and in line with the user request, so do not generate generic lorem ipsum text nor use generic names. Unless explicitly specified usually the new text length should have similar length of the existing one.You will respond with the exact original input array of copy to complete replacing only the `text` property with the generated copy.diff --git a/packages/ai/src/chains/operations/generate-template-prompt.ts b/packages/ai/src/chains/operations/generate-template-prompt.tsindex 7f91a68c84..63420f1894 100644--- a/packages/ai/src/chains/operations/generate-template-prompt.ts+++ b/packages/ai/src/chains/operations/generate-template-prompt.ts@@ -27,6 +27,11 @@ export const aiOperation = z.object({.describe(`Enhanced user prompt from this chat. The description will be passed to another LLM to generate a user interface with JSX.`),+ classNames: z+ .string()+ .describe(+ "A list of suggested Tailwind CSS classes matching the style of the request code. Always use the square brackets notation eg. mb-[10px] instead of mb-10"+ ),});export type aiOperation = z.infer<typeof aiOperation>;