2023-09-21 01:49:00 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { z } from 'zod';
|
|
|
|
|
|
|
|
const headerChoices = [
|
|
|
|
{
|
|
|
|
slug: 'woocommerce-blocks/header-essential',
|
|
|
|
label: 'Essential Header',
|
|
|
|
},
|
|
|
|
{
|
2023-11-08 03:24:47 +00:00
|
|
|
slug: 'woocommerce-blocks/header-centered-menu',
|
2023-09-21 01:49:00 +00:00
|
|
|
label: 'Centered Menu with search Header',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
slug: 'woocommerce-blocks/header-minimal',
|
|
|
|
label: 'Minimal Header',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
slug: 'woocommerce-blocks/header-large',
|
|
|
|
label: 'Large Header',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const allowedHeaders: string[] = headerChoices.map( ( header ) => header.slug );
|
|
|
|
|
|
|
|
export const headerValidator = z.object( {
|
|
|
|
slug: z.string().refine( ( slug ) => allowedHeaders.includes( slug ), {
|
|
|
|
message: 'Header not part of allowed list',
|
|
|
|
} ),
|
|
|
|
} );
|
|
|
|
|
|
|
|
export const defaultHeader = {
|
|
|
|
queryId: 'default_header',
|
|
|
|
|
|
|
|
// make sure version is updated every time the prompt is changed
|
|
|
|
version: '2023-09-19',
|
|
|
|
prompt: ( businessDescription: string, look: string, tone: string ) => {
|
|
|
|
return `
|
|
|
|
You are a WordPress theme expert. Analyse the following store description, merchant's chosen look and tone, and determine the most appropriate header.
|
|
|
|
Respond only with one header and only its JSON.
|
|
|
|
|
|
|
|
Chosen look and tone: ${ look } look, ${ tone } tone.
|
|
|
|
Business description: ${ businessDescription }
|
|
|
|
|
2023-11-08 03:24:47 +00:00
|
|
|
Headers to choose from:
|
2023-09-21 01:49:00 +00:00
|
|
|
${ JSON.stringify( headerChoices ) }
|
|
|
|
`;
|
|
|
|
},
|
|
|
|
responseValidation: headerValidator.parse,
|
|
|
|
};
|