Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.Words now leverages advanced AI models to enhance document processing and analysis. With the Aspose.Words.AI namespace, developers can access AI-powered features such as document summarization and analysis, document translation, and grammar checking by integrating generative language models from industry leaders.
Aspose.Words library currently supports integration with:
These models bring powerful capabilities for working with documents. By enabling seamless interaction with these AI tools, Aspose.Words simplifies complex tasks and enhances productivity for developers.
You can create a model instance using the Create method of the AiModel class.
The following code example shows how to create a new instance of AiModel class:
public static AiModel create(int modelType)With Aspose.Words, developers can also integrate self-hosted LLMs (Large Language Models), providing an alternative to OpenAI/Anthropic/Google’s hosted services.
The following code example shows how to create a self-hosted LLM based on OpenAI’s generative language model:
public void selfHostedModel() throws Exception
{
Document doc = new Document(getMyDir() + "Big document.docx");
String apiKey = System.getenv("API_KEY");
// Use OpenAI generative language models.
AiModel model = new CustomAiModel().withApiKey(apiKey);
Document translatedDoc = model.translate(doc, Language.RUSSIAN);
translatedDoc.save(getArtifactsDir() + "AI.SelfHostedModel.docx");
}
// Custom self-hosted AI model.
static class CustomAiModel extends OpenAiModel
{
protected String getUrl()
{
return "https://localhost/";
}
protected String getName()
{
return "my-model-24b";
}
}Q: Which AI model families are supported by Aspose.Words for Java?
A: Aspose.Words for Java supports models from OpenAI, Google (Gemini), and Anthropic’s Claude families. The supported models are listed in the AiModelType enumeration.
Q: How do I create an AiModel instance for a specific model type?
A: Use the static AiModel.create(int modelType) method, passing the integer value from the AiModelType enum that corresponds to the desired model (e.g., AiModelType.GPT_4O). The method returns an AiModel object ready for translation, summarization, etc.
Q: Can I use a self‑hosted LLM with Aspose.Words?
A: Yes. Derive a class from the appropriate base model (e.g., OpenAiModel) and override getUrl() and getName() to point to your self‑hosted endpoint. Instantiate your custom class and use it like any other AiModel.
Q: Do I need a separate license to use AI features in Aspose.Words?
A: No additional license is required. AI capabilities are included with a regular Aspose.Words for Java license. Ensure your license file is loaded correctly using License license = new License(); license.setLicense("Aspose.Words.Java.lic");.
Q: How can I find the integer value for a specific AiModelType enumeration member?
A: In Java, you can call AiModelType.GPT_4O.getValue() (or simply refer to the constant’s name) to obtain its underlying integer value, which you then pass to AiModel.create. This value is also documented in the API reference.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.