import { BaseStringPromptTemplate } from "./string.js"; import type { BasePromptTemplateInput, TypedPromptInputValues } from "./base.js"; import { type TemplateFormat } from "./template.js"; import type { SerializedPromptTemplate } from "./serde.js"; import type { InputValues, PartialValues } from "../utils/types/index.js"; import { MessageContent, MessageContentComplex } from "../messages/index.js"; /** * Inputs to create a {@link PromptTemplate} * @augments BasePromptTemplateInput */ export interface PromptTemplateInput extends BasePromptTemplateInput { /** * The prompt template */ template: MessageContent; /** * The format of the prompt template. Options are "f-string" and "mustache" */ templateFormat?: Format; /** * Whether or not to try validating the template on initialization * * @defaultValue `true` */ validateTemplate?: boolean; /** * Additional fields which should be included inside * the message content array if using a complex message * content. */ additionalContentFields?: MessageContentComplex; } type NonAlphanumeric = " " | "\t" | "\n" | "\r" | '"' | "'" | "{" | "[" | "(" | "`" | ":" | ";"; /** * Recursive type to extract template parameters from a string. * @template T - The input string. * @template Result - The resulting array of extracted template parameters. */ type ExtractTemplateParamsRecursive = T extends `${string}{${infer Param}}${infer Rest}` ? Param extends `${NonAlphanumeric}${string}` ? ExtractTemplateParamsRecursive : ExtractTemplateParamsRecursive : Result; export type ParamsFromFString = { [Key in ExtractTemplateParamsRecursive[number] | (string & Record)]: any; }; export type ExtractedFStringParams = RunInput extends Symbol ? ParamsFromFString : RunInput; /** * Schema to represent a basic prompt for an LLM. * @augments BasePromptTemplate * @augments PromptTemplateInput * * @example * ```ts * import { PromptTemplate } from "langchain/prompts"; * * const prompt = new PromptTemplate({ * inputVariables: ["foo"], * template: "Say {foo}", * }); * ``` */ export declare class PromptTemplate extends BaseStringPromptTemplate implements PromptTemplateInput { static lc_name(): string; template: MessageContent; templateFormat: TemplateFormat; validateTemplate: boolean; /** * Additional fields which should be included inside * the message content array if using a complex message * content. */ additionalContentFields?: MessageContentComplex; constructor(input: PromptTemplateInput); _getPromptType(): "prompt"; /** * Formats the prompt template with the provided values. * @param values The values to be used to format the prompt template. * @returns A promise that resolves to a string which is the formatted prompt. */ format(values: TypedPromptInputValues): Promise; /** * Take examples in list format with prefix and suffix to create a prompt. * * Intended to be used a a way to dynamically create a prompt from examples. * * @param examples - List of examples to use in the prompt. * @param suffix - String to go after the list of examples. Should generally set up the user's input. * @param inputVariables - A list of variable names the final prompt template will expect * @param exampleSeparator - The separator to use in between examples * @param prefix - String that should go before any examples. Generally includes examples. * * @returns The final prompt template generated. */ static fromExamples(examples: string[], suffix: string, inputVariables: string[], exampleSeparator?: string, prefix?: string): PromptTemplate; /** * Load prompt template from a template f-string */ static fromTemplate(template: T, options?: Omit, "template" | "inputVariables">): PromptTemplate>; static fromTemplate(template: T, options?: Omit, "template" | "inputVariables">): PromptTemplate>; static fromTemplate(template: T, options?: Omit, "template" | "inputVariables">): PromptTemplate; /** * Partially applies values to the prompt template. * @param values The values to be partially applied to the prompt template. * @returns A new instance of PromptTemplate with the partially applied values. */ partial(values: PartialValues): Promise, NewPartialVariableName>>, any>>; serialize(): SerializedPromptTemplate; static deserialize(data: SerializedPromptTemplate): Promise; } export {};