|
1 | 1 |  Devlooped AI Extensions |
2 | 2 | ============ |
3 | 3 |
|
4 | | -[](https://github.com//devlooped/AI/blob/main/license.txt) |
5 | | -[](https://github.com/devlooped/AI/actions/workflows/build.yml) |
| 4 | +[](osmfeula.txt) |
| 5 | +[](license.txt) |
6 | 6 |
|
7 | 7 | Extensions for Microsoft.Agents.AI and Microsoft.Extensions.AI. |
8 | 8 |
|
9 | | -## Open Source Maintenance Fee |
| 9 | +<!-- include https://github.com/devlooped/.github/raw/main/osmf.md --> |
10 | 10 |
|
11 | | -To ensure the long-term sustainability of this project, use of this project requires an |
12 | | -[Open Source Maintenance Fee](https://opensourcemaintenancefee.org). While the source |
13 | | -code is freely available under the terms of the [MIT License](./license.txt), all other aspects of the |
14 | | -project --including opening or commenting on issues, participating in discussions and |
15 | | -downloading releases-- require [adherence to the Maintenance Fee](./osmfeula.txt). |
| 11 | +# Devlooped.Agents.AI |
16 | 12 |
|
17 | | -In short, if you use this project to generate revenue, the [Maintenance Fee is required](./osmfeula.txt). |
| 13 | +[](https://www.nuget.org/packages/Devlooped.Agents.AI) |
| 14 | +[](https://www.nuget.org/packages/Devlooped.Agents.AI) |
18 | 15 |
|
19 | | -To pay the Maintenance Fee, [become a Sponsor](https://github.com/sponsors/devlooped). |
| 16 | +<!-- #agents-title --> |
| 17 | +Extensions for Microsoft.Agents.AI, such as configuration-driven auto-reloading agents. |
| 18 | +<!-- #agents-title --> |
| 19 | + |
| 20 | +<!-- #agents --> |
| 21 | +## Overview |
| 22 | + |
| 23 | +Microsoft.Agents.AI (aka [Agent Framework](https://learn.microsoft.com/en-us/agent-framework/overview/agent-framework-overview) |
| 24 | +is a comprehensive API for building AI agents. Its programatic model (which follows closely |
| 25 | +the [Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai) |
| 26 | +approach) provides maximum flexibility with little prescriptive structure. |
| 27 | + |
| 28 | +This package provides additional extensions to make developing agents easier and more |
| 29 | +declarative. |
| 30 | + |
| 31 | +## Configurable Agents |
| 32 | + |
| 33 | +Tweaking agent options such as description, instructions, chat client to use and its |
| 34 | +options, etc. is very common during development/testing. This package provides the ability to |
| 35 | +drive those settings from configuration (with auto-reload support). This makes it far easier |
| 36 | +to experiment with various combinations of agent instructions, chat client providers and |
| 37 | +options, and model parameters without changing code, recompiling or even restarting the application: |
| 38 | + |
| 39 | +> [!NOTE] |
| 40 | +> This example shows integration with configurable chat clients feature from the |
| 41 | +> Devlooped.Extensions.AI package, but any `IChatClient` registered in the DI container |
| 42 | +> with a matching key can be used. |
| 43 | +
|
| 44 | +```json |
| 45 | +{ |
| 46 | + "AI": { |
| 47 | + "Agents": { |
| 48 | + "MyAgent": { |
| 49 | + "Description": "An AI agent that helps with customer support.", |
| 50 | + "Instructions": "You are a helpful assistant for customer support.", |
| 51 | + "Client": "Grok", |
| 52 | + "Options": { |
| 53 | + "ModelId": "grok-4", |
| 54 | + "Temperature": 0.5, |
| 55 | + } |
| 56 | + } |
| 57 | + }, |
| 58 | + "Clients": { |
| 59 | + "Grok": { |
| 60 | + "Endpoint": "https://api.grok.ai/v1", |
| 61 | + "ModelId": "grok-4-fast-non-reasoning", |
| 62 | + "ApiKey": "xai-asdf" |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | +} |
| 67 | +```` |
| 68 | + |
| 69 | +```csharp |
| 70 | +var host = new HostApplicationBuilder(args); |
| 71 | +host.Configuration.AddJsonFile("appsettings.json, optional: false, reloadOnChange: true); |
| 72 | + |
| 73 | +// 👇 implicitly calls AddChatClients |
| 74 | +host.AddAIAgents(); |
| 75 | + |
| 76 | +var app = host.Build(); |
| 77 | +var agent = app.Services.GetRequiredKeyedService<AIAgent>("MyAgent"); |
| 78 | +``` |
| 79 | + |
| 80 | +Agents are also properly registered in the corresponding Microsoft Agent Framework |
| 81 | +[AgentCatalog](https://learn.microsoft.com/en-us/dotnet/api/microsoft.agents.ai.hosting.agentcatalog): |
| 82 | + |
| 83 | +```csharp |
| 84 | +var catalog = app.Services.GetRequiredService<AgentCatalog>(); |
| 85 | +await foreach (AIAgent agent in catalog.GetAgentsAsync()) |
| 86 | +{ |
| 87 | + var metadata = agent.GetService<AIAgentMetadata>(); |
| 88 | + Console.WriteLine($"Agent: {agent.Name} by {metadata.ProviderName}"); |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +<!-- #agents --> |
20 | 93 |
|
21 | 94 | # Devlooped.Extensions.AI |
22 | 95 |
|
23 | 96 | [](https://www.nuget.org/packages/Devlooped.Extensions.AI) |
24 | 97 | [](https://www.nuget.org/packages/Devlooped.Extensions.AI) |
25 | 98 |
|
26 | | -<!-- #description --> |
| 99 | +<!-- #extensions-title --> |
27 | 100 | Extensions for Microsoft.Extensions.AI |
28 | | -<!-- #description --> |
| 101 | +<!-- #extensions-title --> |
| 102 | + |
| 103 | +<!-- #extensions --> |
| 104 | +## Configurable Chat Clients |
| 105 | + |
| 106 | +Since tweaking chat options such as model identifier, reasoning effort, verbosity |
| 107 | +and other model settings is very common, this package provides the ability to |
| 108 | +drive those settings from configuration (with auto-reload support), both per-client |
| 109 | +as well as per-request. This makes local development and testing much easier and |
| 110 | +boosts the dev loop: |
| 111 | + |
| 112 | +```json |
| 113 | +{ |
| 114 | + "AI": { |
| 115 | + "Clients": { |
| 116 | + "Grok": { |
| 117 | + "Endpoint": "https://api.grok.ai/v1", |
| 118 | + "ModelId": "grok-4-fast-non-reasoning", |
| 119 | + "ApiKey": "xai-asdf" |
| 120 | + } |
| 121 | + } |
| 122 | + } |
| 123 | +} |
| 124 | +```` |
| 125 | + |
| 126 | +```csharp |
| 127 | +var host = new HostApplicationBuilder(args); |
| 128 | +host.Configuration.AddJsonFile("appsettings.json, optional: false, reloadOnChange: true); |
| 129 | +host.AddChatClients(); |
| 130 | + |
| 131 | +var app = host.Build(); |
| 132 | +var grok = app.Services.GetRequiredKeyedService<IChatClient>("Grok"); |
| 133 | +``` |
| 134 | + |
| 135 | +Changing the `appsettings.json` file will automatically update the client |
| 136 | +configuration without restarting the application. |
| 137 | + |
29 | 138 |
|
30 | | -<!-- #content --> |
31 | 139 | ## Grok |
32 | 140 |
|
33 | 141 | Full support for Grok [Live Search](https://docs.x.ai/docs/guides/live-search) |
@@ -332,7 +440,7 @@ IChatClient client = new GrokChatClient(Environment.GetEnvironmentVariable("XAI_ |
332 | 440 | }) |
333 | 441 | .Build(); |
334 | 442 | ``` |
335 | | -<!-- #content --> |
| 443 | +<!-- #extensions --> |
336 | 444 |
|
337 | 445 | <!-- include https://github.com/devlooped/sponsors/raw/main/footer.md --> |
338 | 446 | # Sponsors |
|
0 commit comments