forked from DavidSouther/ailly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
31 lines (27 loc) · 927 Bytes
/
index.ts
File metadata and controls
31 lines (27 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import type { Content, View } from "../content/content.js";
import type { Engine } from "../engine/index.js";
import type { PipelineSettings } from "../index.js";
import { RAG } from "./rag.js";
export type PluginBuilder = (
engine: Engine,
settings: PipelineSettings,
) => Promise<Plugin>;
export interface Plugin {
augment(c: Content): Promise<void>;
clean(c: Content): Promise<void>;
update(c: Content[]): Promise<void>;
view?(): Promise<View>;
}
export const PLUGINS: Record<string, { default: PluginBuilder }> = {
noop: { default: RAG.empty as unknown as PluginBuilder },
none: { default: RAG.empty as unknown as PluginBuilder },
};
export async function getPlugin(
name: keyof typeof PLUGINS | string,
): Promise<{ default: PluginBuilder }> {
if (name.startsWith("file://")) {
return import(name);
}
if (!PLUGINS[name]) throw new Error(`Unknown plugin ${name}`);
return PLUGINS[name];
}