Package com.acumenvelocity.ath.gemini
Class GenAi
- java.lang.Object
-
- com.acumenvelocity.ath.gemini.GenAi
-
public class GenAi extends Object
-
-
Constructor Summary
Constructors Constructor Description GenAi()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AlignmentData.CombinedAlignmentOutputalignParagraphsAndSentences(String modelName, AlignmentData.CombinedAlignmentInput input)Performs combined paragraph and sentence alignment using an LLM.static voiddone()Closes the Gemini Client connection.static com.google.genai.ClientgetClient()Returns the initialized Gemini Client.static voidinit()Initializes the Gemini Client using the API key from environment variables or Const.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.
-
-
-
Method Detail
-
init
public static void init() throws AthExceptionInitializes 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
-
-