mirror of
https://gh-proxy.org/https://github.com/klinsmaya/gateway.git
synced 2026-11-10 10:07:26 +08:00
31 lines
756 B
TypeScript
31 lines
756 B
TypeScript
export interface PluginContext {
|
|
[key: string]: any;
|
|
requestType: 'complete' | 'chatComplete';
|
|
provider: string;
|
|
}
|
|
|
|
export interface PluginParameters {
|
|
[key: string]: any;
|
|
credentials?: { [key: string]: string };
|
|
}
|
|
|
|
export interface PluginHandlerResponse {
|
|
error: any;
|
|
verdict?: boolean;
|
|
// The data object can be any JSON object or null.
|
|
data?: any | null;
|
|
}
|
|
|
|
export type HookEventType = 'beforeRequestHook' | 'afterRequestHook';
|
|
|
|
export type PluginHandler = (
|
|
context: PluginContext,
|
|
parameters: PluginParameters,
|
|
eventType: HookEventType,
|
|
options: {
|
|
env: Record<string, any>;
|
|
},
|
|
// Handler function, useful in cases for a provider with multiple guardrails ex: mistral
|
|
fn?: string
|
|
) => Promise<PluginHandlerResponse>;
|