Aspose::Words::AI::GoogleAiModel class

GoogleAiModel class

An abstract class representing the integration with Google’s AI models within the Aspose.Words.

class GoogleAiModel : public Aspose::Words::AI::AiModel,
                      public Aspose::Words::AI::IAiModelText

Methods

MethodDescription
virtual CheckGrammar(System::SharedPtr<Aspose::Words::Document>, System::SharedPtr<Aspose::Words::AI::CheckGrammarOptions>)Checks grammar of the provided document. This operation leverages the connected AI model for checking grammar of document.
static Create(Aspose::Words::AI::AiModelType)Creates a new instance of AiModel class.
GetType() const override
GoogleAiModel()
Is(const System::TypeInfo&) const override
Summarize(System::SharedPtr<Aspose::Words::Document>, System::SharedPtr<Aspose::Words::AI::SummarizeOptions>) overrideSummarizes specified Document object.
Summarize(System::ArrayPtr<System::SharedPtr<Aspose::Words::Document>>, System::SharedPtr<Aspose::Words::AI::SummarizeOptions>) overrideSummarizes specified Document objects.
Translate(System::SharedPtr<Aspose::Words::Document>, Aspose::Words::AI::Language) overrideTranslates a specified document.
static Type()
WithApiKey(const System::String&)Sets a specified API key to the model.

Examples

Shows how to summarize text using OpenAI and Google models.

auto firstDoc = System::MakeObject<Aspose::Words::Document>(get_MyDir() + u"Big document.docx");
auto secondDoc = System::MakeObject<Aspose::Words::Document>(get_MyDir() + u"Document.docx");

System::String apiKey = System::Environment::GetEnvironmentVariable(u"API_KEY");
// Use OpenAI or Google generative language models.
System::SharedPtr<Aspose::Words::AI::AiModel> model = (System::ExplicitCast<Aspose::Words::AI::OpenAiModel>(Aspose::Words::AI::AiModel::Create(Aspose::Words::AI::AiModelType::Gpt4OMini)->WithApiKey(apiKey)))->WithOrganization(u"Organization")->WithProject(u"Project");

auto options = System::MakeObject<Aspose::Words::AI::SummarizeOptions>();

options->set_SummaryLength(Aspose::Words::AI::SummaryLength::Short);
System::SharedPtr<Aspose::Words::Document> oneDocumentSummary = model->Summarize(firstDoc, options);
oneDocumentSummary->Save(get_ArtifactsDir() + u"AI.AiSummarize.One.docx");

options->set_SummaryLength(Aspose::Words::AI::SummaryLength::Long);
System::SharedPtr<Aspose::Words::Document> multiDocumentSummary = model->Summarize(System::MakeArray<System::SharedPtr<Aspose::Words::Document>>({firstDoc, secondDoc}), options);
multiDocumentSummary->Save(get_ArtifactsDir() + u"AI.AiSummarize.Multi.docx");

See Also