AsposeAIWebClient

AsposeAIWebClient class

A built-in IAIWebClient implementation that connects to Aspose’s own LLM. This is the default client used by the parameterless SlidesAIAgent() constructor.

AsposeAIWebClient

NameDescription
AsposeAIWebClient()Creates an instance of the Aspose AI web client that connects to the default Aspose LLM endpoint. This is the client used by the parameterless SlidesAIAgent() function, so creating it explicitly is only required when passing the client to the SlidesAIAgent(IAIWebClient) function directly. AsposeAIWebClient aiClient = new AsposeAIWebClient(); try { SlidesAIAgent aiAgent = new SlidesAIAgent(aiClient); Presentation presentation = new Presentation(“Presentation.pptx”); try { aiAgent.translate(presentation, “spanish”); presentation.save(“translated.pptx”, SaveFormat.Pptx); } finally { if (presentation != null) presentation.dispose(); } } finally { if (aiClient != null) aiClient.dispose(); }

Returns: AsposeAIWebClient


AsposeAIWebClient

NameDescription
AsposeAIWebClient(HttpURLConnection)Creates an instance of the Aspose AI web client that connects to the default Aspose LLM endpoint using an externally managed HttpURLConnection. The provided HttpURLConnection is not disposed by this instance and remains owned by the caller.

Parameters:

NameTypeDescription
httpClientHttpURLConnectionAn externally managed {@code HttpURLConnection} instance. URL url = new URL(url); HttpURLConnection httpClient = (HttpURLConnection) url.openConnection(); try { AsposeAIWebClient aiClient = new AsposeAIWebClient(httpClient); SlidesAIAgent aiAgent = new SlidesAIAgent(aiClient); Presentation presentation = new Presentation(“Presentation.pptx”); try { aiAgent.translate(presentation, “spanish”); presentation.save(“translated.pptx”, SaveFormat.Pptx); } finally { if (presentation != null) presentation.dispose(); } } finally { if (httpClient != null) httpClient.disconnect(); }

Returns: AsposeAIWebClient

Error

ErrorCondition
ArgumentNullExceptionHttpClient instance is not provided.

AsposeAIWebClient

NameDescription
AsposeAIWebClient(String)Creates an instance of the Aspose AI web client that connects to a custom endpoint URL. Use this overload when you have a URL provided by the Aspose.Slides team; otherwise, use the AsposeAIWebClient() overload with the default URL.

Parameters:

NameTypeDescription
urlStringEndpoint URL of the Aspose LLM, provided by the Aspose.Slides team. AsposeAIWebClient aiClient = new AsposeAIWebClient(customUrl); try { SlidesAIAgent aiAgent = new SlidesAIAgent(aiClient); Presentation presentation = new Presentation(“Presentation.pptx”); try { aiAgent.translate(presentation, “spanish”); presentation.save(“translated.pptx”, SaveFormat.Pptx); } finally { if (presentation != null) presentation.dispose(); } } finally { if (aiClient != null) aiClient.dispose(); }

Returns: AsposeAIWebClient

Error

ErrorCondition
ArgumentNullExceptionURL can’t be null or empty.

AsposeAIWebClient

NameDescription
AsposeAIWebClient(String, HttpURLConnection)Creates an instance of the Aspose AI web client that connects to a custom endpoint URL using an externally managed HttpURLConnection. The provided HttpURLConnection is not disposed by this instance and remains owned by the caller. Use this overload when you have a URL provided by the Aspose.Slides team and want to supply your own HttpURLConnection; if you only need your own HttpURLConnection with the default URL, use the AsposeAIWebClient(HttpURLConnection) overload instead.

Parameters:

NameTypeDescription
urlStringEndpoint URL of the Aspose LLM, provided by the Aspose.Slides team.
httpClientHttpURLConnectionAn externally managed {@code HttpURLConnection} instance. URL url = new URL(url); HttpURLConnection httpClient = (HttpURLConnection) url.openConnection(); try { AsposeAIWebClient aiClient = new AsposeAIWebClient(customUrl, httpClient); SlidesAIAgent aiAgent = new SlidesAIAgent(aiClient); Presentation presentation = new Presentation(“Presentation.pptx”); try { aiAgent.translate(presentation, “spanish”); presentation.save(“translated.pptx”, SaveFormat.Pptx); } finally { if (presentation != null) presentation.dispose(); } } finally { if (httpClient != null) httpClient.disconnect(); }

Returns: AsposeAIWebClient

Error

ErrorCondition
ArgumentNullExceptionHttpClient instance is not provided.

callChat

NameDescription
callChat (String)Sends a chat instruction to the AI model and returns response message to the given instruction.

Parameters:

NameTypeDescription
instructionStringThe instruction or message to be processed by the AI model.

Returns: String

Error

ErrorCondition
com.aspose.ms.System.ArgumentExceptionAI chat instruction can’t be null or empty

createConversation

NameDescription
createConversation ()Creates a conversation instance. Unlike regular AI calls, conversations retain the entire context.

Returns: OpenAIConversation


dispose

NameDescription
dispose ()Releases resources used by this instance.