UNPKG

@langchain/core

Version:
1 lines 5.83 kB
{"version":3,"file":"base.d.ts","names":["InputValues","PartialValues","StringWithAutocomplete","BasePromptValueInterface","BaseOutputParser","SerializedFields","Runnable","BaseCallbackConfig","TypedPromptInputValues","RunInput","Extract","Example","Record","BasePromptTemplateInput","InputVariables","PartialVariableName","Array","BasePromptTemplate","RunOutput","Promise"],"sources":["../../src/prompts/base.d.ts"],"sourcesContent":["import type { InputValues, PartialValues, StringWithAutocomplete } from \"../utils/types/index.js\";\nimport { type BasePromptValueInterface } from \"../prompt_values.js\";\nimport { BaseOutputParser } from \"../output_parsers/index.js\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\nimport { Runnable } from \"../runnables/base.js\";\nimport { BaseCallbackConfig } from \"../callbacks/manager.js\";\nexport type TypedPromptInputValues<RunInput> = InputValues<StringWithAutocomplete<Extract<keyof RunInput, string>>>;\nexport type Example = Record<string, string>;\n/**\n * Input common to all prompt templates.\n */\nexport interface BasePromptTemplateInput<InputVariables extends InputValues = any, PartialVariableName extends string = any> {\n /**\n * A list of variable names the prompt template expects\n */\n inputVariables: Array<Extract<keyof InputVariables, string>>;\n /**\n * How to parse the output of calling an LLM on this formatted prompt\n */\n outputParser?: BaseOutputParser;\n /** Partial variables */\n partialVariables?: PartialValues<PartialVariableName>;\n}\n/**\n * Base class for prompt templates. Exposes a format method that returns a\n * string prompt given a set of input values.\n */\nexport declare abstract class BasePromptTemplate<RunInput extends InputValues = any, RunOutput extends BasePromptValueInterface = BasePromptValueInterface, PartialVariableName extends string = any> extends Runnable<RunInput, RunOutput> implements BasePromptTemplateInput {\n PromptValueReturnType: RunOutput;\n lc_serializable: boolean;\n lc_namespace: string[];\n get lc_attributes(): SerializedFields | undefined;\n inputVariables: Array<Extract<keyof RunInput, string>>;\n outputParser?: BaseOutputParser;\n partialVariables: PartialValues<PartialVariableName>;\n /**\n * Metadata to be used for tracing.\n */\n metadata?: Record<string, unknown>;\n /** Tags to be used for tracing. */\n tags?: string[];\n constructor(input: BasePromptTemplateInput);\n abstract partial(values: PartialValues): Promise<BasePromptTemplate<RunInput, RunOutput, PartialVariableName>>;\n /**\n * Merges partial variables and user variables.\n * @param userVariables The user variables to merge with the partial variables.\n * @returns A Promise that resolves to an object containing the merged variables.\n */\n mergePartialAndUserVariables(userVariables: TypedPromptInputValues<RunInput>): Promise<InputValues<Extract<keyof RunInput, string> | PartialVariableName>>;\n /**\n * Invokes the prompt template with the given input and options.\n * @param input The input to invoke the prompt template with.\n * @param options Optional configuration for the callback.\n * @returns A Promise that resolves to the output of the prompt template.\n */\n invoke(input: RunInput, options?: BaseCallbackConfig): Promise<RunOutput>;\n /**\n * Format the prompt given the input values.\n *\n * @param values - A dictionary of arguments to be passed to the prompt template.\n * @returns A formatted prompt string.\n *\n * @example\n * ```ts\n * prompt.format({ foo: \"bar\" });\n * ```\n */\n abstract format(values: TypedPromptInputValues<RunInput>): Promise<string>;\n /**\n * Format the prompt given the input values and return a formatted prompt value.\n * @param values\n * @returns A formatted PromptValue.\n */\n abstract formatPromptValue(values: TypedPromptInputValues<RunInput>): Promise<RunOutput>;\n /**\n * Return the string type key uniquely identifying this class of prompt template.\n */\n abstract _getPromptType(): string;\n}\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;;;KAMYQ,mCAAmCR,YAAYE,uBAAuBQ,cAAcD;KACpFE,OAAAA,GAAUC;;AADtB;;AAAkFF,UAKjEG,uBALiEH,CAAAA,uBAKlBV,WALkBU,GAAAA,GAAAA,EAAAA,4BAAAA,MAAAA,GAAAA,GAAAA,CAAAA,CAAAA;EAAvBR;;AAAD;EAC9CS,cAAO,EAQCK,KARD,CAQON,OARE,CAAA,MAQYI,cARZ,EAAA,MAAA,CAAA,CAAA;EAIXD;;;EAISH,YAAAA,CAAAA,EAIPN,gBAJOM;EAANM;EAIDZ,gBAAAA,CAAAA,EAEIH,aAFJG,CAEkBW,mBAFlBX,CAAAA;;;AAEiB;AAMpC;;AAAuGD,uBAAzEc,kBAAyEd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