import { FrameworkError } from './errors.js'; import { PlainObject, ObjectLike } from './internals/types.js'; import { Serializable } from './internals/serializable.js'; import { ZodType, z } from 'zod'; import { SchemaObject } from 'ajv'; import './internals/helpers/guards.js'; /** * Copyright 2025 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ type PostInfer = T extends PlainObject ? { [K in keyof T]: T[K] extends Date ? string : T[K]; } : T; type InferValue = T extends ZodType ? PostInfer : never; type PromptTemplateRenderFn = (this: InferValue) => any; type PromptTemplateRenderInput = z.input> = { [K in Extract]: T2[K] | PromptTemplateRenderFn | undefined; }; interface PromptTemplateInput { template: string; customTags?: [string, string]; escape?: boolean; schema: SchemaObject; defaults?: Partial>; functions?: Record>; } type PromptTemplateConstructor = N extends ZodType ? Omit, "schema" | "functions" | "defaults"> & { schema: N; functions?: Record>; defaults?: Partial>; } : Omit, "schema"> & { schema: T | SchemaObject; }; type Customizer = ((config: Required>) => PromptTemplateConstructor) | ((config: Required>) => void); declare class PromptTemplateError extends FrameworkError { template: PromptTemplate; constructor(message: string, template: PromptTemplate, context?: ObjectLike); } declare class ValidationPromptTemplateError extends PromptTemplateError { } declare class PromptTemplate extends Serializable { protected config: Required>; static functions: { trim: () => (text: string, render: (value: string) => string) => string; }; constructor(config: Omit, "schema"> & { schema: T | SchemaObject; }); validateInput(input: unknown): asserts input is T; fork(customizer: Customizer): PromptTemplate; fork(customizer: Customizer): PromptTemplate; render(input: PromptTemplateRenderInput): string; loadSnapshot(data: ReturnType): void; createSnapshot(): { config: Required>; }; } declare namespace PromptTemplate { type infer = PromptTemplate>; } export { PromptTemplate, PromptTemplateError, type PromptTemplateInput, type PromptTemplateRenderFn, type PromptTemplateRenderInput, ValidationPromptTemplateError };