From 7cfdccf973522fc79962ad857f3ced5ff057ecbf Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 12 Nov 2025 13:40:57 +0300 Subject: [PATCH 01/16] Revise AI integration docs for ABP Framework Updated the artificial intelligence documentation to clarify ABP Framework's AI integration approach, focusing on abstractions and workspaces using Microsoft's AI stacks. Simplified installation and usage instructions, provided clearer examples for Microsoft.Extensions.AI and Semantic Kernel, and improved explanations of workspaces and configuration. Removed redundant and verbose sections for better readability and maintainability. --- .../infrastructure/artificial-intelligence.md | 283 ++++-------------- 1 file changed, 55 insertions(+), 228 deletions(-) diff --git a/docs/en/framework/infrastructure/artificial-intelligence.md b/docs/en/framework/infrastructure/artificial-intelligence.md index 652c7c8233..9cb5f3632a 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence.md +++ b/docs/en/framework/infrastructure/artificial-intelligence.md @@ -1,11 +1,9 @@ # Artificial Intelligence +ABP Framework provides integration for AI capabilities to your application by using Microsoft's AI stacks by using abstractions and workspaces. The main purpose of this integration is to provide a consistent way to use AI capabilities and managing different AI providers, models and configurations by using workspaces. -ABP provides a simple way to integrate AI capabilities into your applications by unifying two popular .NET AI stacks under a common concept called a "workspace": +ABP Framework doesn't implement any AI providers or models, it only provides the abstractions by using Microsoft's packages such as [Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai) and [Microsoft.SemanticKernel](https://learn.microsoft.com/en-us/semantic-kernel/overview/). -- Microsoft.Extensions.AI `IChatClient` -- Microsoft.SemanticKernel `Kernel` - -A workspace is just a named scope. You configure providers per workspace and then resolve either default services (for the "Default" workspace) or workspace-scoped services. +ABP allows you to define a default configuration for across the application and also allows you to define isolated configurations for different different purposes by using workspaces. A workspace allows you to configure isolated AI configurations for a named scope. You can resolve AI services for a specific workspace when you need to use them. ## Installation @@ -17,152 +15,59 @@ It is suggested to use the ABP CLI to install the package. Open a command line w abp add-package Volo.Abp.AI ``` -### Manual Installation - -Add nuget package to your project: - -```bash -dotnet add package Volo.Abp.AI -``` - -Then add the module dependency to your module class: - -```csharp -using Volo.Abp.AI; -using Volo.Abp.Modularity; - -[DependsOn(typeof(AbpAIModule))] -public class MyProjectModule : AbpModule -{ -} -``` - ## Usage -### Chat Client +Since ABP supports both `Microsoft.Extensions.AI` and `Microsoft.SemanticKernel`, you can use both of them in your application by resolving `IChatClient` or `IKernelAccessor` services from the [service provider](../fundamentals/dependency-injection.md). -#### Default configuration (quick start) +### Microsoft.Extensions.AI -Configure the default workspace to inject `IChatClient` directly. +You can resolve both `IChatClient` to access configured chat client from your service and use it directly. ```csharp -using Microsoft.Extensions.AI; -using Microsoft.SemanticKernel; -using Volo.Abp.AI; -using Volo.Abp.Modularity; - -public class MyProjectModule : AbpModule -{ - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.PreConfigure(options => - { - options.Workspaces.ConfigureDefault(configuration => - { - configuration.ConfigureChatClient(chatClientConfiguration => - { - chatClientConfiguration.Builder = new ChatClientBuilder( - sp => new OllamaApiClient("http://localhost:11434", "mistral") - ); - }); - - // Chat client only in this quick start - }); - }); - } -} -``` - -Once configured, inject the default chat client: - -```csharp -using Microsoft.Extensions.AI; - public class MyService { - private readonly IChatClient _chatClient; // default chat client - + private readonly IChatClient _chatClient; public MyService(IChatClient chatClient) { _chatClient = chatClient; } -} -``` -#### Workspace configuration - -Workspaces allow multiple, isolated AI configurations. Define workspace types (optionally decorated with `WorkspaceNameAttribute`). If omitted, the type’s full name is used. - -```csharp -using Volo.Abp.AI; - -[WorkspaceName("GreetingAssistant")] -public class GreetingAssistant // ChatClient-only workspace -{ -} -``` - -Configure a ChatClient workspace: - -```csharp -public class MyProjectModule : AbpModule -{ - public override void ConfigureServices(ServiceConfigurationContext context) + public async Task GetResponseAsync(string prompt) { - context.Services.PreConfigure(options => - { - options.Workspaces.Configure(configuration => - { - configuration.ConfigureChatClient(chatClientConfiguration => - { - chatClientConfiguration.Builder = new ChatClientBuilder( - sp => new OllamaApiClient("http://localhost:11434", "mistral") - ); - - chatClientConfiguration.BuilderConfigurers.Add(builder => - { - // Anything you want to do with the builder: - // builder.UseFunctionInvocation().UseLogging(); // For example - }); - }); - }); - }); + return await _chatClient.GetResponseAsync(prompt); } } ``` -### Semantic Kernel - -#### Default configuration +You can also resolve `IChatClientAccessor` to access the `IChatClient` optionally configured scenarios such as developing a module or a service that may use AI capabilities **optionally**. ```csharp -public class MyProjectModule : AbpModule +public class MyService { - public override void ConfigureServices(ServiceConfigurationContext context) + private readonly IChatClientAccessor _chatClientAccessor; + public MyService(IChatClientAccessor chatClientAccessor) + { + _chatClientAccessor = chatClientAccessor; + } + + public async Task GetResponseAsync(string prompt) { - context.Services.PreConfigure(options => + var chatClient = _chatClientAccessor.ChatClient; + if (chatClient is null) { - options.Workspaces.ConfigureDefault(configuration => - { - configuration.ConfigureKernel(kernelConfiguration => - { - kernelConfiguration.Builder = Kernel.CreateBuilder() - .AddAzureOpenAIChatClient("...", "..."); - }); - // Note: Chat client is not configured here - }); - }); + return "No chat client configured"; + } + return await chatClient.GetResponseAsync(prompt); } } ``` -Once configured, inject the default kernel: +### Microsoft.SemanticKernel -```csharp -using System.Threading.Tasks; -using Volo.Abp.AI; +Semantic Kernel can be used by resolving `IKernelAccessor` service that carries the `Kernel` instance. Kernel might be null if no workspace is configured. You should check the kernel before using it. +```csharp public class MyService { private readonly IKernelAccessor _kernelAccessor; @@ -171,137 +76,59 @@ public class MyService _kernelAccessor = kernelAccessor; } - public async Task DoSomethingAsync() - { - var kernel = _kernelAccessor.Kernel; // Kernel might be null if no workspace is configured. - - var result = await kernel.InvokeAsync(/*... */); - } -} -``` - -#### Workspace configuration - -```csharp -public class MyProjectModule : AbpModule -{ - public override void ConfigureServices(ServiceConfigurationContext context) + public async Task GetResponseAsync(string prompt) { - context.Services.PreConfigure(options => + var kernel = _kernelAccessor.Kernel; + if (kernel is null) { - options.Workspaces.Configure(configuration => - { - configuration.ConfigureKernel(kernelConfiguration => - { - kernelConfiguration.Builder = Kernel.CreateBuilder() - .AddOpenAIChatCompletion("...", "..."); - }); - }); - }); + return "No kernel configured"; + } + return await kernel.InvokeAsync(prompt); } } ``` -#### Workspace usage +### Workspaces + +Workspaces are a way to configure isolated AI configurations for a named scope. You can define a workspace by decorating a class with the `WorkspaceNameAttribute` attribute that carries the workspace name. +- Workspace names must be unique. +- Workspace names cannot contain spaces _(use underscores or camelCase)_. +- Workspace names are case-sensitive. ```csharp -using Microsoft.Extensions.AI; using Volo.Abp.AI; -using Microsoft.SemanticKernel; -public class PlanningService +[WorkspaceName("CommentSummarization")] +public class CommentSummarization { - private readonly IKernelAccessor _kernelAccessor; - private readonly IChatClient _chatClient; // available even if only Kernel is configured - - public PlanningService( - IKernelAccessor kernelAccessor, - IChatClient chatClient) - { - _kernelAccessor = kernelAccessor; - _chatClient = chatClient; - } - - public async Task PlanAsync(string topic) - { - var kernel = _kernelAccessor.Kernel; // Microsoft.SemanticKernel.Kernel - // Use Semantic Kernel APIs if needed... - - var response = await _chatClient.GetResponseAsync( - [new ChatMessage(ChatRole.User, $"Create a content plan for: {topic}")] - ); - return response?.Message?.Text ?? string.Empty; - } } ``` -## Options +> [!NOTE] +> If you don't specify the workspace name, the full name of the class will be used as the workspace name. -`AbpAIOptions` configuration pattern offers `ConfigureChatClient(...)` and `ConfigureKernel(...)` methods for configuration. These methods are defined in the `WorkspaceConfiguration` class. They are used to configure the `ChatClient` and `Kernel` respectively. - -`Builder` is set once and is used to build the `ChatClient` or `Kernel` instance. `BuilderConfigurers` is a list of actions that are applied to the `Builder` instance for incremental changes. These actions are executed in the order they are added. - -If a workspace configures only the Kernel, a chat client may still be exposed for that workspace through the Kernel’s service provider (when available). - - -## Advanced Usage and Customizations - -### Addding Your Own DelegatingChatClient - -If you want to build your own decorator, implement a `DelegatingChatClient` derivative and provide an extension method that adds it to the `ChatClientBuilder` using `builder.Use(...)`. - -Example sketch: +You can resolve generic versions of `IChatClient`, `IChatClientAccessor` or `IKernelAccessor` services for a specific workspace as generic arguments. If Chat Client or Kernel is not configured for a workspace, you will get `null` from the accessor services. You should check the accessor before using it. This applies only for specified workspaces. Another workspace may have a configured Chat Client or Kernel. ```csharp -using Microsoft.Extensions.AI; - -public class SystemMessageChatClient : DelegatingChatClient +public class MyService { - public SystemMessageChatClient(IChatClient inner, string systemMessage) : base(inner) + private readonly IChatClientAccessor _chatClientAccessor; + public MyService(IChatClientAccessor chatClientAccessor) { - SystemMessage = systemMessage; + _chatClientAccessor = chatClientAccessor; } - public string SystemMessage { get; set; } - - public override Task GetResponseAsync(IEnumerable messages, ChatOptions? options = null, CancellationToken cancellationToken = default) + public async Task GetResponseAsync(string prompt) { - // Mutate messages/options as needed, then call base - return base.GetResponseAsync(messages, options, cancellationToken); - } -} - -public static class SystemMessageChatClientExtensions -{ - public static ChatClientBuilder UseSystemMessage(this ChatClientBuilder builder, string systemMessage) - { - return builder.Use(client => new SystemMessageChatClient(client, systemMessage)); + var chatClient = _chatClientAccessor.ChatClient; + if (chatClient is null) + { + return "No chat client configured for 'CommentSummarization' workspace"; + } + return await chatClient.GetResponseAsync(prompt); } } ``` +## Configuration -```cs -chatClientConfiguration.BuilderConfigurers.Add(builder => -{ - builder.UseSystemMessage("You are a helpful assistant that greets users in a friendly manner with their names."); -}); -``` - -## Technical Anatomy - -- `AbpAIModule`: Wires up configured workspaces, registers keyed services and default services for the `"Default"` workspace. -- `AbpAIOptions`: Holds `Workspaces` and provides helper methods for internal keyed service naming. -- `WorkspaceConfigurationDictionary` and `WorkspaceConfiguration`: Configure per-workspace Chat Client and Kernel. -- `ChatClientConfiguration` and `KernelConfiguration`: Hold builders and a list of ordered builder configurers. -- `WorkspaceNameAttribute`: Names a workspace; falls back to the type’s full name if not specified. -- `IChatClient`: Typed chat client for a workspace. -- `IKernelAccessor`: Provides access to the workspace’s `Kernel` instance if configured. -- `AbpAIWorkspaceOptions`: Exposes `ConfiguredWorkspaceNames` for diagnostics. - -There are no database tables for this feature; it is a pure configuration and DI integration layer. - -## See Also - -- Microsoft.Extensions.AI (Chat Client) -- Microsoft Semantic Kernel \ No newline at end of file From f6dd79df6aca144efe9ecd4d55289873630566df Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 12 Nov 2025 16:01:36 +0300 Subject: [PATCH 02/16] Update artificial-intelligence.md --- .../infrastructure/artificial-intelligence.md | 119 +++++++++++++++++- 1 file changed, 117 insertions(+), 2 deletions(-) diff --git a/docs/en/framework/infrastructure/artificial-intelligence.md b/docs/en/framework/infrastructure/artificial-intelligence.md index 9cb5f3632a..f88b24648a 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence.md +++ b/docs/en/framework/infrastructure/artificial-intelligence.md @@ -17,11 +17,13 @@ abp add-package Volo.Abp.AI ## Usage -Since ABP supports both `Microsoft.Extensions.AI` and `Microsoft.SemanticKernel`, you can use both of them in your application by resolving `IChatClient` or `IKernelAccessor` services from the [service provider](../fundamentals/dependency-injection.md). +Since ABP supports both `Microsoft.Extensions.AI` and `Microsoft.SemanticKernel`. Microsoft provides `IChatClient` interface abstraction for different chat client integrations. ABP respects it and uses it by default. Also `Kernel` object is used by `Microsoft.SemanticKernel` to execute AI capabilities. ABP respects it and uses it by default. + +You can use both of them in your application by resolving `IChatClient` or `IKernelAccessor` services from the [service provider](../fundamentals/dependency-injection.md). `IChatClient` is the original interface from `Microsoft.Extensions.AI` but `IKernelAccessor` is a custom service that is used to access the `Kernel` object from `Microsoft.SemanticKernel`. ### Microsoft.Extensions.AI -You can resolve both `IChatClient` to access configured chat client from your service and use it directly. +You can resolve `IChatClient` to access configured chat client from your service and use it directly. ```csharp public class MyService @@ -132,3 +134,116 @@ public class MyService ## Configuration +`AbpAIWorkspaceOptions` configuration is used to configure AI workspaces and their configurations. You can configure the default workspace and also configure isolated workspaces by using the this options class.It has to be configured **before the services are configured** in the `PreConfigure` method of your module class. It is important since the services are registered after the configuration is applied. + +- `AbpAIWorkspaceOptions` has a `Workspaces` property that is type of `WorkspaceConfigurationDictionary` which is a dictionary of workspace names and their configurations. It provides `Configure` and `ConfigureDefault` methods to configure the default workspace and also configure isolated workspaces by using the workspace type. + +- Configure method passes `WorkspaceConfiguration` object to the configure action. You can configure the `ChatClient` and `Kernel` by using the `ConfigureChatClient` and `ConfigureKernel` methods. + +- Both **ChatClient** and **Kernel** have a `Builder` property and `BuilderConfigurers` property. + - `Builder` is set once and is used to build the `ChatClient` or `Kernel` instance. + - `BuilderConfigurers` is a list of actions that are applied to the `Builder` instance for incremental changes.These actions are executed in the order they are added. + + +### Microsoft.Extensions.AI +To configure a chat client, you'll need a LLM provider package such as [Microsoft.Extensions.AI.OpenAI](https://www.nuget.org/packages/Microsoft.Extensions.AI.OpenAI) or [OllamaSharp](https://www.nuget.org/packages/OllamaSharp/) to configure a chat client. + +_The following example is requires [OllamaSharp](https://www.nuget.org/packages/OllamaSharp/) package to be installed._ + + +Demonstration of the default workspace configuration: +```csharp +[DependsOn(typeof(AbpAIModule))] +public class MyProjectModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(options => + { + options.Workspaces.ConfigureDefault(configuration => + { + configuration.ConfigureChatClient(chatClientConfiguration => + { + chatClientConfiguration.Builder = new ChatClientBuilder( + sp => new OllamaApiClient("http://localhost:11434", "mistral") + ); + }); + }); + }); + } +} +``` + + +Demonstration of the isolated workspace configuration: +```csharp +[DependsOn(typeof(AbpAIModule))] +public class MyProjectModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(options => + { + options.Workspaces.Configure(configuration => + { + configuration.ConfigureChatClient(chatClientConfiguration => + { + chatClientConfiguration.Builder = new ChatClientBuilder( + sp => new OllamaApiClient("http://localhost:11434", "mistral") + ); + }); + }); + }); + } +} +``` + +### Semantic Kernel +To configure a kernel, you'll need a kernel connector package such as [Microsoft.SemanticKernel.Connectors.OpenAI](Microsoft.SemanticKernel.Connectors.OpenAI) to configure a kernel to use a specific LLM provider. + +_The following example is requires [Microsoft.SemanticKernel.Connectors.AzureOpenAI](Microsoft.SemanticKernel.Connectors.AzureOpenAI) package to be installed._ + +Demonstration of the default workspace configuration: +```csharp +[DependsOn(typeof(AbpAIModule))] +public class MyProjectModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(options => + { + options.Workspaces.ConfigureDefault(configuration => + { + configuration.ConfigureKernel(kernelConfiguration => + { + kernelConfiguration.Builder = Kernel.CreateBuilder() + .AddAzureOpenAIChatClient("...", "..."); + }); + // Note: Chat client is not configured here + }); + }); + } +} +``` + +Demonstration of the isolated workspace configuration: +```csharp +[DependsOn(typeof(AbpAIModule))] +public class MyProjectModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(options => + { + options.Workspaces.Configure(configuration => + { + configuration.ConfigureKernel(kernelConfiguration => + { + kernelConfiguration.Builder = Kernel.CreateBuilder() + .AddAzureOpenAIChatClient("...", "..."); + }); + }); + }); + } +} +``` \ No newline at end of file From 929091e1f34597e4be6a30a1aaa937df1b6e9b6b Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 12 Nov 2025 16:03:06 +0300 Subject: [PATCH 03/16] Update artificial-intelligence.md --- docs/en/framework/infrastructure/artificial-intelligence.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/en/framework/infrastructure/artificial-intelligence.md b/docs/en/framework/infrastructure/artificial-intelligence.md index f88b24648a..de51a1f9d5 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence.md +++ b/docs/en/framework/infrastructure/artificial-intelligence.md @@ -115,6 +115,7 @@ You can resolve generic versions of `IChatClient`, `IChatClientAccessor` or `IKe public class MyService { private readonly IChatClientAccessor _chatClientAccessor; + public MyService(IChatClientAccessor chatClientAccessor) { _chatClientAccessor = chatClientAccessor; @@ -148,7 +149,7 @@ public class MyService ### Microsoft.Extensions.AI To configure a chat client, you'll need a LLM provider package such as [Microsoft.Extensions.AI.OpenAI](https://www.nuget.org/packages/Microsoft.Extensions.AI.OpenAI) or [OllamaSharp](https://www.nuget.org/packages/OllamaSharp/) to configure a chat client. -_The following example is requires [OllamaSharp](https://www.nuget.org/packages/OllamaSharp/) package to be installed._ +_The following example requires [OllamaSharp](https://www.nuget.org/packages/OllamaSharp/) package to be installed._ Demonstration of the default workspace configuration: @@ -201,7 +202,7 @@ public class MyProjectModule : AbpModule ### Semantic Kernel To configure a kernel, you'll need a kernel connector package such as [Microsoft.SemanticKernel.Connectors.OpenAI](Microsoft.SemanticKernel.Connectors.OpenAI) to configure a kernel to use a specific LLM provider. -_The following example is requires [Microsoft.SemanticKernel.Connectors.AzureOpenAI](Microsoft.SemanticKernel.Connectors.AzureOpenAI) package to be installed._ +_The following example requires [Microsoft.SemanticKernel.Connectors.AzureOpenAI](Microsoft.SemanticKernel.Connectors.AzureOpenAI) package to be installed._ Demonstration of the default workspace configuration: ```csharp From 3dd3d2caf6462ea096cd2f736649f9e300e2546c Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 12 Nov 2025 16:08:36 +0300 Subject: [PATCH 04/16] Update artificial-intelligence.md --- docs/en/framework/infrastructure/artificial-intelligence.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/framework/infrastructure/artificial-intelligence.md b/docs/en/framework/infrastructure/artificial-intelligence.md index de51a1f9d5..7c1cd25e91 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence.md +++ b/docs/en/framework/infrastructure/artificial-intelligence.md @@ -17,7 +17,7 @@ abp add-package Volo.Abp.AI ## Usage -Since ABP supports both `Microsoft.Extensions.AI` and `Microsoft.SemanticKernel`. Microsoft provides `IChatClient` interface abstraction for different chat client integrations. ABP respects it and uses it by default. Also `Kernel` object is used by `Microsoft.SemanticKernel` to execute AI capabilities. ABP respects it and uses it by default. +Both `Microsoft.Extensions.AI` and `Microsoft.SemanticKernel` are supported. Microsoft provides `IChatClient` interface to cover multiple chat client integrations. ABP respects it and uses it by default. You'll be use this interface to access the chat client from your services. In the other hand, `Microsoft.SemanticKernel` provides `Kernel` object to configure and execute AI capabilities ABP respects it and uses it by default but the Kernel is not directly accessible from your services. You'll be use `IKernelAccessor` service to access the `Kernel` object from your services. You can use both of them in your application by resolving `IChatClient` or `IKernelAccessor` services from the [service provider](../fundamentals/dependency-injection.md). `IChatClient` is the original interface from `Microsoft.Extensions.AI` but `IKernelAccessor` is a custom service that is used to access the `Kernel` object from `Microsoft.SemanticKernel`. From 7e01f04d35e2128b7c8e214c7be81aeb3b1b3aae Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 12 Nov 2025 16:28:15 +0300 Subject: [PATCH 05/16] Separate ai docs into ME.AI and Semantic.Kernel --- .../infrastructure/artificial-intelligence.md | 250 ------------------ .../artificial-intelligence/index.md | 28 ++ .../microsoft-extensions-ai.md | 170 ++++++++++++ .../microsoft-semantic-kernel.md | 130 +++++++++ 4 files changed, 328 insertions(+), 250 deletions(-) delete mode 100644 docs/en/framework/infrastructure/artificial-intelligence.md create mode 100644 docs/en/framework/infrastructure/artificial-intelligence/index.md create mode 100644 docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md create mode 100644 docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md diff --git a/docs/en/framework/infrastructure/artificial-intelligence.md b/docs/en/framework/infrastructure/artificial-intelligence.md deleted file mode 100644 index 7c1cd25e91..0000000000 --- a/docs/en/framework/infrastructure/artificial-intelligence.md +++ /dev/null @@ -1,250 +0,0 @@ -# Artificial Intelligence -ABP Framework provides integration for AI capabilities to your application by using Microsoft's AI stacks by using abstractions and workspaces. The main purpose of this integration is to provide a consistent way to use AI capabilities and managing different AI providers, models and configurations by using workspaces. - -ABP Framework doesn't implement any AI providers or models, it only provides the abstractions by using Microsoft's packages such as [Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai) and [Microsoft.SemanticKernel](https://learn.microsoft.com/en-us/semantic-kernel/overview/). - -ABP allows you to define a default configuration for across the application and also allows you to define isolated configurations for different different purposes by using workspaces. A workspace allows you to configure isolated AI configurations for a named scope. You can resolve AI services for a specific workspace when you need to use them. - -## Installation - -> This package is not included by default. Install it to enable AI features. - -It is suggested to use the ABP CLI to install the package. Open a command line window in the folder of the project (.csproj file) and type the following command: - -```bash -abp add-package Volo.Abp.AI -``` - -## Usage - -Both `Microsoft.Extensions.AI` and `Microsoft.SemanticKernel` are supported. Microsoft provides `IChatClient` interface to cover multiple chat client integrations. ABP respects it and uses it by default. You'll be use this interface to access the chat client from your services. In the other hand, `Microsoft.SemanticKernel` provides `Kernel` object to configure and execute AI capabilities ABP respects it and uses it by default but the Kernel is not directly accessible from your services. You'll be use `IKernelAccessor` service to access the `Kernel` object from your services. - -You can use both of them in your application by resolving `IChatClient` or `IKernelAccessor` services from the [service provider](../fundamentals/dependency-injection.md). `IChatClient` is the original interface from `Microsoft.Extensions.AI` but `IKernelAccessor` is a custom service that is used to access the `Kernel` object from `Microsoft.SemanticKernel`. - -### Microsoft.Extensions.AI - -You can resolve `IChatClient` to access configured chat client from your service and use it directly. - -```csharp -public class MyService -{ - private readonly IChatClient _chatClient; - public MyService(IChatClient chatClient) - { - _chatClient = chatClient; - } - - public async Task GetResponseAsync(string prompt) - { - return await _chatClient.GetResponseAsync(prompt); - } -} -``` - -You can also resolve `IChatClientAccessor` to access the `IChatClient` optionally configured scenarios such as developing a module or a service that may use AI capabilities **optionally**. - - -```csharp -public class MyService -{ - private readonly IChatClientAccessor _chatClientAccessor; - public MyService(IChatClientAccessor chatClientAccessor) - { - _chatClientAccessor = chatClientAccessor; - } - - public async Task GetResponseAsync(string prompt) - { - var chatClient = _chatClientAccessor.ChatClient; - if (chatClient is null) - { - return "No chat client configured"; - } - return await chatClient.GetResponseAsync(prompt); - } -} -``` - -### Microsoft.SemanticKernel - -Semantic Kernel can be used by resolving `IKernelAccessor` service that carries the `Kernel` instance. Kernel might be null if no workspace is configured. You should check the kernel before using it. - -```csharp -public class MyService -{ - private readonly IKernelAccessor _kernelAccessor; - public MyService(IKernelAccessor kernelAccessor) - { - _kernelAccessor = kernelAccessor; - } - - public async Task GetResponseAsync(string prompt) - { - var kernel = _kernelAccessor.Kernel; - if (kernel is null) - { - return "No kernel configured"; - } - return await kernel.InvokeAsync(prompt); - } -} -``` - -### Workspaces - -Workspaces are a way to configure isolated AI configurations for a named scope. You can define a workspace by decorating a class with the `WorkspaceNameAttribute` attribute that carries the workspace name. -- Workspace names must be unique. -- Workspace names cannot contain spaces _(use underscores or camelCase)_. -- Workspace names are case-sensitive. - -```csharp -using Volo.Abp.AI; - -[WorkspaceName("CommentSummarization")] -public class CommentSummarization -{ -} -``` - -> [!NOTE] -> If you don't specify the workspace name, the full name of the class will be used as the workspace name. - -You can resolve generic versions of `IChatClient`, `IChatClientAccessor` or `IKernelAccessor` services for a specific workspace as generic arguments. If Chat Client or Kernel is not configured for a workspace, you will get `null` from the accessor services. You should check the accessor before using it. This applies only for specified workspaces. Another workspace may have a configured Chat Client or Kernel. - -```csharp -public class MyService -{ - private readonly IChatClientAccessor _chatClientAccessor; - - public MyService(IChatClientAccessor chatClientAccessor) - { - _chatClientAccessor = chatClientAccessor; - } - - public async Task GetResponseAsync(string prompt) - { - var chatClient = _chatClientAccessor.ChatClient; - if (chatClient is null) - { - return "No chat client configured for 'CommentSummarization' workspace"; - } - return await chatClient.GetResponseAsync(prompt); - } -} -``` - -## Configuration - -`AbpAIWorkspaceOptions` configuration is used to configure AI workspaces and their configurations. You can configure the default workspace and also configure isolated workspaces by using the this options class.It has to be configured **before the services are configured** in the `PreConfigure` method of your module class. It is important since the services are registered after the configuration is applied. - -- `AbpAIWorkspaceOptions` has a `Workspaces` property that is type of `WorkspaceConfigurationDictionary` which is a dictionary of workspace names and their configurations. It provides `Configure` and `ConfigureDefault` methods to configure the default workspace and also configure isolated workspaces by using the workspace type. - -- Configure method passes `WorkspaceConfiguration` object to the configure action. You can configure the `ChatClient` and `Kernel` by using the `ConfigureChatClient` and `ConfigureKernel` methods. - -- Both **ChatClient** and **Kernel** have a `Builder` property and `BuilderConfigurers` property. - - `Builder` is set once and is used to build the `ChatClient` or `Kernel` instance. - - `BuilderConfigurers` is a list of actions that are applied to the `Builder` instance for incremental changes.These actions are executed in the order they are added. - - -### Microsoft.Extensions.AI -To configure a chat client, you'll need a LLM provider package such as [Microsoft.Extensions.AI.OpenAI](https://www.nuget.org/packages/Microsoft.Extensions.AI.OpenAI) or [OllamaSharp](https://www.nuget.org/packages/OllamaSharp/) to configure a chat client. - -_The following example requires [OllamaSharp](https://www.nuget.org/packages/OllamaSharp/) package to be installed._ - - -Demonstration of the default workspace configuration: -```csharp -[DependsOn(typeof(AbpAIModule))] -public class MyProjectModule : AbpModule -{ - public override void PreConfigureServices(ServiceConfigurationContext context) - { - PreConfigure(options => - { - options.Workspaces.ConfigureDefault(configuration => - { - configuration.ConfigureChatClient(chatClientConfiguration => - { - chatClientConfiguration.Builder = new ChatClientBuilder( - sp => new OllamaApiClient("http://localhost:11434", "mistral") - ); - }); - }); - }); - } -} -``` - - -Demonstration of the isolated workspace configuration: -```csharp -[DependsOn(typeof(AbpAIModule))] -public class MyProjectModule : AbpModule -{ - public override void PreConfigureServices(ServiceConfigurationContext context) - { - PreConfigure(options => - { - options.Workspaces.Configure(configuration => - { - configuration.ConfigureChatClient(chatClientConfiguration => - { - chatClientConfiguration.Builder = new ChatClientBuilder( - sp => new OllamaApiClient("http://localhost:11434", "mistral") - ); - }); - }); - }); - } -} -``` - -### Semantic Kernel -To configure a kernel, you'll need a kernel connector package such as [Microsoft.SemanticKernel.Connectors.OpenAI](Microsoft.SemanticKernel.Connectors.OpenAI) to configure a kernel to use a specific LLM provider. - -_The following example requires [Microsoft.SemanticKernel.Connectors.AzureOpenAI](Microsoft.SemanticKernel.Connectors.AzureOpenAI) package to be installed._ - -Demonstration of the default workspace configuration: -```csharp -[DependsOn(typeof(AbpAIModule))] -public class MyProjectModule : AbpModule -{ - public override void PreConfigureServices(ServiceConfigurationContext context) - { - PreConfigure(options => - { - options.Workspaces.ConfigureDefault(configuration => - { - configuration.ConfigureKernel(kernelConfiguration => - { - kernelConfiguration.Builder = Kernel.CreateBuilder() - .AddAzureOpenAIChatClient("...", "..."); - }); - // Note: Chat client is not configured here - }); - }); - } -} -``` - -Demonstration of the isolated workspace configuration: -```csharp -[DependsOn(typeof(AbpAIModule))] -public class MyProjectModule : AbpModule -{ - public override void PreConfigureServices(ServiceConfigurationContext context) - { - PreConfigure(options => - { - options.Workspaces.Configure(configuration => - { - configuration.ConfigureKernel(kernelConfiguration => - { - kernelConfiguration.Builder = Kernel.CreateBuilder() - .AddAzureOpenAIChatClient("...", "..."); - }); - }); - }); - } -} -``` \ No newline at end of file diff --git a/docs/en/framework/infrastructure/artificial-intelligence/index.md b/docs/en/framework/infrastructure/artificial-intelligence/index.md new file mode 100644 index 0000000000..e2dba531fd --- /dev/null +++ b/docs/en/framework/infrastructure/artificial-intelligence/index.md @@ -0,0 +1,28 @@ +# Artificial Intelligence +ABP Framework provides integration for AI capabilities to your application by using Microsoft's AI stacks by using abstractions and workspaces. The main purpose of this integration is to provide a consistent way to use AI capabilities and managing different AI providers, models and configurations by using workspaces. + +ABP Framework doesn't implement any AI providers or models, it only provides the abstractions by using Microsoft's packages such as [Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai) and [Microsoft.SemanticKernel](https://learn.microsoft.com/en-us/semantic-kernel/overview/). + +ABP allows you to define a default configuration for across the application and also allows you to define isolated configurations for different different purposes by using workspaces. A workspace allows you to configure isolated AI configurations for a named scope. You can resolve AI services for a specific workspace when you need to use them. + + + +## Installation + +> This package is not included by default. Install it to enable AI features. + +It is suggested to use the ABP CLI to install the package. Open a command line window in the folder of the project (.csproj file) and type the following command: + +```bash +abp add-package Volo.Abp.AI +``` + +## Usage +Both `Microsoft.Extensions.AI` and `Microsoft.SemanticKernel` are supported. Microsoft provides `IChatClient` interface to cover multiple chat client integrations. ABP respects it and uses it by default. You'll be use this interface to access the chat client from your services. In the other hand, `Microsoft.SemanticKernel` provides `Kernel` object to configure and execute AI capabilities ABP respects it and uses it by default but the Kernel is not directly accessible from your services. You'll be use `IKernelAccessor` service to access the `Kernel` object from your services. + +You can use both of them in your application by resolving `IChatClient` or `IKernelAccessor` services from the [service provider](../fundamentals/dependency-injection.md). `IChatClient` is the original interface from `Microsoft.Extensions.AI` but `IKernelAccessor` is a custom service that is used to access the `Kernel` object from `Microsoft.SemanticKernel`. + +Check the following documentation for the usage of `Microsoft.Extensions.AI` and `Microsoft.SemanticKernel`: + +- [Microsoft.Extensions.AI](./microsoft-extensions-ai.md) +- [Microsoft.SemanticKernel](./microsoft-semantic-kernel.md) diff --git a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md new file mode 100644 index 0000000000..92ece58fbe --- /dev/null +++ b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md @@ -0,0 +1,170 @@ +# Microsoft.Extensions.AI +[Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai) is a library that provides a unified API for integrating AI services. It is a part of the Microsoft AI Extensions Library. It is used to integrate AI services into your application. This documentation is about the usage of this library with ABP Framework. Make sure you have read the [Artificial Intelligence](../artificial-intelligence.md) documentation before reading this documentation. + +## Usage + +You can resolve `IChatClient` to access configured chat client from your service and use it directly. + +```csharp +public class MyService +{ + private readonly IChatClient _chatClient; + public MyService(IChatClient chatClient) + { + _chatClient = chatClient; + } + + public async Task GetResponseAsync(string prompt) + { + return await _chatClient.GetResponseAsync(prompt); + } +} +``` + +You can also resolve `IChatClientAccessor` to access the `IChatClient` optionally configured scenarios such as developing a module or a service that may use AI capabilities **optionally**. + + +```csharp +public class MyService +{ + private readonly IChatClientAccessor _chatClientAccessor; + public MyService(IChatClientAccessor chatClientAccessor) + { + _chatClientAccessor = chatClientAccessor; + } + + public async Task GetResponseAsync(string prompt) + { + var chatClient = _chatClientAccessor.ChatClient; + if (chatClient is null) + { + return "No chat client configured"; + } + return await chatClient.GetResponseAsync(prompt); + } +} +``` + +### Workspaces + +Workspaces are a way to configure isolated AI configurations for a named scope. You can define a workspace by decorating a class with the `WorkspaceNameAttribute` attribute that carries the workspace name. +- Workspace names must be unique. +- Workspace names cannot contain spaces _(use underscores or camelCase)_. +- Workspace names are case-sensitive. + +```csharp +using Volo.Abp.AI; + +[WorkspaceName("CommentSummarization")] +public class CommentSummarization +{ +} +``` + +> [!NOTE] +> If you don't specify the workspace name, the full name of the class will be used as the workspace name. + +You can resolve generic versions of `IChatClient` and `IChatClientAccessor` services for a specific workspace as generic arguments. If Chat Client is not configured for a workspace, you will get `null` from the accessor services. You should check the accessor before using it. This applies only for specified workspaces. Another workspace may have a configured Chat Client. + +`IChatClient` or `IChatClientAccessor` can be resolved to access a specific workspace's chat client. This is a typed chat client and can be configured separately from the default chat client. + + +Example of resolving a typed chat client: +```csharp +public class MyService +{ + private readonly IChatClient _chatClient; + + public MyService(IChatClient chatClient) + { + _chatClient = chatClient; + } + + public async Task GetResponseAsync(string prompt) + { + return await _chatClient.GetResponseAsync(prompt); + } +} +``` + +Example of resolving a typed chat client accessor: +```csharp +public class MyService +{ + private readonly IChatClientAccessor _chatClientAccessor; +} + public async Task GetResponseAsync(string prompt) + { + var chatClient = _chatClientAccessor.ChatClient; + if (chatClient is null) + { + return "No chat client configured"; + } + return await chatClient.GetResponseAsync(prompt); + } +} +``` + +## Configuration + +`AbpAIWorkspaceOptions` configuration is used to configure AI workspaces and their configurations. You can configure the default workspace and also configure isolated workspaces by using the this options class.It has to be configured **before the services are configured** in the `PreConfigure` method of your module class. It is important since the services are registered after the configuration is applied. + +- `AbpAIWorkspaceOptions` has a `Workspaces` property that is type of `WorkspaceConfigurationDictionary` which is a dictionary of workspace names and their configurations. It provides `Configure` and `ConfigureDefault` methods to configure the default workspace and also configure isolated workspaces by using the workspace type. + +- Configure method passes `WorkspaceConfiguration` object to the configure action. You can configure the `ChatClient` by using the `ConfigureChatClient` method. + +- `ConfigureChatClient()` method passes `ChatClientConfiguration` parameter to the configure action. You can configure the `Builder` and `BuilderConfigurers` by using the `ConfigureBuilder` method. + - `Builder` is set once and is used to build the `ChatClient` instance. + - `BuilderConfigurers` is a list of actions that are applied to the `Builder` instance for incremental changes.These actions are executed in the order they are added. + +To configure a chat client, you'll need a LLM provider package such as [Microsoft.Extensions.AI.OpenAI](https://www.nuget.org/packages/Microsoft.Extensions.AI.OpenAI) or [OllamaSharp](https://www.nuget.org/packages/OllamaSharp/) to configure a chat client. + +_The following example requires [OllamaSharp](https://www.nuget.org/packages/OllamaSharp/) package to be installed._ + + +Demonstration of the default workspace configuration: +```csharp +[DependsOn(typeof(AbpAIModule))] +public class MyProjectModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(options => + { + options.Workspaces.ConfigureDefault(configuration => + { + configuration.ConfigureChatClient(chatClientConfiguration => + { + chatClientConfiguration.Builder = new ChatClientBuilder( + sp => new OllamaApiClient("http://localhost:11434", "mistral") + ); + }); + }); + }); + } +} +``` + + +Demonstration of the isolated workspace configuration: +```csharp +[DependsOn(typeof(AbpAIModule))] +public class MyProjectModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(options => + { + options.Workspaces.Configure(configuration => + { + configuration.ConfigureChatClient(chatClientConfiguration => + { + chatClientConfiguration.Builder = new ChatClientBuilder( + sp => new OllamaApiClient("http://localhost:11434", "mistral") + ); + }); + }); + }); + } +} +``` \ No newline at end of file diff --git a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md new file mode 100644 index 0000000000..ba0bf3538d --- /dev/null +++ b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md @@ -0,0 +1,130 @@ +# Microsoft.SemanticKernel +[Microsoft.SemanticKernel](https://learn.microsoft.com/en-us/semantic-kernel/overview/) is a library that provides a unified SDK for integrating AI services. This documentation is about the usage of this library with ABP Framework. Make sure you have read the [Artificial Intelligence](../artificial-intelligence.md) documentation before reading this documentation. + +## Usage + +Semantic Kernel can be used by resolving `IKernelAccessor` service that carries the `Kernel` instance. Kernel might be `null` if no workspace is configured. You should check the kernel before using it. + +```csharp +public class MyService +{ + private readonly IKernelAccessor _kernelAccessor; + public MyService(IKernelAccessor kernelAccessor) + { + _kernelAccessor = kernelAccessor; + } + + public async Task GetResponseAsync(string prompt) + { + var kernel = _kernelAccessor.Kernel; + if (kernel is null) + { + return "No kernel configured"; + } + return await kernel.InvokeAsync(prompt); + } +} +``` + +### Workspaces + +Workspaces are a way to configure isolated AI configurations for a named scope. You can define a workspace by decorating a class with the `WorkspaceNameAttribute` attribute that carries the workspace name. +- Workspace names must be unique. +- Workspace names cannot contain spaces _(use underscores or camelCase)_. +- Workspace names are case-sensitive. + +```csharp +using Volo.Abp.AI; + +[WorkspaceName("CommentSummarization")] +public class CommentSummarization +{ +} +``` + +> [!NOTE] +> If you don't specify the workspace name, the full name of the class will be used as the workspace name. + +You can resolve generic versions of `IKernelAccessor` service for a specific workspace as generic arguments. If Kernel is not configured for a workspace, you will get `null` from the accessor service. You should check the accessor before using it. This applies only for specified workspaces. Another workspace may have a configured Kernel. + + +`IKernelAccessor` can be resolved to access a specific workspace's kernel. This is a typed kernel accessor and each workspace can have its own kernel configuration. + +Example of resolving a typed kernel accessor: +```csharp +public class MyService +{ + private readonly IKernelAccessor _kernelAccessor; +} + public async Task GetResponseAsync(string prompt) + { + var kernel = _kernelAccessor.Kernel; + if (kernel is null) + { + return "No kernel configured"; + } + return await kernel.InvokeAsync(prompt); + } +} +``` + +## Configuration + +`AbpAIWorkspaceOptions` configuration is used to configure AI workspaces and their configurations. You can configure the default workspace and also configure isolated workspaces by using the this options class.It has to be configured **before the services are configured** in the `PreConfigure` method of your module class. It is important since the services are registered after the configuration is applied. + +- `AbpAIWorkspaceOptions` has a `Workspaces` property that is type of `WorkspaceConfigurationDictionary` which is a dictionary of workspace names and their configurations. It provides `Configure` and `ConfigureDefault` methods to configure the default workspace and also configure isolated workspaces by using the workspace type. + +- Configure method passes `WorkspaceConfiguration` object to the configure action. You can configure the `Kernel` by using the `ConfigureKernel` method. + +- `ConfigureKernel()` method passes `KernelConfiguration` parameter to the configure action. You can configure the `Builder` and `BuilderConfigurers` by using the `ConfigureBuilder` method. + - `Builder` is set once and is used to build the `Kernel` instance. + - `BuilderConfigurers` is a list of actions that are applied to the `Builder` instance for incremental changes.These actions are executed in the order they are added. + +To configure a kernel, you'll need a kernel connector package such as [Microsoft.SemanticKernel.Connectors.OpenAI](Microsoft.SemanticKernel.Connectors.OpenAI) to configure a kernel to use a specific LLM provider. + +_The following example requires [Microsoft.SemanticKernel.Connectors.AzureOpenAI](Microsoft.SemanticKernel.Connectors.AzureOpenAI) package to be installed._ + +Demonstration of the default workspace configuration: +```csharp +[DependsOn(typeof(AbpAIModule))] +public class MyProjectModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(options => + { + options.Workspaces.ConfigureDefault(configuration => + { + configuration.ConfigureKernel(kernelConfiguration => + { + kernelConfiguration.Builder = Kernel.CreateBuilder() + .AddAzureOpenAIChatClient("...", "..."); + }); + // Note: Chat client is not configured here + }); + }); + } +} +``` + +Demonstration of the isolated workspace configuration: +```csharp +[DependsOn(typeof(AbpAIModule))] +public class MyProjectModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(options => + { + options.Workspaces.Configure(configuration => + { + configuration.ConfigureKernel(kernelConfiguration => + { + kernelConfiguration.Builder = Kernel.CreateBuilder() + .AddAzureOpenAIChatClient("...", "..."); + }); + }); + }); + } +} +``` \ No newline at end of file From a13a735a2d75b0c9f59312737ec87781b4ec3d6d Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 12 Nov 2025 16:29:49 +0300 Subject: [PATCH 06/16] Update links --- .../artificial-intelligence/microsoft-extensions-ai.md | 2 +- .../artificial-intelligence/microsoft-semantic-kernel.md | 2 +- docs/en/framework/infrastructure/index.md | 2 +- docs/en/modules/ai-management/index.md | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md index 92ece58fbe..60f41e3d96 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md +++ b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md @@ -1,5 +1,5 @@ # Microsoft.Extensions.AI -[Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai) is a library that provides a unified API for integrating AI services. It is a part of the Microsoft AI Extensions Library. It is used to integrate AI services into your application. This documentation is about the usage of this library with ABP Framework. Make sure you have read the [Artificial Intelligence](../artificial-intelligence.md) documentation before reading this documentation. +[Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai) is a library that provides a unified API for integrating AI services. It is a part of the Microsoft AI Extensions Library. It is used to integrate AI services into your application. This documentation is about the usage of this library with ABP Framework. Make sure you have read the [Artificial Intelligence](../index.md) documentation before reading this documentation. ## Usage diff --git a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md index ba0bf3538d..3dfed0b0b0 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md +++ b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md @@ -1,5 +1,5 @@ # Microsoft.SemanticKernel -[Microsoft.SemanticKernel](https://learn.microsoft.com/en-us/semantic-kernel/overview/) is a library that provides a unified SDK for integrating AI services. This documentation is about the usage of this library with ABP Framework. Make sure you have read the [Artificial Intelligence](../artificial-intelligence.md) documentation before reading this documentation. +[Microsoft.SemanticKernel](https://learn.microsoft.com/en-us/semantic-kernel/overview/) is a library that provides a unified SDK for integrating AI services. This documentation is about the usage of this library with ABP Framework. Make sure you have read the [Artificial Intelligence](./index.md) documentation before reading this documentation. ## Usage diff --git a/docs/en/framework/infrastructure/index.md b/docs/en/framework/infrastructure/index.md index a242c8b4fa..ec6377d757 100644 --- a/docs/en/framework/infrastructure/index.md +++ b/docs/en/framework/infrastructure/index.md @@ -10,7 +10,7 @@ ABP provides a complete infrastructure for creating real world software solutions with modern architectures based on the .NET platform. Each of the following documents explains an infrastructure feature: * [Audit Logging](./audit-logging.md) -* [Artificial Intelligence](./artificial-intelligence.md) +* [Artificial Intelligence](./artificial-intelligence/index.md) * [Background Jobs](./background-jobs/index.md) * [Background Workers](./background-workers/index.md) * [BLOB Storing](./blob-storing/index.md) diff --git a/docs/en/modules/ai-management/index.md b/docs/en/modules/ai-management/index.md index 0d3abe18a0..339124acca 100644 --- a/docs/en/modules/ai-management/index.md +++ b/docs/en/modules/ai-management/index.md @@ -2,7 +2,7 @@ > You must have an ABP Team or a higher license to use this module. -This module implements AI (Artificial Intelligence) management capabilities on top of the [Artificial Intelligence Workspaces](../../framework/infrastructure/artificial-intelligence.md) feature of the ABP Framework and allows to manage workspaces dynamically from the application including UI components and API endpoints. +This module implements AI (Artificial Intelligence) management capabilities on top of the [Artificial Intelligence Workspaces](../../framework/infrastructure/artificial-intelligence/index.md) feature of the ABP Framework and allows to manage workspaces dynamically from the application including UI components and API endpoints. ## How to Install @@ -241,7 +241,7 @@ public class MyService } ``` -> See [Artificial Intelligence](../../framework/infrastructure/artificial-intelligence.md) documentation for more details about workspace configuration. +> See [Artificial Intelligence](../../framework/infrastructure/artificial-intelligence/index.md) documentation for more details about workspace configuration. ### Scenario 2: AI Management with Domain Layer Dependency (Local Execution) @@ -619,6 +619,6 @@ The cache is automatically invalidated when workspaces are created, updated, or ## See Also -- [Artificial Intelligence Infrastructure](../../framework/infrastructure/artificial-intelligence.md): Learn about the underlying AI workspace infrastructure +- [Artificial Intelligence Infrastructure](../../framework/infrastructure/artificial-intelligence/index.md): Learn about the underlying AI workspace infrastructure - [Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/ai/): Microsoft's unified AI abstractions - [Semantic Kernel](https://learn.microsoft.com/en-us/semantic-kernel/): Microsoft's Semantic Kernel integration \ No newline at end of file From afbc3bcce97ce5f68af08eb14343256900c8d1c8 Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 12 Nov 2025 16:30:53 +0300 Subject: [PATCH 07/16] Update index.md --- .../framework/infrastructure/artificial-intelligence/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/framework/infrastructure/artificial-intelligence/index.md b/docs/en/framework/infrastructure/artificial-intelligence/index.md index e2dba531fd..82a133ca1d 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence/index.md +++ b/docs/en/framework/infrastructure/artificial-intelligence/index.md @@ -24,5 +24,5 @@ You can use both of them in your application by resolving `IChatClient` or `IKer Check the following documentation for the usage of `Microsoft.Extensions.AI` and `Microsoft.SemanticKernel`: -- [Microsoft.Extensions.AI](./microsoft-extensions-ai.md) -- [Microsoft.SemanticKernel](./microsoft-semantic-kernel.md) +- [Usage of Microsoft.Extensions.AI](./microsoft-extensions-ai.md) +- [Usage of Microsoft.SemanticKernel](./microsoft-semantic-kernel.md) From 8c7bd2167148c5216a931cece3cabfc0523b3326 Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 12 Nov 2025 16:32:41 +0300 Subject: [PATCH 08/16] Update links --- .../infrastructure/artificial-intelligence/index.md | 1 + .../artificial-intelligence/microsoft-extensions-ai.md | 8 +++++++- .../artificial-intelligence/microsoft-semantic-kernel.md | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/en/framework/infrastructure/artificial-intelligence/index.md b/docs/en/framework/infrastructure/artificial-intelligence/index.md index 82a133ca1d..74d0ffb93c 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence/index.md +++ b/docs/en/framework/infrastructure/artificial-intelligence/index.md @@ -26,3 +26,4 @@ Check the following documentation for the usage of `Microsoft.Extensions.AI` and - [Usage of Microsoft.Extensions.AI](./microsoft-extensions-ai.md) - [Usage of Microsoft.SemanticKernel](./microsoft-semantic-kernel.md) + diff --git a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md index 60f41e3d96..1f0b54a478 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md +++ b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md @@ -167,4 +167,10 @@ public class MyProjectModule : AbpModule }); } } -``` \ No newline at end of file +``` + + +## See Also + +- [Usage of Semantic Kernel](./microsoft-semantic-kernel.md) +- [AI Samples for .NET](https://github.com/microsoft/ai-samples): Microsoft's AI samples for .NET \ No newline at end of file diff --git a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md index 3dfed0b0b0..d4b0eff533 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md +++ b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md @@ -127,4 +127,9 @@ public class MyProjectModule : AbpModule }); } } -``` \ No newline at end of file +``` + +## See Also + +- [Usage of Microsoft.Extensions.AI](./microsoft-extensions-ai.md) +- [AI Samples for .NET](https://github.com/microsoft/ai-samples): Microsoft's AI samples for .NET \ No newline at end of file From 2573fdf1b3265260e8f1bdbd8b5ae0542d69a5b5 Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 12 Nov 2025 16:33:12 +0300 Subject: [PATCH 09/16] Update microsoft-extensions-ai.md --- .../artificial-intelligence/microsoft-extensions-ai.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md index 1f0b54a478..8763d6ab1f 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md +++ b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md @@ -1,5 +1,5 @@ # Microsoft.Extensions.AI -[Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai) is a library that provides a unified API for integrating AI services. It is a part of the Microsoft AI Extensions Library. It is used to integrate AI services into your application. This documentation is about the usage of this library with ABP Framework. Make sure you have read the [Artificial Intelligence](../index.md) documentation before reading this documentation. +[Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai) is a library that provides a unified API for integrating AI services. It is a part of the Microsoft AI Extensions Library. It is used to integrate AI services into your application. This documentation is about the usage of this library with ABP Framework. Make sure you have read the [Artificial Intelligence](./index.md) documentation before reading this documentation. ## Usage From f34c73cf34f9c3cfe69e12694d3ed9780d370ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 12 Nov 2025 18:32:47 +0300 Subject: [PATCH 10/16] Revisit the AI introduction document --- .../artificial-intelligence/index.md | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/docs/en/framework/infrastructure/artificial-intelligence/index.md b/docs/en/framework/infrastructure/artificial-intelligence/index.md index 74d0ffb93c..9b3466d77e 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence/index.md +++ b/docs/en/framework/infrastructure/artificial-intelligence/index.md @@ -1,29 +1,31 @@ # Artificial Intelligence -ABP Framework provides integration for AI capabilities to your application by using Microsoft's AI stacks by using abstractions and workspaces. The main purpose of this integration is to provide a consistent way to use AI capabilities and managing different AI providers, models and configurations by using workspaces. - -ABP Framework doesn't implement any AI providers or models, it only provides the abstractions by using Microsoft's packages such as [Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai) and [Microsoft.SemanticKernel](https://learn.microsoft.com/en-us/semantic-kernel/overview/). - -ABP allows you to define a default configuration for across the application and also allows you to define isolated configurations for different different purposes by using workspaces. A workspace allows you to configure isolated AI configurations for a named scope. You can resolve AI services for a specific workspace when you need to use them. +> ABP Framework can work with any AI library or framework that supports .NET development. +ABP Framework provides integration for AI capabilities to your application by using Microsoft's popular AI libraries. The main purpose of this integration is to provide a consistent and easy way to use AI capabilities and manage different AI providers, models and configurations in a single application. +ABP introduces a concept called **AI Workspace**. A workspace allows you to configure isolated AI configurations for a named scope. You can then resolve AI services for a specific workspace when you need to use them. ## Installation -> This package is not included by default. Install it to enable AI features. - -It is suggested to use the ABP CLI to install the package. Open a command line window in the folder of the project (.csproj file) and type the following command: +Use the [ABP CLI](../../../cli/index.md) to install the [Volo.Abp.AI](https://www.nuget.org/packages/Volo.Abp.AI) NuGet package into your project. Open a command line window in the root directory of your project (`.csproj` file) and type the following command: ```bash abp add-package Volo.Abp.AI ``` +*For different installation options, check [the package definition page](https://abp.io/package-detail/Volo.Abp.AI).* + ## Usage -Both `Microsoft.Extensions.AI` and `Microsoft.SemanticKernel` are supported. Microsoft provides `IChatClient` interface to cover multiple chat client integrations. ABP respects it and uses it by default. You'll be use this interface to access the chat client from your services. In the other hand, `Microsoft.SemanticKernel` provides `Kernel` object to configure and execute AI capabilities ABP respects it and uses it by default but the Kernel is not directly accessible from your services. You'll be use `IKernelAccessor` service to access the `Kernel` object from your services. -You can use both of them in your application by resolving `IChatClient` or `IKernelAccessor` services from the [service provider](../fundamentals/dependency-injection.md). `IChatClient` is the original interface from `Microsoft.Extensions.AI` but `IKernelAccessor` is a custom service that is used to access the `Kernel` object from `Microsoft.SemanticKernel`. +The `Volo.Abp.AI` package provides integration with the following libraries: + +* [Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai) +* [Microsoft.SemanticKernel](https://learn.microsoft.com/en-us/semantic-kernel/overview/) + +The Microsoft.Extensions.AI library is suggested for library developers to keep the library dependency minimum and simple (since it provides basic abstractions and fundamental AI provider integrations), while Semantic Kernel is suggested for applications that need rich and advanced AI integration features. -Check the following documentation for the usage of `Microsoft.Extensions.AI` and `Microsoft.SemanticKernel`: +Check the following documentation to learn how to use these libraries with the ABP integration: -- [Usage of Microsoft.Extensions.AI](./microsoft-extensions-ai.md) -- [Usage of Microsoft.SemanticKernel](./microsoft-semantic-kernel.md) +- [ABP Microsoft.Extensions.AI integration](./microsoft-extensions-ai.md) +- [ABP Microsoft.SemanticKernel integration](./microsoft-semantic-kernel.md) From 0ab9f348c3d8070ce1722e763d1ac9608826b352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 12 Nov 2025 18:37:26 +0300 Subject: [PATCH 11/16] Update index.md --- .../framework/infrastructure/artificial-intelligence/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/framework/infrastructure/artificial-intelligence/index.md b/docs/en/framework/infrastructure/artificial-intelligence/index.md index 9b3466d77e..1d09af594f 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence/index.md +++ b/docs/en/framework/infrastructure/artificial-intelligence/index.md @@ -1,10 +1,10 @@ # Artificial Intelligence -> ABP Framework can work with any AI library or framework that supports .NET development. - ABP Framework provides integration for AI capabilities to your application by using Microsoft's popular AI libraries. The main purpose of this integration is to provide a consistent and easy way to use AI capabilities and manage different AI providers, models and configurations in a single application. ABP introduces a concept called **AI Workspace**. A workspace allows you to configure isolated AI configurations for a named scope. You can then resolve AI services for a specific workspace when you need to use them. +> ABP Framework can work with any AI library or framework that supports .NET development. However, the AI integration features explained in the following documents provide a modular and standard way to work with AI, which allows ABP developers to create reusable modules and components with AI capabilities in a standard way. + ## Installation Use the [ABP CLI](../../../cli/index.md) to install the [Volo.Abp.AI](https://www.nuget.org/packages/Volo.Abp.AI) NuGet package into your project. Open a command line window in the root directory of your project (`.csproj` file) and type the following command: From 82baa822162b7a9023ca9950d2aa757ffbe42d69 Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 12 Nov 2025 19:43:45 +0300 Subject: [PATCH 12/16] Update AI samples link to Microsoft Learn Replaced the outdated GitHub link for 'AI Samples for .NET' with the official Microsoft Learn samples page in both Microsoft.Extensions.AI and Semantic Kernel documentation. --- .../artificial-intelligence/microsoft-extensions-ai.md | 2 +- .../artificial-intelligence/microsoft-semantic-kernel.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md index 8763d6ab1f..35b370585e 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md +++ b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-extensions-ai.md @@ -173,4 +173,4 @@ public class MyProjectModule : AbpModule ## See Also - [Usage of Semantic Kernel](./microsoft-semantic-kernel.md) -- [AI Samples for .NET](https://github.com/microsoft/ai-samples): Microsoft's AI samples for .NET \ No newline at end of file +- [AI Samples for .NET](https://learn.microsoft.com/en-us/samples/dotnet/ai-samples/ai-samples/) \ No newline at end of file diff --git a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md index d4b0eff533..07622391bd 100644 --- a/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md +++ b/docs/en/framework/infrastructure/artificial-intelligence/microsoft-semantic-kernel.md @@ -132,4 +132,4 @@ public class MyProjectModule : AbpModule ## See Also - [Usage of Microsoft.Extensions.AI](./microsoft-extensions-ai.md) -- [AI Samples for .NET](https://github.com/microsoft/ai-samples): Microsoft's AI samples for .NET \ No newline at end of file +- [AI Samples for .NET](https://learn.microsoft.com/en-us/samples/dotnet/ai-samples/ai-samples/) \ No newline at end of file From 0c1e493122cc3cb0513b13f798ed55ea6bf25ac1 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 19 Nov 2025 13:04:55 +0800 Subject: [PATCH 13/16] Update migration guide for Razor Runtime Compilation --- docs/en/release-info/migration-guides/abp-10-0.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/release-info/migration-guides/abp-10-0.md b/docs/en/release-info/migration-guides/abp-10-0.md index ecf1c7fca2..b5379062f6 100644 --- a/docs/en/release-info/migration-guides/abp-10-0.md +++ b/docs/en/release-info/migration-guides/abp-10-0.md @@ -20,6 +20,8 @@ We removed the Razor Runtime Compilation support since it is obsolete and replac If you want to keep using it, you can add [Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation](https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation) package to your project and configure it manually. +> If the referenced project also contains Razor Pages that require this feature, add the package to that project as well. + ```csharp using Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation; using Volo.Abp.DependencyInjection; From d8acd9a606e68257141ce662ba52669cce8710d9 Mon Sep 17 00:00:00 2001 From: sumeyye Date: Wed, 19 Nov 2025 09:41:01 +0300 Subject: [PATCH 14/16] fix: merger conflict on extensible form prop component --- .../extensible-form-prop.component.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/npm/ng-packs/packages/components/extensible/src/lib/components/extensible-form/extensible-form-prop.component.ts b/npm/ng-packs/packages/components/extensible/src/lib/components/extensible-form/extensible-form-prop.component.ts index dc52eff6a4..696ce633a7 100644 --- a/npm/ng-packs/packages/components/extensible/src/lib/components/extensible-form/extensible-form-prop.component.ts +++ b/npm/ng-packs/packages/components/extensible/src/lib/components/extensible-form/extensible-form-prop.component.ts @@ -101,9 +101,6 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { @Input() isFirstGroup?: boolean; @ViewChild('field') private fieldRef!: ElementRef; - private shouldFocus = signal(false); - private isViewReady = signal(false); - injectorForCustomComponent?: Injector; asterisk = ''; containerClassName = 'mb-2'; @@ -120,15 +117,6 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { return this.disabledFn(this.data); } - constructor() { - // Effect to handle focus when both conditions are met - effect(() => { - if (this.shouldFocus() && this.isViewReady() && this.fieldRef?.nativeElement) { - this.focusElement(); - } - }); - } - setTypeaheadValue(selectedOption: ABP.Option) { this.typeaheadModel = selectedOption || { key: null, value: null }; const { key, value } = this.typeaheadModel; From a8de9df45c9af24332d665c144dcd8fe48324033 Mon Sep 17 00:00:00 2001 From: EngincanV Date: Wed, 19 Nov 2025 09:42:14 +0300 Subject: [PATCH 15/16] Add MySQL compatibility notice for .NET 10.0 to migration guide Added a section to the ABP 10.0 migration guide warning users about limited MySQL provider support for .NET 10.0 and recommending to delay upgrades until stable releases are available. --- .../release-info/migration-guides/abp-10-0.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/en/release-info/migration-guides/abp-10-0.md b/docs/en/release-info/migration-guides/abp-10-0.md index b5379062f6..c75cf97930 100644 --- a/docs/en/release-info/migration-guides/abp-10-0.md +++ b/docs/en/release-info/migration-guides/abp-10-0.md @@ -8,6 +8,24 @@ This document is a guide for upgrading ABP v9.x solutions to ABP v10.0. There ar We've upgraded ABP to .NET 10.0, so you need to move your solutions to .NET 10.0 if you want to use ABP 10.0. You can check Microsoft’s [Migrate from ASP.NET Core 9.0 to 10.0](https://learn.microsoft.com/en-us/aspnet/core/migration/90-to-100) documentation to see how to update an existing ASP.NET Core 9.0 project to ASP.NET Core 10.0. +### MySQL Support for .NET 10.0 + +**If you are using MySQL as your database provider, please be aware of the following compatibility issues before upgrading to ABP 10.0:** + +The MySQL Entity Framework Core providers currently have limited support for .NET 10.0: + +* **Pomelo.EntityFrameworkCore.MySql**: Does not yet support .NET 10.0. The team is actively working on adding support. +* **MySql.EntityFrameworkCore**: Currently in Release Candidate (RC) status with known bugs that may affect production applications. + +**Recommendation**: If you are using MySQL, we recommend waiting to upgrade to ABP 10.0 until the MySQL providers release stable versions with full .NET 10.0 support. + +**Track Progress**: + +* [Pomelo Provider - EF Core 10 Support](https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/2007) +* [MySql.EntityFrameworkCore NuGet Package](https://www.nuget.org/packages/MySql.EntityFrameworkCore/#versions-body-tab) + +We will update to support the latest stable MySQL providers as soon as they become available. + ### Add New EF Core Migrations Some entities in certain modules have been modified. If you are using Entity Framework Core, please create a new EF Core migration in your project after upgrading to ABP 10.0. From ea258056659976f459ab1282ca10a08f180fe679 Mon Sep 17 00:00:00 2001 From: Engincan VESKE Date: Wed, 19 Nov 2025 06:43:58 +0000 Subject: [PATCH 16/16] Update MySQL compatibility note for ABP 10.0 --- docs/en/release-info/migration-guides/abp-10-0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/release-info/migration-guides/abp-10-0.md b/docs/en/release-info/migration-guides/abp-10-0.md index c75cf97930..ea095d58b3 100644 --- a/docs/en/release-info/migration-guides/abp-10-0.md +++ b/docs/en/release-info/migration-guides/abp-10-0.md @@ -10,7 +10,7 @@ We've upgraded ABP to .NET 10.0, so you need to move your solutions to .NET 10.0 ### MySQL Support for .NET 10.0 -**If you are using MySQL as your database provider, please be aware of the following compatibility issues before upgrading to ABP 10.0:** +**If you are using MySQL as your database provider, please be aware of the following compatibility issues before upgrading to ABP 10.0!** The MySQL Entity Framework Core providers currently have limited support for .NET 10.0: