Skip to content

Commit 2a2842f

Browse files
author
vderyushev
committed
Merge branch 'ReleasePreparation'
2 parents 98cf1e6 + f1c8766 commit 2a2842f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3537
-343
lines changed

Examples/ApiExamples/Java/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,15 @@
5454
<dependency>
5555
<groupId>com.aspose</groupId>
5656
<artifactId>aspose-words</artifactId>
57-
<version>24.10</version>
57+
<version>25.1</version>
5858
<classifier>jdk17</classifier>
5959
</dependency>
60+
<dependency>
61+
<groupId>com.aspose</groupId>
62+
<artifactId>aspose-words</artifactId>
63+
<version>25.1</version>
64+
<classifier>shaping-harfbuzz-plugin</classifier>
65+
</dependency>
6066
<dependency>
6167
<groupId>com.aspose</groupId>
6268
<artifactId>aspose-barcode</artifactId>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package Examples;
2+
3+
// Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
4+
//
5+
// This file is part of Aspose.Words. The source code in this file
6+
// is only intended as a supplement to the documentation, and is provided
7+
// "as is", without warranty of any kind, either expressed or implied.
8+
//////////////////////////////////////////////////////////////////////////
9+
10+
import com.aspose.words.*;
11+
import org.testng.annotations.Test;
12+
13+
@Test
14+
public class ExAI extends ApiExampleBase
15+
{
16+
@Test (enabled = false, description = "This test should be run manually to manage API requests amount")
17+
public void aiSummarize() throws Exception
18+
{
19+
//ExStart:AiSummarize
20+
//GistId:72d57eeddb7fb342fd51b26e5fcf9642
21+
//ExFor:GoogleAiModel
22+
//ExFor:OpenAiModel
23+
//ExFor:OpenAiModel.WithOrganization(String)
24+
//ExFor:OpenAiModel.WithProject(String)
25+
//ExFor:IAiModelText
26+
//ExFor:IAiModelText.Summarize(Document, SummarizeOptions)
27+
//ExFor:IAiModelText.Summarize(Document[], SummarizeOptions)
28+
//ExFor:SummarizeOptions
29+
//ExFor:SummarizeOptions.#ctor
30+
//ExFor:SummarizeOptions.SummaryLength
31+
//ExFor:SummaryLength
32+
//ExFor:AiModel
33+
//ExFor:AiModel.Create(AiModelType)
34+
//ExFor:AiModel.WithApiKey(String)
35+
//ExFor:AiModelType
36+
//ExSummary:Shows how to summarize text using OpenAI and Google models.
37+
Document firstDoc = new Document(getMyDir() + "Big document.docx");
38+
Document secondDoc = new Document(getMyDir() + "Document.docx");
39+
40+
String apiKey = System.getenv("API_KEY");
41+
// Use OpenAI or Google generative language models.
42+
IAiModelText model = ((OpenAiModel)AiModel.create(AiModelType.GPT_4_O_MINI).withApiKey(apiKey)).withOrganization("Organization").withProject("Project");
43+
44+
SummarizeOptions options = new SummarizeOptions();
45+
options.setSummaryLength(SummaryLength.SHORT);
46+
Document oneDocumentSummary = model.summarize(firstDoc, options);
47+
oneDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.One.docx");
48+
49+
options = new SummarizeOptions();
50+
options.setSummaryLength(SummaryLength.LONG);
51+
Document multiDocumentSummary = model.summarize(new Document[] { firstDoc, secondDoc }, options);
52+
multiDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.Multi.docx");
53+
//ExEnd:AiSummarize
54+
}
55+
56+
@Test (enabled = false, description = "This test should be run manually to manage API requests amount")
57+
public void aiTranslate() throws Exception
58+
{
59+
//ExStart:AiTranslate
60+
//GistId:93fefe5344a8337b931d0fed5c028225
61+
//ExFor:IAiModelText.Translate(Document, AI.Language)
62+
//ExFor:AI.Language
63+
//ExSummary:Shows how to translate text using Google models.
64+
Document doc = new Document(getMyDir() + "Document.docx");
65+
66+
String apiKey = System.getenv("API_KEY");
67+
// Use Google generative language models.
68+
IAiModelText model = (IAiModelText)AiModel.create(AiModelType.GEMINI_15_FLASH).withApiKey(apiKey);
69+
70+
Document translatedDoc = model.translate(doc, Language.ARABIC);
71+
translatedDoc.save(getArtifactsDir() + "AI.AiTranslate.docx");
72+
//ExEnd:AiTranslate
73+
}
74+
}
75+

0 commit comments

Comments
 (0)