@olakai/sdk
Version:
This document demonstrates how to use the Olakai SDK with all its features.
135 lines • 3.07 kB
TypeScript
/**
* Payload for monitoring API
*/
export type MonitorPayload = {
email?: string;
chatId?: string;
task?: string;
subTask?: string;
prompt: JsonValue;
response: JsonValue;
tokens?: number;
requestTime?: number;
errorMessage?: string;
blocked?: boolean;
sensitivity?: string[];
};
/**
* Payload for control API
*/
export type ControlPayload = {
prompt: JsonValue;
email?: string;
chatId?: string;
task?: string;
subTask?: string;
tokens?: number;
overrideControlCriteria?: string[];
};
/**
* Configuration for each monitored function
*/
export type MonitorOptions<TArgs extends any[], TResult> = {
onMonitoredFunctionError?: boolean;
chatId?: string | ((args: TArgs) => string);
email?: string | ((args: TArgs) => string);
task?: string;
subTask?: string;
sanitize?: boolean;
priority?: "low" | "normal" | "high";
askOverride?: string[];
};
export declare enum StorageType {
MEMORY = "memory",
FILE = "file",
LOCAL_STORAGE = "localStorage",
AUTO = "auto",
DISABLED = "disabled"
}
/**
* Global SDK configuration
*/
export type SDKConfig = {
apiKey: string;
monitorEndpoint: string;
controlEndpoint: string;
version: string;
enableBatching: boolean;
batchSize: number;
batchTime: number;
retries: number;
timeout: number;
enableStorage: boolean;
storageType: StorageType;
storageKey: string;
maxStorageSize: number;
cacheDirectory?: string;
sanitizePatterns: SanitizePattern[];
debug: boolean;
verbose: boolean;
};
/**
* Batch request for reporting API
*/
export type BatchRequest = {
id: string;
payload: MonitorPayload[];
timestamp: number;
retries: number;
priority: "low" | "normal" | "high";
};
/**
* Response for monitoring API
*/
export type MonitoringAPIResponse = {
success: boolean;
message: string;
totalRequests: number;
successCount: number;
failureCount: number;
results: Array<{
index: number;
success: boolean;
promptRequestId: string | null;
error: string | null;
}>;
};
/**
* Response for control API
*/
export type ControlAPIResponse = {
allowed: boolean;
details: {
detectedSensitivity: string[];
isAllowedPersona: boolean;
};
message?: string;
};
export type SanitizePattern = {
pattern?: RegExp;
key?: string;
replacement?: string;
};
export declare enum ErrorCode {
SUCCESS = 201,
PARTIAL_SUCCESS = 207,
FAILED = 500,
BAD_REQUEST = 400,
UNREACHABLE = 404
}
/**
* Represents any valid JSON value.
*/
export type JsonValue = null | boolean | number | string | JsonArray | JsonObject;
/**
* Represents an array of JSON values.
*/
export type JsonArray = JsonValue[];
/**
* Represents a JSON object, which is a key-value map where keys are strings and
* values are any valid JSON value.
*/
export type JsonObject = {
[key: string]: undefined | JsonValue;
};
//# sourceMappingURL=types.d.ts.map