Class AsposeLLMApi
AsposeLLMApi class
High-level facade over Engine: the recommended entry point for consumers of the Aspose.LLM NuGet package. Handles binary deployment, model loading, license checks, and session lifecycle from a single PresetCoreBase.
Models. No model is included in Aspose.LLM. The API runs a model that you choose, on your own machine; the model file is obtained separately and is governed by the model publisher’s license, not the Aspose license. Verifying and complying with that license is your responsibility.
Singleton. Only one instance may exist per process. Constructing a second AsposeLLMApi before disposing the first throws InvalidOperationException. This guards against double-loading the native llama.cpp runtime; the underlying libraries are not re-entrant on all platforms.
License. All chat-path methods enforce a runtime license check; unlicensed calls raise Exception with a “Not licensed” message.
public class AsposeLLMApi : IDisposable
Constructors
| Name | Description |
|---|---|
| AsposeLLMApi(PresetCoreBase, ILogger?) | Initializes a new instance of the AsposeLLMApi class using the supplied preset. |
Properties
| Name | Description |
|---|---|
| DefaultPreset { get; } | Gets the preset that provides default parameters for this API instance. |
Methods
| Name | Description |
|---|---|
| static Create(PresetCoreBase, ILogger?) | Creates a new AsposeLLMApi instance using the provided preset. Equivalent to new AsposeLLMApi(preset, logger); preserved for fluent / factory-style call sites. |
| CloseChatSession(string) | Closes a chat session and releases its native context resources. This is the per-session counterpart to disposing the whole API instance. |
| Dispose() | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
| ForceCacheCleanup(CacheCleanupStrategy) | Forces cleanup of the current chat session cache using the specified strategy. |
| GetDefaultParametersAsync() | Gets the default parameter sets returned by the engine. |
| GetDefaultPreset() | Returns a pre-configured Qwen25Preset instance suitable as a starting point when the caller has not prepared their own preset. The returned instance is freshly constructed (not shared with DefaultPreset) — callers may mutate it safely. |
| LoadChatSession(string) | Loads a chat session from a file |
| SaveChatSession(string, string?) | Saves a chat session to a file |
| SendMessageAsync(string, IEnumerable<byte[]>?, PresetCoreBase?, CancellationToken) | Sends a user message to the current chat session, creating one first if CurrentChatSessionId is empty. |
| SendMessageToSessionAsync(string, string, IEnumerable<byte[]>?, CancellationToken) | Sends a message to a specific chat session and gets a response |
| StartNewChatAsync(PresetCoreBase, string) | Starts a new chat session. When preset is null, falls back to the preset supplied at construction (accessible via DefaultPreset). |
| static LoadPresetFromJson(string) | Loads one preset from one inline JSON document. The JSON must contain extends, which selects the built-in preset that will be used as the base before applying overrides. |
| static SavePresetToJson(PresetCoreBase, bool) | Exports one built-in preset instance to one inline JSON document. The output uses the same contract as LoadPresetFromJson. By default it emits extends plus only the properties that differ from the selected built-in preset defaults. Set includeDefaults to true to export a full preset snapshot with all writable fields. |
See Also
- namespace Aspose.LLM
- assembly Aspose.LLM