@langchain/core
Version:
Core LangChain.js abstractions and schemas
1 lines • 5.77 kB
Source Map (JSON)
{"version":3,"file":"base.d.cts","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;;;AAA2DV,UAK1CW,uBAL0CX,CAAAA,uBAKKF,WALLE,GAAAA,GAAAA,EAAAA,4BAAAA,MAAAA,GAAAA,GAAAA,CAAAA,CAAAA;EAAZF;AAAW;AAC1D;EAIiBa,cAAAA,EAIGG,KAJHH,CAISH,OAJc,CAAA,MAIAI,cAJAC,EAAAA,MAAAA,CAAAA,CAAAA;EAAwBf;;;EAI5CgB,YAAAA,CAAAA,EAIDZ,gBAJCY;EAIDZ;EAEkBW,gBAAAA,CAAAA,EAAdd,aAAcc,CAAAA,mBAAAA,CAAAA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