-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vderyushev
committed
Nov 7, 2024
1 parent
0e4a2ab
commit 89c45e2
Showing
16 changed files
with
341 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved. | ||
// | ||
// This file is part of Aspose.Words. The source code in this file | ||
// is only intended as a supplement to the documentation, and is provided | ||
// "as is", without warranty of any kind, either expressed or implied. | ||
////////////////////////////////////////////////////////////////////////// | ||
|
||
using System.Text; | ||
using NUnit.Framework; | ||
using Aspose.Words; | ||
using System; | ||
using Aspose.Words.AI; | ||
|
||
namespace ApiExamples | ||
{ | ||
[TestFixture] | ||
public class ExAI : ApiExampleBase | ||
{ | ||
[Test, Explicit("This test should be run manually to manage API requests amount")] | ||
public void AiSummarize() | ||
{ | ||
//ExStart:AiSummarize | ||
//ReleaseVersion:24.11 | ||
//ExFor:GoogleAiModel | ||
//ExFor:OpenAiModel | ||
//ExFor:IAiModelText | ||
//ExFor:IAiModelText.Summarize(Document, SummarizeOptions) | ||
//ExFor:IAiModelText.Summarize(Document[], SummarizeOptions) | ||
//ExFor:SummarizeOptions | ||
//ExFor:SummarizeOptions.SummaryLength | ||
//ExFor:SummaryLength | ||
//ExFor:AiModel | ||
//ExFor:AiModel.Create(AiModelType) | ||
//ExFor:AiModel.WithApiKey(String) | ||
//ExFor:AiModelType | ||
//ExSummary:Shows how to summarize text using OpenAI and Google models. | ||
Document firstDoc = new Document(MyDir + "Big document.docx"); | ||
Document secondDoc = new Document(MyDir + "Document.docx"); | ||
|
||
string apiKey = Environment.GetEnvironmentVariable("API_KEY"); | ||
// Use OpenAI or Google generative language models. | ||
IAiModelText model = (IAiModelText)AiModel.Create(AiModelType.Gpt4OMini).WithApiKey(apiKey); | ||
|
||
Document oneDocumentSummary = model.Summarize(firstDoc, new SummarizeOptions() { SummaryLength = SummaryLength.Short }); | ||
oneDocumentSummary.Save(ArtifactsDir + "AI.AiSummarize.One.docx"); | ||
|
||
Document multiDocumentSummary = model.Summarize(new Document[] { firstDoc, secondDoc }, new SummarizeOptions() { SummaryLength = SummaryLength.Long }); | ||
multiDocumentSummary.Save(ArtifactsDir + "AI.AiSummarize.Multi.docx"); | ||
//ExEnd:AiSummarize | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.