@gptp/core
Version:
Library to supercharge your use of large language models
56 lines (55 loc) • 3.23 kB
TypeScript
import { string_name } from '.././types/typeAliases';
import { ExecutionTools } from '../execution/ExecutionTools';
import { PtpExecutor } from '../execution/PtpExecutor';
import { Prompt } from '../types/Prompt';
import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
import { PromptTemplatePipelineString } from '../types/PromptTemplatePipelineString';
import { PromptTemplatePipeline } from './PromptTemplatePipeline';
/**
* Library of prompt template pipelines that groups together prompt template pipelines for an application. This is a very thin wrapper around the Array / Set of prompt template pipelines.
*
* Prompt Template Pipeline library is a useful helper in execution, it can be shared between execution and consumer parts of the app and make common knowledge about prompt template pipelines.
*
* It allows to create executor functions from prompt template pipelines in the library.
*
* @see https://github.com/webgptorg/ptp#prompt-template-pipeline-library
*/
export declare class PromptTemplatePipelineLibrary {
readonly promptTemplatePipelines: Record<string_name, PromptTemplatePipeline>;
/**
* Constructs PromptTemplatePipeline from any sources
*
* Note: During the construction syntax and logic of all sources are validated
* Note: You can combine .ptp.md and .ptp.json files BUT it is not recommended
*
* @param ptpSources contents of .ptp.md or .ptp.json files
* @returns PromptTemplatePipelineLibrary
*/
static fromSources(ptpSources: Record<string_name, PromptTemplatePipelineJson | PromptTemplatePipelineString>): PromptTemplatePipelineLibrary;
private constructor();
/**
* Gets prompt template pipeline by name
*/
getPtp(name: string_name): PromptTemplatePipeline;
/**
* Checks whether prompt is in the library
*/
isPromptInLibrary(prompt: Prompt): boolean;
/**
* Gets executor function for given prompt template pipeline
*/
createExecutor(name: string_name, tools: ExecutionTools): PtpExecutor;
}
/**
* TODO: !! [👐][🧠] Split of PromptTemplatePipeline,PromptTemplatePipelineLibrary between interface and class
* TODO: !! [👐] Make promptTemplatePipelines private WHEN split between interface and class
* TODO: [🧠] Maybe isPromptInLibrary should be separate utility function
* TODO: [🧠] Maybe createExecutor should be separate utility function
* TODO: Static method fromDirectory
* TODO: [🤜] Add generic type for entry and result parameters
* TODO: [🧠] Is it better to ptpLibrary.executePtp('writeXyz',{...}) OR ptpLibrary.createExecutor('writeXyz')({...}) OR createExecutor(ptpLibrary.getPtp('writeXyz'))
* TODO: [🧠] Formarly (before commit 62229afce7668a5b85077cc18becf798b583bf8d) there were two classes PromptTemplatePipelineLibrary+PtpLibraryExecutor (maybe it was better?)
* TODO: [🧠] Is it better to pass tools into getExecutor or into constructor
* Maybe it is not a good idea to cache executors when they are can be created with different tools
* TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
*/