GoogleAiModel class

GoogleAiModel class

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

Inheritance: GoogleAiModelAiModel

Interfaces: IAiModelText

Methods

NameDescription
check_grammar(source_document, options)Checks grammar of the provided document. This operation leverages the connected AI model for checking grammar of document.
(Inherited from AiModel)
create(model_type)Creates a new instance of AiModel class.
(Inherited from AiModel)
summarize(doc, options)Summarizes specified Document object.
summarize(docs, options)Summarizes specified Document objects.
translate(doc, language)Translates a specified document.
with_api_key(api_key)Sets a specified API key to the model.
(Inherited from AiModel)

Examples

Shows how to summarize text using OpenAI and Google models.

first_doc = aw.Document(file_name=MY_DIR + 'Big document.docx')
second_doc = aw.Document(file_name=MY_DIR + 'Document.docx')
api_key = system_helper.environment.Environment.get_environment_variable('API_KEY')
# Use OpenAI or Google generative language models.
model = aw.ai.AiModel.create(aw.ai.AiModelType.GPT_4O_MINI).with_api_key(api_key).as_open_ai_model().with_organization('Organization').with_project('Project')
options = aw.ai.SummarizeOptions()
options.summary_length = aw.ai.SummaryLength.SHORT
one_document_summary = model.summarize(source_document=first_doc, options=options)
one_document_summary.save(file_name=ARTIFACTS_DIR + 'AI.AiSummarize.One.docx')
options.summary_length = aw.ai.SummaryLength.LONG
multi_document_summary = model.summarize(source_documents=[first_doc, second_doc], options=options)
multi_document_summary.save(file_name=ARTIFACTS_DIR + 'AI.AiSummarize.Multi.docx')

See Also