import type { Context } from "../context.js"; import { Resource } from "../resource.js"; import type { Secret } from "../secret.js"; import { type ModelConfig } from "./client.js"; /** * Properties for creating or updating a CSSFile */ export interface CSSFileProps { /** * Path to the CSS file */ path: string; /** * Base URL for the OpenAI API * @default 'https://api.openai.com/v1' */ baseURL?: string; /** * Prompt for generating content * Use alchemy template literals to include file context: * @example * prompt: await alchemy` * Generate CSS styles for: * ${alchemy.file("src/components/Button.jsx")} * ` */ prompt: string; /** * System prompt for the model * This is used to provide instructions to the model about how to format the response * The default system prompt instructs the model to return CSS code inside ```css fences * @default "You are a CSS code generator. Create CSS code based on the user's requirements. Your response MUST include only CSS code inside ```css fences. Do not include any other text, explanations, or multiple code blocks." */ system?: string; /** * OpenAI API key to use for generating content * If not provided, will use OPENAI_API_KEY environment variable */ apiKey?: Secret; /** * Model configuration */ model?: ModelConfig; /** * Temperature for controlling randomness in generation. * Higher values (e.g., 0.8) make output more random, * lower values (e.g., 0.2) make it more deterministic. * @default 0.7 */ temperature?: number; } /** * A CSS file that can be created, updated, and deleted */ export interface CSSFile extends CSSFileProps, Resource<"ai::CSSFile"> { /** * Content of the CSS file */ content: string; /** * Time at which the file was created */ createdAt: number; /** * Time at which the file was last updated */ updatedAt: number; } /** * Resource for generating CSS files using AI models. * Extracts CSS code from between ```css fences and validates the response. * * @example * // Create styles for a website * const mainStyles = await CSSFile("main-styles", { * path: "./public/css/main.css", * prompt: await alchemy` * Generate modern CSS styles for a company website with: * - Clean, minimalist design * - Primary color: #0062ff * - Secondary color: #6c757d * - Light gray background * - Responsive layout for mobile, tablet, and desktop * - Custom styles for buttons, cards, and navigation * `, * model: { * id: "gpt-4o", * provider: "openai" * } * }); * * @example * // Generate CSS based on existing HTML * const componentStyles = await CSSFile("component-styles", { * path: "./src/styles/component.css", * prompt: await alchemy` * Create CSS styles for this HTML component: * ${alchemy.file("src/components/Card.html")} * * The styles should be: * - Modern and clean * - Include hover effects and transitions * - Support both light and dark themes * - Use CSS variables for colors and spacing * `, * temperature: 0.2 * }); * * @example * // Generate CSS animation with custom system prompt * const animationStyles = await CSSFile("animations", { * path: "./src/styles/animations.css", * prompt: await alchemy` * Create CSS animations for: * - Fade in/out * - Slide in from different directions * - Pulse effect * - Bounce effect * - Scale in/out * - Rotate * * Each animation should be reusable via class names. * `, * system: "You are an expert CSS animator. Create a single CSS file inside ```css fences with no additional text. Use modern CSS animation techniques and include vendor prefixes where needed for browser compatibility.", * model: { * id: "claude-3-opus-20240229", * provider: "anthropic" * } * }); */ export declare const CSSFile: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context, id: string, props: CSSFileProps) => Promise); //# sourceMappingURL=css-file.d.ts.map