Package com.acumenvelocity.ath.openai
Class OpenAi
- java.lang.Object
-
- com.acumenvelocity.ath.openai.OpenAi
-
public class OpenAi extends Object
-
-
Constructor Summary
Constructors Constructor Description OpenAi()
-
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()static com.openai.client.OpenAIClientgetClient()static voidinit()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
-
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 an OpenAI 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.
- Parameters:
modelName- the OpenAI model name to use (e.g., "gpt-5-mini")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.
- Parameters:
modelName- the OpenAI model name to use (e.g., "gpt-4o-mini")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
-
getClient
public static com.openai.client.OpenAIClient getClient()
-
-