GoogleAiModel class

GoogleAiModel class

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

Inheritance: GoogleAiModelAiModel

Properties

NameDescription
timeoutGets or sets the number of milliseconds to wait before the request to AI model times out. The default value is 100,000 milliseconds (100 seconds).
(Inherited from AiModel)
urlGets or sets a URL of the model. The default value is “https://generativelanguage.googleapis.com/v1beta/models/".

Methods

NameDescription
asAnthropicAiModel()
(Inherited from AiModel)
checkGrammar(sourceDocument, options)Checks grammar of the provided document. This operation leverages the connected AI model for checking grammar of document.
(Inherited from AiModel)
create(modelType)Creates a new instance of AiModel class.
(Inherited from AiModel)
createClaude35Haiku()Creates a new instance of Claude 3.5 Haiku generative model type.
(Inherited from AiModel)
createClaude35Sonnet()Creates a new instance of Claude 3.5 Sonnet generative model type.
(Inherited from AiModel)
createClaude3Haiku()Creates a new instance of Claude 3 Haiku generative model type.
(Inherited from AiModel)
createClaude3Opus()Creates a new instance of Claude 3 Opus generative model type.
(Inherited from AiModel)
createClaude3Sonnet()Creates a new instance of Claude 3 Sonnet generative model type.
(Inherited from AiModel)
createGemini15Flash()Creates a new instance of Gemini 1.5 Flash generative model type.
(Inherited from AiModel)
createGemini15Flash8B()Creates a new instance of Gemini 1.5 Flash-8B generative model type.
(Inherited from AiModel)
createGemini15Pro()Creates a new instance of Gemini 1.5 Pro generative model type.
(Inherited from AiModel)
createGpt35Turbo()Creates a new instance of GPT-3.5 Turbo generative model type.
(Inherited from AiModel)
createGpt4O()Creates a new instance of GPT-4o generative model type.
(Inherited from AiModel)
createGpt4OMini()Creates a new instance of GPT-4 mini generative model type.
(Inherited from AiModel)
createGpt4Turbo()Creates a new instance of GPT-4 Turbo generative model type.
(Inherited from AiModel)
setApiKey(apiKey)Sets a specified API key to the model.
(Inherited from AiModel)
summarize(doc, options)Summarizes specified Document object.
summarize(docs, options)Summarizes specified Document objects.
translate(doc, language)Translates a specified document.

Examples

Shows how to summarize text using OpenAI and Google models.

let firstDoc = new aw.Document(base.myDir + "Big document.docx");
let secondDoc = new aw.Document(base.myDir + "Document.docx");

const apiKey = process.env.API_KEY;
if (!apiKey) {
  console.warn("API_KEY environment variable is not set.");
  return;
}

// Use OpenAI or Google generative language models.
let model = aw.AI.AiModel.createGpt4OMini();
model.setApiKey(apiKey);
model.setOrganization("Organization");
model.setProject("Project");

let options = new aw.AI.SummarizeOptions();

options.summaryLength = aw.AI.SummaryLength.Short;
let oneDocumentSummary = model.summarize(firstDoc, options);
oneDocumentSummary.save(base.artifactsDir + "AI.AiSummarize.one.docx");

options.summaryLength = aw.AI.SummaryLength.Long;
let multiDocumentSummary = model.summarize([firstDoc, secondDoc], options);
multiDocumentSummary.save(base.artifactsDir + "AI.AiSummarize.multi.docx");

See Also