@olakai/sdk
Version:
This document demonstrates how to use the Olakai SDK with all its features.
150 lines • 3.46 kB
TypeScript
export type OlakaiEventParams = {
prompt: string;
response: string;
userEmail?: string;
chatId?: string;
task?: string;
subTask?: string;
tokens?: number;
requestTime?: number;
shouldScore?: boolean;
customDimensions?: {
dim1?: string;
dim2?: string;
dim3?: string;
dim4?: string;
dim5?: string;
[key: string]: string | undefined;
};
customMetrics?: {
metric1?: number;
metric2?: number;
metric3?: number;
metric4?: number;
metric5?: number;
[key: string]: number | undefined;
};
};
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[];
shouldScore?: boolean;
customDimensions?: {
dim1?: string;
dim2?: string;
dim3?: string;
dim4?: string;
dim5?: string;
[key: string]: string | undefined;
};
customMetrics?: {
metric1?: number;
metric2?: number;
metric3?: number;
metric4?: number;
metric5?: number;
[key: string]: number | undefined;
};
};
/**
* Global SDK configuration
*/
export type SDKConfig = {
apiKey: string;
monitorEndpoint: string;
controlEndpoint: string;
version: string;
retries: number;
timeout: number;
debug: boolean;
verbose: boolean;
};
/**
* 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;
};
/**
* 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 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