Interface IUtilityAI

Interface

IUtilityAI Defines the contract for a comprehensive Utility AI service.

interface IUtilityAI {
    utilityId: string;
    initialize(config): Promise<void>;
    summarize(textToSummarize, options?): Promise<string>;
    classifyText(textToClassify, options): Promise<ClassificationResult>;
    extractKeywords(textToAnalyze, options?): Promise<string[]>;
    tokenize(text, options?): Promise<string[]>;
    stemTokens(tokens, options?): Promise<string[]>;
    calculateSimilarity(text1, text2, options?): Promise<number>;
    analyzeSentiment(text, options?): Promise<SentimentResult>;
    detectLanguage(text, options?): Promise<LanguageDetectionResult[]>;
    normalizeText(text, options?): Promise<string>;
    generateNGrams(tokens, options): Promise<Record<number, string[][]>>;
    calculateReadability(text, options): Promise<ReadabilityResult>;
    parseJsonSafe<T>(jsonString, options?): Promise<null | T>;
    checkHealth(): Promise<{
        isHealthy: boolean;
        details?: any;
        dependencies?: {
            name: string;
            isHealthy: boolean;
            details?: any;
        }[];
    }>;
    shutdown?(): Promise<void>;
    trainModel?(trainingData, modelType, trainingOptions?): Promise<{
        success: boolean;
        message?: string;
        modelId?: string;
    }>;
    saveTrainedModel?(modelTypeOrId, pathOrStoreId?): Promise<{
        success: boolean;
        pathOrStoreId?: string;
        message?: string;
    }>;
    loadTrainedModel?(modelTypeOrId, pathOrStoreId?): Promise<{
        success: boolean;
        message?: string;
    }>;
}

Implemented by

Methods

  • Parses a string that is expected to be JSON: as it is, else from inside the Markdown code fence it is or holds, which a model asked for JSON alone often answers in. An LLM-backed class sends a text that still does not parse for repair when attemptFixWithLLM is set.

    Type Parameters

    • T = any

      The expected type of the parsed JSON object.

    Parameters

    • jsonString: string

      The string to parse.

    • Optional options: ParseJsonOptions<T>

      Options for parsing and fixing.

    Returns Promise<null | T>

    The parsed object, or null if parsing and fixing fail.

  • Returns Promise<{
        isHealthy: boolean;
        details?: any;
        dependencies?: {
            name: string;
            isHealthy: boolean;
            details?: any;
        }[];
    }>

  • Parameters

    • trainingData: any[]
    • modelType: string
    • Optional trainingOptions: Record<string, any>

    Returns Promise<{
        success: boolean;
        message?: string;
        modelId?: string;
    }>

  • Parameters

    • modelTypeOrId: string
    • Optional pathOrStoreId: string

    Returns Promise<{
        success: boolean;
        pathOrStoreId?: string;
        message?: string;
    }>

  • Parameters

    • modelTypeOrId: string
    • Optional pathOrStoreId: string

    Returns Promise<{
        success: boolean;
        message?: string;
    }>

Properties

utilityId: string