dotnet-ai
БесплатноБез исполняемых скриптовНе проверен.NET AI integration with Microsoft.Extensions.AI, Semantic Kernel, MCP servers, embeddings, vector search, and agent frameworks
от TheLobbi★ 22 звезды на GitHubОб этом скилле
.NET AI Integration
Microsoft.Extensions.AI (Unified AI Abstraction)
The recommended way to integrate AI in .NET apps. Provides a vendor-agnostic abstraction over AI services.
// Install: dotnet add package Microsoft.Extensions.AI
// Provider packages: Microsoft.Extensions.AI.OpenAI, Microsoft.Extensions.AI.AzureAIInference, etc.
using Microsoft.Extensions.AI;
// Register in DI
builder.Services.AddChatClient(new AzureOpenAIClient(
new Uri(builder.Configuration["AI:Endpoint"]!),
new DefaultAzureCredential())
.GetChatClient("gpt-4o"));
// Or with OpenAI directly
builder.Services.AddChatClient(new OpenAIClient(apiKey)
.GetChatClient("gpt-4o"));
Chat Completion
public sealed class ChatService(IChatClient chatClient)
{
public async Task<string> AskAsync(string question, CancellationToken ct)
{
var response = await chatClient.GetResponseAsync(question, cancellationToken: ct);
return response.Text;
}
public async Task<string> AskWithContextAsync(string question, string systemPrompt, CancellationToken ct)
{
var messages = new List<ChatMessage>
{
new(ChatRole.System, systemPrompt),
new(ChatRole.User, question)
};
var response = await chatClient.GetResponseAsync(messages, cancellationToken: ct);
return response.Text;
}
// Streaming
public async IAsyncEnumerable<string> StreamAsync(
string prompt, [EnumeratorCancellation] CancellationToken ct = default)
{
await foreach (var update in chatClient.GetStreamingResponseAsync(prompt, cancellationToken: ct))
{
if (update.Text is not null)
yield return update.Text;
}
}
}
Function Calling (Tool Use) - from official docs
using Microsoft.Extensions.AI;
using OpenAI;
// Build client with function invocation middleware
IChatClient client =
new ChatClientBuilder(new OpenAIClient(key).GetChatClient("gpt-4o").AsIChatClient())
.UseFunctionInvocation() // Auto-invokes local functions
.Build();
// Define tools available to the model
var chatOptions = new ChatOptions
{
Tools = [AIFunctionFactory.Create((string location, string unit) =>
{
return "Periods of rain or drizzle, 15 C";
},
"get_current_weather",
"Gets the current weather in a given location")]
};
// Conversation with automatic tool invocation
List<ChatMessage> chatHistory =
[
new(ChatRole.System, "You are a hiking enthusiast who helps discover fun hikes."),
new(ChatRole.User, "I live in Montreal. What's the current weather like?")
];
ChatResponse response = await client.GetResponseAsync(chatHistory, chatOptions);
Console.WriteLine(response.Text); // Model auto-called get_current_weather
Embeddings
// IEmbeddingGenerator<string, Embedding<float>>
builder.Services.AddEmbeddingGenerator(new AzureOpenAIClient(endpoint, credential)
.GetEmbeddingClient("text-embedding-3-small"));
public sealed class SemanticSearchService(IEmbeddingGenerator<string, Embedding<float>> embedder)
{
public async Task<float[]> GetEmbeddingAsync(string text, CancellationToken ct)
{
var embedding = await embedder.GenerateAsync(text, cancellationToken: ct);
return embedding[0].Vector.ToArray();
}
public async Task<IReadOnlyList<float[]>> GetBatchEmbeddingsAsync(
IEnumerable<string> texts, CancellationToken ct)
{
var embeddings = await embedder.GenerateAsync(texts.ToList(), cancellationToken: ct);
return embeddings.Select(e => e.Vector.ToArray()).ToList();
}
}
Semantic Kernel (AI Orchestration)
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
// Build kernel
var kernel = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion("gpt-4o", endpoint, credential)
.Build();
// Simple prompt
var result = await kernel.InvokePromptAsync("Summarize: {{$input}}", new() { ["input"] = text });
// With plugins
kernel.Plugins.AddFromType<TimePlugin>();
kernel.Plugins.AddFromType<WeatherPlugin>();
// Auto function calling
var settings = new OpenAIPromptExecutionSettings { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() };
var chatService = kernel.GetRequiredService<IChatCompletionService>();
var response = await chatService.GetChatMessageContentAsync("What time is it in London?", settings, kernel);
MCP (Model Context Protocol) in .NET - from official docs
Build MCP Server
# Requires .NET 10.0 SDK
dotnet new install Microsoft.McpServer.ProjectTemplates
dotnet new mcpserver -n MyMcpServer
// Program.cs
using ModelContextProtocol.Server;
using System.ComponentModel;
var hostBuilder = Host.CreateDefaultBuilder(args)
.ConfigureServices((context, services) =>
{
services.AddMcpServer(options =>
{
optio
Установить dotnet-ai в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditGrepBashFAQ
Что делает скилл dotnet-ai?
.NET AI integration with Microsoft.Extensions.AI, Semantic Kernel, MCP servers, embeddings, vector search, and agent frameworks
Как установить скилл dotnet-ai?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл dotnet-ai запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic