UNPKG

@handit.ai/ai-wrapper

Version:

🤖 Intelligent AI execution system with built-in tracking, evaluation, and self-improvement capabilities. The complete AI intelligence platform for enterprise applications.

190 lines (169 loc) 6.09 kB
declare module '@handit.ai/ai-wrapper' { export interface AIWrapperOptions { handitApiKey?: string; openaiApiKey?: string | null; googleApiKey?: string | null; anthropicApiKey?: string | null; trackingUrl?: string | null; performanceUrl?: string | null; ssoTrackingUrl?: string | null; } export interface ExecutionOptions { agentName: string; input: string; model?: string; nodeName?: string; additionalOptions?: Record<string, any>; } export interface ExecutionResult { success: boolean; output?: string; executionId?: string; prompts?: Array<{ type: string; content: string; }>; error?: string; } export interface GenericExecutionOptions extends ExecutionOptions { provider: 'openai' | 'google' | 'anthropic'; } export interface TrackingOptions { input: any; output: any; nodeName: string; agentName: string; nodeType?: string; executionId: string; } export interface PromptsOptions { agentName: string; } export interface Prompt { type: string; content: string; } /** * Intelligent AI execution system with built-in tracking, evaluation, and self-improvement capabilities. * * @example * ```typescript * import { AIWrapper } from '@handit.ai/ai-wrapper'; * * const aiWrapper = new AIWrapper({ * handitApiKey: 'your-key', * openaiApiKey: 'openai-key' * }); * * const result = await aiWrapper.runSmartAgent({ * agentName: 'customer-support', * input: 'How can I help you?' * }); * ``` */ export class AIWrapper { /** * Creates a new AI Wrapper instance with intelligent execution capabilities * @param options Configuration options for the AI wrapper */ constructor(options?: AIWrapperOptions); /** * 🤖 Smart AI execution with full intelligence, tracking, and optimization (OpenAI) * The flagship method - includes complete AI intelligence with automatic optimization * * @param options Execution options * @returns Promise<ExecutionResult> - Result with AI response and tracking data */ runSmartAgent(options: ExecutionOptions): Promise<ExecutionResult>; /** * 🎯 Optimized AI execution with Google AI - Performance and quality focused * Uses Google's advanced AI models with optimization tracking * * @param options Execution options * @returns Promise<ExecutionResult> - Result with AI response and optimization metrics */ runOptimizedAgent(options: ExecutionOptions): Promise<ExecutionResult>; /** * 🛡️ Tracked AI execution with Anthropic Claude - Enhanced safety tracking * Uses Anthropic's safety-focused models with detailed execution analysis * * @param options Execution options * @returns Promise<ExecutionResult> - Result with AI response and safety tracking */ runTrackedAgent(options: ExecutionOptions): Promise<ExecutionResult>; /** * 🔥 Direct OpenAI execution with tracking * Direct access to OpenAI models with full tracking capabilities * * @param options Execution options * @returns Promise<ExecutionResult> - Result with AI response and tracking */ runWithOpenAI(options: ExecutionOptions): Promise<ExecutionResult>; /** * 🌟 Direct Google AI execution with tracking * Direct access to Google AI models with full tracking capabilities * * @param options Execution options * @returns Promise<ExecutionResult> - Result with AI response and tracking */ runWithGoogle(options: ExecutionOptions): Promise<ExecutionResult>; /** * ⚡ Direct Anthropic execution with tracking * Direct access to Anthropic models with full tracking capabilities * * @param options Execution options * @returns Promise<ExecutionResult> - Result with AI response and tracking */ runWithAnthropic(options: ExecutionOptions): Promise<ExecutionResult>; /** * 🎛️ Generic AI execution - specify any provider * Flexible execution method where you can choose the AI provider * * @param options Generic execution options with provider specification * @returns Promise<ExecutionResult> - Result with AI response and tracking */ executeAgent(options: GenericExecutionOptions): Promise<ExecutionResult>; /** * 📥 Get optimized prompts for an agent * Retrieves the current active prompts for the specified agent * * @param options Prompts retrieval options * @returns Promise<Prompt[]> - Array of prompts for the agent */ getPrompts(options: PromptsOptions): Promise<Prompt[]>; /** * 📊 Manual tracking of node execution * Manually track any execution for analytics and improvement * * @param options Tracking options * @returns Promise<any> - Tracking result */ track(options: TrackingOptions): Promise<any>; // Legacy methods for backward compatibility /** * @deprecated Use runWithOpenAI instead */ executeWithOpenAI(options: ExecutionOptions): Promise<ExecutionResult>; /** * @deprecated Use runWithGoogle instead */ executeWithGoogle(options: ExecutionOptions): Promise<ExecutionResult>; /** * @deprecated Use runWithAnthropic instead */ executeWithAnthropic(options: ExecutionOptions): Promise<ExecutionResult>; } // Re-export handit functions for direct access export function fetchPrompts(options: PromptsOptions): Promise<Prompt[]>; export function trackNode(options: TrackingOptions): Promise<any>; export function startTracing(options: { agentName: string }): Promise<{ executionId: string }>; export function endTracing(options: { executionId: string; agentName?: string }): Promise<void>; export function config(options: { apiKey: string; trackingUrl?: string; performanceUrl?: string; ssoTrackingUrl?: string; }): void; // Default export export default AIWrapper; }