Skip to content

Commit b9b1474

Browse files
committed
Fix ExAI
1 parent a46222b commit b9b1474

File tree

1 file changed

+9
-5
lines changed
  • Examples/ApiExamples/Java/src/main/java/Examples

1 file changed

+9
-5
lines changed

Examples/ApiExamples/Java/src/main/java/Examples/ExAI.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// "as is", without warranty of any kind, either expressed or implied.
88
//////////////////////////////////////////////////////////////////////////
99

10+
import com.aspose.words.*;
1011
import org.testng.annotations.Test;
11-
import com.aspose.words.Document;
1212

1313
@Test
1414
public class ExAI extends ApiExampleBase
@@ -36,12 +36,16 @@ public void aiSummarize() throws Exception
3636

3737
String apiKey = System.getenv("API_KEY");
3838
// 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);
4244
oneDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.One.docx");
4345

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);
4549
multiDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.Multi.docx");
4650
//ExEnd:AiSummarize
4751
}

0 commit comments

Comments
 (0)