UNPKG

@promptbook/browser

Version:

Promptbook: Run AI apps in plain human language across multiple models and platforms

66 lines (65 loc) 2.72 kB
import type { ExecutionTools } from '../../execution/ExecutionTools'; import type { PrepareAndScrapeOptions } from '../../prepare/PrepareAndScrapeOptions'; import type { string_dirname } from '../../types/typeAliases'; import type { string_pipeline_root_url } from '../../types/typeAliases'; import type { PipelineCollection } from '../PipelineCollection'; /** * Options for `createCollectionFromDirectory` function * * Note: `rootDirname` is not needed because it is the folder in which `.book` or `.book` file is located * This is not same as `path` which is the first argument of `createCollectionFromDirectory` - it can be a subfolder */ type CreatePipelineCollectionFromDirectoryOptions = Omit<PrepareAndScrapeOptions, 'rootDirname'> & { /** * If true, the directory is searched recursively for pipelines * * @default true */ isRecursive?: boolean; /** * If true, the collection creation outputs information about each file it reads * * @default false */ isVerbose?: boolean; /** * This will be used as a root URL for all pipelines in the collection * * It has 2 purposes: * 1) Every pipeline in the collection is checked if it is a child of `rootUrl` * 2) If the pipeline does not have a URL, it is created from the `rootUrl` and path to the pipeline * * @default false */ rootUrl?: string_pipeline_root_url; /** * If true, directory will be scanned only when needed not during the construction * * @default false */ isLazyLoaded?: boolean; /** * If true, whole collection creation crashes on error in any pipeline * If true and isLazyLoaded is true, the error is thrown on first access to the pipeline * * @default true */ isCrashedOnError?: boolean; }; /** * Constructs Pipeline from given directory * * Note: Works only in Node.js environment because it reads the file system * * @param rootPath - path to the directory with pipelines * @param tools - Execution tools to be used for pipeline preparation if needed - If not provided, `$provideExecutionToolsForNode` will be used * @param options - Options for the collection creation * @returns PipelineCollection * @public exported from `@promptbook/node` */ export declare function createCollectionFromDirectory(rootPath: string_dirname, tools?: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options?: CreatePipelineCollectionFromDirectoryOptions): Promise<PipelineCollection>; export {}; /** * TODO: [🖇] What about symlinks? Maybe option isSymlinksFollowed * TODO: Maybe move from `@promptbook/node` to `@promptbook/core` as we removes direct dependency on `fs` */