Class GenAi


  • public class GenAi
    extends Object
    • Constructor Detail

      • GenAi

        public GenAi()
    • Method Detail

      • init

        public static void init()
                         throws AthException
        Initializes the Gemini Client using the API key from environment variables or Const.
        Throws:
        AthException
      • reinsertCodes

        public static List<List<InlineCodeRef>> reinsertCodes​(String modelName,
                                                              List<LayeredSegment> layeredSegments)
        Reinserts inline codes into target segments using an LLM to align them with source codes. *

        This method analyzes source and target text segments and uses a Gemini model to determine the correct positions for inline codes in the target text based on word/phrase alignment with the source text.

        *

        The method guarantees to return a list of the same size as the input layeredSegments, with empty lists for segments that have no codes or when processing fails.

        * @param modelName the Gemini model name to use (e.g., "gemini-2.5-flash") * @param layeredSegments the list of segments containing source and target text with code references
        Returns:
        a list of code reference lists, one per input segment. Never null, always the same size as layeredSegments. Individual lists are never null (empty lists for no codes).
      • alignParagraphsAndSentences

        public static AlignmentData.CombinedAlignmentOutput alignParagraphsAndSentences​(String modelName,
                                                                                        AlignmentData.CombinedAlignmentInput input)
                                                                                 throws Exception
        Performs combined paragraph and sentence alignment using an LLM. *

        This method sends a request to align both paragraphs and sentences in a single API call. The input contains source and target paragraphs with their segmented sentences. The LLM first aligns paragraphs (which may be split, merged, or reordered between documents), then aligns sentences within each aligned paragraph pair.

        * @param modelName the Gemini model name to use (e.g., "gemini-2.5-pro") * @param input the alignment input containing source and target paragraphs with segments
        Returns:
        the alignment output with paragraph and sentence alignments
        Throws:
        Exception - if the API call fails or returns invalid data
      • done

        public static void done()
        Closes the Gemini Client connection.
      • getClient

        public static com.google.genai.Client getClient()
        Returns the initialized Gemini Client. * @return the Gemini Client instance