|
7 | 7 | // "as is", without warranty of any kind, either expressed or implied.
|
8 | 8 | //////////////////////////////////////////////////////////////////////////
|
9 | 9 |
|
| 10 | +import com.aspose.words.*; |
10 | 11 | import org.testng.annotations.Test;
|
11 |
| -import com.aspose.words.Document; |
12 | 12 |
|
13 | 13 | @Test
|
14 | 14 | public class ExAI extends ApiExampleBase
|
@@ -36,12 +36,16 @@ public void aiSummarize() throws Exception
|
36 | 36 |
|
37 | 37 | String apiKey = System.getenv("API_KEY");
|
38 | 38 | // Use OpenAI or Google generative language models.
|
39 |
| - IAiModelText model = (IAiModelText)AiModel.create(AiModelType.GPT_4_O_MINI).withApiKey(apiKey); |
40 |
| - |
41 |
| - Document oneDocumentSummary = model.summarize(firstDoc, new SummarizeOptions(); { oneDocumentSummary.setSummaryLength(SummaryLength.SHORT); }); |
| 39 | + IAiModelText model = (IAiModelText) AiModel.create(AiModelType.GPT_4_O_MINI).withApiKey(apiKey); |
| 40 | + |
| 41 | + SummarizeOptions options = new SummarizeOptions(); |
| 42 | + options.setSummaryLength(SummaryLength.SHORT); |
| 43 | + Document oneDocumentSummary = model.summarize(firstDoc, options); |
42 | 44 | oneDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.One.docx");
|
43 | 45 |
|
44 |
| - Document multiDocumentSummary = model.summarize(new Document[] { firstDoc, secondDoc }, new SummarizeOptions(); { multiDocumentSummary.setSummaryLength(SummaryLength.LONG); }); |
| 46 | + options = new SummarizeOptions(); |
| 47 | + options.setSummaryLength(SummaryLength.LONG); |
| 48 | + Document multiDocumentSummary = model.summarize(new Document[] { firstDoc, secondDoc }, options); |
45 | 49 | multiDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.Multi.docx");
|
46 | 50 | //ExEnd:AiSummarize
|
47 | 51 | }
|
|
0 commit comments