UNPKG

@gptp/core

Version:

Library to supercharge your use of large language models

69 lines (68 loc) 3.36 kB
import { string_name } from '.././types/typeAliases'; import { PromptTemplateJson } from '../types/PromptTemplatePipelineJson/PromptTemplateJson'; import { PromptTemplateParameterJson } from '../types/PromptTemplatePipelineJson/PromptTemplateParameterJson'; import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson'; import { PromptTemplatePipelineString } from '../types/PromptTemplatePipelineString'; /** * Prompt template pipeline is the **core concept of this library**. * It represents a series of prompt templates chained together to form a pipeline / one big prompt template with input and result parameters. * * It can have 3 formats: * - **.ptp.md file** in custom markdown format described above * - **JSON** format, parsed from the .ptp.md file * - _(this)_ **Object** which is created from JSON format and bound with tools around (but not the execution logic) * * @see https://github.com/webgptorg/ptp#prompt-template-pipeline */ export declare class PromptTemplatePipeline { readonly ptpUrl: URL | null; readonly parameters: Record<string_name, PromptTemplateParameterJson>; readonly promptTemplates: Array<PromptTemplateJson>; /** * Constructs PromptTemplatePipeline from any source * * Note: During the construction syntax and logic of source is validated * * @param source content of .ptp.md or .ptp.json file * @returns PromptTemplatePipeline */ static fromSource(ptpSource: PromptTemplatePipelineString | PromptTemplatePipelineJson): PromptTemplatePipeline; /** * Constructs PromptTemplatePipeline from markdown source * * Note: During the construction syntax and logic of source is validated * * @param ptpString content of .ptp.md file * @returns PromptTemplatePipeline */ static fromString(ptpString: PromptTemplatePipelineString): PromptTemplatePipeline; /** * Constructs PromptTemplatePipeline from JSON source * * Note: During the construction the source is logic validated * * @param ptpjson content of .ptp.json file parsed into JSON * @returns PromptTemplatePipeline */ static fromJson(ptpjson: PromptTemplatePipelineJson): PromptTemplatePipeline; private constructor(); /** * Returns the first prompt template in the pipeline */ get entryPromptTemplate(): PromptTemplateJson; /** * Gets the parameter that is the result of given prompt template */ getResultingParameter(promptTemplateName: string_name): PromptTemplateParameterJson; /** * Gets the following prompt template in the pipeline or null if there is no following prompt template and this is the last one */ getFollowingPromptTemplate(promptTemplateName: string_name): PromptTemplateJson | null; } /** * TODO: !! [👐][🧠] Split of PromptTemplatePipeline,PromptTemplatePipelineLibrary between interface and class * TODO: !! [👐] Make parameters and promptTemplates private WHEN split between interface and class * TODO: !! Add generic type for entry and result parameters * TODO: Can be Array elegantly typed such as it must have at least one element? * TODO: [🧠] Each PromptTemplatePipeline should have its unique hash to be able to compare them and execute on server ONLY the desired ones */