SummarizeOptions
Contents
[
Hide
]Inheritance: java.lang.Object
public class SummarizeOptions
Allows to specify various options for summarizing document content.
Examples:
Shows how to summarize text using OpenAI and Google models.
Document firstDoc = new Document(getMyDir() + "Big document.docx");
Document secondDoc = new Document(getMyDir() + "Document.docx");
String apiKey = System.getenv("API_KEY");
// Use OpenAI or Google generative language models.
IAiModelText model = (IAiModelText) AiModel.create(AiModelType.GPT_4_O_MINI).withApiKey(apiKey);
SummarizeOptions options = new SummarizeOptions();
options.setSummaryLength(SummaryLength.SHORT);
Document oneDocumentSummary = model.summarize(firstDoc, options);
oneDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.One.docx");
options = new SummarizeOptions();
options.setSummaryLength(SummaryLength.LONG);
Document multiDocumentSummary = model.summarize(new Document[] { firstDoc, secondDoc }, options);
multiDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.Multi.docx");
Constructors
Constructor | Description |
---|---|
SummarizeOptions() | Initializes a new instances of SummarizeOptions class. |
Methods
Method | Description |
---|---|
getSummaryLength() | Allows to specify summary length. |
setSummaryLength(int value) | Allows to specify summary length. |
SummarizeOptions()
public SummarizeOptions()
Initializes a new instances of SummarizeOptions class.
getSummaryLength()
public int getSummaryLength()
Allows to specify summary length. Default value is SummaryLength.MEDIUM.
Examples:
Shows how to summarize text using OpenAI and Google models.
Document firstDoc = new Document(getMyDir() + "Big document.docx");
Document secondDoc = new Document(getMyDir() + "Document.docx");
String apiKey = System.getenv("API_KEY");
// Use OpenAI or Google generative language models.
IAiModelText model = (IAiModelText) AiModel.create(AiModelType.GPT_4_O_MINI).withApiKey(apiKey);
SummarizeOptions options = new SummarizeOptions();
options.setSummaryLength(SummaryLength.SHORT);
Document oneDocumentSummary = model.summarize(firstDoc, options);
oneDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.One.docx");
options = new SummarizeOptions();
options.setSummaryLength(SummaryLength.LONG);
Document multiDocumentSummary = model.summarize(new Document[] { firstDoc, secondDoc }, options);
multiDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.Multi.docx");
Returns: int - The corresponding int value. The returned value is one of SummaryLength constants.
setSummaryLength(int value)
public void setSummaryLength(int value)
Allows to specify summary length. Default value is SummaryLength.MEDIUM.
Examples:
Shows how to summarize text using OpenAI and Google models.
Document firstDoc = new Document(getMyDir() + "Big document.docx");
Document secondDoc = new Document(getMyDir() + "Document.docx");
String apiKey = System.getenv("API_KEY");
// Use OpenAI or Google generative language models.
IAiModelText model = (IAiModelText) AiModel.create(AiModelType.GPT_4_O_MINI).withApiKey(apiKey);
SummarizeOptions options = new SummarizeOptions();
options.setSummaryLength(SummaryLength.SHORT);
Document oneDocumentSummary = model.summarize(firstDoc, options);
oneDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.One.docx");
options = new SummarizeOptions();
options.setSummaryLength(SummaryLength.LONG);
Document multiDocumentSummary = model.summarize(new Document[] { firstDoc, secondDoc }, options);
multiDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.Multi.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The corresponding int value. The value must be one of SummaryLength constants. |