Class HybridUtilityAI

Routes each utility method to the most appropriate backend:

  • LLM: summarization, classification, keyword extraction, JSON repair
  • Statistical: tokenization, stemming, n-grams, readability, similarity
  • Either with preference: sentiment, language detection

A summary, classification, keyword list, similarity or sentiment whose method names a method only one class has goes to that class when the hybrid holds it. The statistical class takes first_n_sentences and extractive_sentence_rank summaries, naive_bayes and keyword_matching classification, tf_idf and frequency_based keywords, cosine_tfidf, jaccard and levenshtein similarity and lexicon_based sentiment; the LLM-backed class takes abstractive_llm and key_points_llm summaries, llm_zeroshot classification, llm keywords, llm_semantic similarity and llm sentiment. If the preferred backend is not held, the other one takes the call.

Implements

Constructors

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;
        }[];
    }>

Properties

utilityId: string