@prexo/ai-chat-sdk
Version:
AI Chat SDK for building AI chat applications with Context and History
107 lines (102 loc) • 3.75 kB
text/typescript
import { SDKConfig, BaseVectorContext, BaseMessageHistory, EventName, EventProperties, SDKStatus, TelementryOptions, GetContextClientParams, GetHistoryClientParams } from './types.cjs';
export { ExtVectorConfig, RedisHistoryConfig, VectorContextResult } from './types.cjs';
import { Telementry } from './telemetry.cjs';
export { ExtVector, VectorDB, getContextClient } from './context.cjs';
export { InRedisHistory, getHistoryClient } from './history.cjs';
import '@upstash/redis';
import 'ai';
import '@upstash/vector';
declare const SDK_VERSION = "1.0.1-beta.1";
declare const SDK_NAME = "@prexo/ai-chat-sdk";
declare const DEFAULT_CHAT_SESSION_ID: (id?: string) => string;
declare const DEFAULT_HISTORY_LENGTH = 50;
declare const DEFAULT_HISTORY_TTL = 86400;
declare const DEFAULT_MSG_ID: string;
declare const DEFAULT_SIMILARITY_THRESHOLD = 0.5;
declare const DEFAULT_TOP_K = 5;
/**
* AI Chat SDK - Main class for configuring and managing AI chat functionality
*
* @example
* ```typescript
* // Professional usage - recommended approach
* const sdk = new AIChatSDK({
* telemetry: { enabled: true },
* context: {
* vector: {
* url: 'https://your-vector-db.upstash.io',
* token: 'your-token',
* namespace: 'your-namespace'
* }
* }
* });
*
* // Use the configured clients
* const contextClient = sdk.getContextClient();
* const historyClient = sdk.getHistoryClient();
* ```
*/
declare class AIChatSDK {
private telemetry?;
private contextClient?;
private historyClient?;
/**
* Creates a new AIChatSDK instance with the specified configuration
*
* @param config - Configuration options for telemetry, context, and history
*
* @example
* ```typescript
* const sdk = new AIChatSDK({
* telemetry: { enabled: true },
* context: { vector: { url: '...', token: '...', namespace: '...' } },
* history: { redis: { url: '...', token: '...' } }
* });
* ```
*/
constructor(config?: SDKConfig);
/**
* Get the configured telemetry instance
*/
getTelemetry(): Telementry | undefined;
/**
* Get the configured context client
*/
getContextClient(): BaseVectorContext | undefined;
/**
* Get the configured history client
*/
getHistoryClient(): BaseMessageHistory | undefined;
/**
* Send a telemetry event if telemetry is enabled
*/
trackEvent(event: EventName, properties: EventProperties): Promise<void>;
/**
* Check if the SDK is properly configured
*/
isConfigured(): boolean;
/**
* Get SDK configuration status
*/
getConfigurationStatus(): SDKStatus;
/**
* Get SDK version information
*/
getVersionInfo(): {
version: string;
name: string;
};
/**
* Reset all configured clients
*/
reset(): void;
/**
* Update SDK configuration
*/
updateConfig(config: SDKConfig): void;
}
declare function createAIChatSDK(config?: SDKConfig): AIChatSDK;
declare function createTelemetry(options: TelementryOptions): Telementry;
declare function createContextClient(params: GetContextClientParams): BaseVectorContext | undefined;
declare function createHistoryClient(params?: GetHistoryClientParams): BaseMessageHistory | undefined;
export { AIChatSDK, BaseMessageHistory, DEFAULT_CHAT_SESSION_ID, DEFAULT_HISTORY_LENGTH, DEFAULT_HISTORY_TTL, DEFAULT_MSG_ID, DEFAULT_SIMILARITY_THRESHOLD, DEFAULT_TOP_K, EventName, EventProperties, GetContextClientParams, GetHistoryClientParams, SDKConfig, SDKStatus, SDK_NAME, SDK_VERSION, Telementry, TelementryOptions, createAIChatSDK, createContextClient, createHistoryClient, createTelemetry, AIChatSDK as default };