Devlooped.Extensions.AI
0.5.1
Prefix Reserved
See the version list below for details.
dotnet add package Devlooped.Extensions.AI --version 0.5.1
NuGet\Install-Package Devlooped.Extensions.AI -Version 0.5.1
<PackageReference Include="Devlooped.Extensions.AI" Version="0.5.1" />
<PackageVersion Include="Devlooped.Extensions.AI" Version="0.5.1" />
<PackageReference Include="Devlooped.Extensions.AI" />
paket add Devlooped.Extensions.AI --version 0.5.1
#r "nuget: Devlooped.Extensions.AI, 0.5.1"
#addin nuget:?package=Devlooped.Extensions.AI&version=0.5.1
#tool nuget:?package=Devlooped.Extensions.AI&version=0.5.1
Extensions for Microsoft.Extensions.AI
Grok
Full support for Grok Live Search and Reasoning model options.
// Sample X.AI client usage with .NET
var messages = new Chat()
{
{ "system", "You are a highly intelligent AI assistant." },
{ "user", "What is 101*3?" },
};
var grok = new GrokClient(Env.Get("XAI_API_KEY")!);
var options = new GrokChatOptions
{
ModelId = "grok-3-mini", // or "grok-3-mini-fast"
Temperature = 0.7f,
ReasoningEffort = ReasoningEffort.High, // or ReasoningEffort.Low
Search = GrokSearch.Auto, // or GrokSearch.On or GrokSearch.Off
};
var response = await grok.GetResponseAsync(messages, options);
Search can alternatively be configured using a regular ChatOptions
and adding the HostedWebSearchTool
to the tools collection, which
sets the live search mode to auto
like above:
var messages = new Chat()
{
{ "system", "You are an AI assistant that knows how to search the web." },
{ "user", "What's Tesla stock worth today? Search X and the news for latest info." },
};
var grok = new GrokClient(Env.Get("XAI_API_KEY")!);
var options = new ChatOptions
{
ModelId = "grok-3",
Tools = [new HostedWebSearchTool()]
};
var response = await grok.GetResponseAsync(messages, options);
Console Logging
Additional UseJsonConsoleLogging
extension for rich JSON-formatted console logging of AI requests
are provided at two levels:
- Chat pipeline: similar to
UseLogging
. - HTTP pipeline: lowest possible layer before the request is sent to the AI service,
can capture all requests and responses. Can also be used with other Azure SDK-based
clients that leverage
ClientPipelineOptions
.
Rich JSON formatting is provided by Spectre.Console
The HTTP pipeline logging can be enabled by calling UseJsonConsoleLogging
on the
client options passed to the client constructor:
var openai = new OpenAIClient(
Env.Get("OPENAI_API_KEY")!,
new OpenAIClientOptions().UseJsonConsoleLogging());
For a Grok client with search-enabled, a request would look like the following:
Both alternatives receive an optional JsonConsoleOptions
instance to configure
the output, including truncating or wrapping long messages, setting panel style,
and more.
The chat pipeline logging is added similar to other pipeline extensions:
IChatClient client = new GrokClient(Env.Get("XAI_API_KEY")!)
.AsBuilder()
.UseOpenTelemetry()
// other extensions...
.UseJsonConsoleLogging(new JsonConsoleOptions()
{
// Formatting options...
Border = BoxBorder.None,
WrapLength = 80,
})
.Build();
Sponsors
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.AI (>= 9.6.0)
- Microsoft.Extensions.AI.OpenAI (>= 9.6.0-preview.1.25310.2)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.6)
- OpenAI (>= 2.2.0-beta.4)
- Spectre.Console (>= 0.50.0)
- Spectre.Console.Json (>= 0.50.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Devlooped.Extensions.AI:
Package | Downloads |
---|---|
Smith
Run AI-powered C# files using Microsoft.Extensions.AI and Devlooped.Extensions.AI |
GitHub repositories
This package is not used by any popular GitHub repositories.