mongodb-rag-core
Version:
Common elements used by MongoDB Chatbot Framework components.
56 lines • 1.99 kB
TypeScript
import { TaskOptions } from "simple-git";
import { DataSource } from "./DataSource";
import { Page, PageMetadata } from "../contentStore";
/**
Function to convert a file in the repo into a `Page` or `Page[]`.
@param path - Path to file in repo
@param content - Contents of file in repo
*/
export type HandlePageFunc = (path: string, content: string) => Promise<undefined | Omit<Page, "sourceName"> | Omit<Page, "sourceName">[]>;
export interface MakeGitDataSourceParams {
/** Name of project */
name: string;
/**
URI for git repo
@example
"https://github.com/mongodb/mongo-java-driver.git"
*/
repoUri: string;
/**
Options for `simple-git` clone command.
@default
{ "--depth": 1 }
*/
repoOptions?: TaskOptions;
/**
Filter function for selecting files in the repo to parse to pages.
@example
(path: string) => path.endsWith(".html")
*/
filter: FilterFunc;
/**
Metadata to be included in all pages.
*/
metadata?: PageMetadata;
handlePage: HandlePageFunc;
}
/**
Loads and processes files from a Git repo (can be hosted anywhere).
*/
export declare function makeGitDataSource({ name, handlePage, filter, metadata, repoUri, repoOptions, }: MakeGitDataSourceParams): DataSource;
/**
@param prefix - prefix for the temporary directory name
*/
export declare function makeRandomTmp(prefix: string): string;
export declare function getRepoLocally({ repoPath, localPath, options, }: {
repoPath: string;
localPath: string;
options?: TaskOptions;
}): Promise<void>;
export type FilterFunc = (path: string) => boolean;
export declare function getRelevantFilePathsInDir(directoryPath: string, filter: FilterFunc, fileList?: string[]): string[];
export declare function getRelevantFilesAsStrings({ directoryPath, filter, }: {
directoryPath: string;
filter: FilterFunc;
}): Promise<Record<string, string>>;
//# sourceMappingURL=GitDataSource.d.ts.map