semantic-kernel
БесплатноБез исполняемых скриптовНе проверенBuild AI applications with Microsoft Semantic Kernel. Create plugins, planners, memory systems, and AI orchestration. Use for enterprise AI integration…
от majiayu000★ 31 звезда на GitHubОб этом скилле
Semantic Kernel
Expert guidance for Microsoft's AI orchestration framework.
Installation
# Python
pip install semantic-kernel
# .NET
dotnet add package Microsoft.SemanticKernel
Quick Start
Python
import asyncio
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
async def main():
# Create kernel
kernel = Kernel()
# Add AI service
kernel.add_service(OpenAIChatCompletion(
service_id="chat",
ai_model_id="gpt-4o",
api_key="your-api-key"
))
# Simple completion
result = await kernel.invoke_prompt("What is the capital of France?")
print(result)
asyncio.run(main())
.NET
using Microsoft.SemanticKernel;
var kernel = Kernel.CreateBuilder()
.AddOpenAIChatCompletion("gpt-4o", "your-api-key")
.Build();
var result = await kernel.InvokePromptAsync("What is the capital of France?");
Console.WriteLine(result);
Plugins
Native Functions (Python)
from semantic_kernel.functions import kernel_function
class MathPlugin:
@kernel_function(name="add", description="Add two numbers")
def add(self, a: float, b: float) -> float:
return a + b
@kernel_function(name="multiply", description="Multiply two numbers")
def multiply(self, a: float, b: float) -> float:
return a * b
@kernel_function(name="calculate_compound_interest")
def compound_interest(
self,
principal: float,
rate: float,
time: float,
n: int = 12
) -> str:
"""Calculate compound interest.
Args:
principal: Initial amount
rate: Annual interest rate (as decimal)
time: Time in years
n: Compounding frequency per year
"""
amount = principal * (1 + rate/n) ** (n * time)
return f"Final amount: ${amount:.2f}"
# Register plugin
kernel.add_plugin(MathPlugin(), plugin_name="math")
# Invoke
result = await kernel.invoke(
plugin_name="math",
function_name="add",
a=5,
b=3
)
Native Functions (.NET)
public class MathPlugin
{
[KernelFunction, Description("Add two numbers")]
public double Add(double a, double b) => a + b;
[KernelFunction, Description("Multiply two numbers")]
public double Multiply(double a, double b) => a * b;
}
// Register
kernel.ImportPluginFromType<MathPlugin>();
// Invoke
var result = await kernel.InvokeAsync("MathPlugin", "Add",
new() { ["a"] = 5, ["b"] = 3 });
Prompt Functions
# Inline prompt
summarize = kernel.add_function(
plugin_name="text",
function_name="summarize",
prompt="""Summarize the following text in 3 sentences:
{{$input}}
Summary:""",
description="Summarize text"
)
result = await kernel.invoke(summarize, input="Long text here...")
# prompts/summarize/config.json
{
"schema": 1,
"name": "summarize",
"description": "Summarize text",
"input_variables": [
{
"name": "input",
"description": "Text to summarize",
"required": true
}
],
"execution_settings": {
"default": {
"max_tokens": 500,
"temperature": 0.3
}
}
}
# prompts/summarize/skprompt.txt
Summarize the following text in 3 sentences:
{{$input}}
Summary:
# Load from directory
kernel.add_plugin(parent_directory="./prompts", plugin_name="text")
Chat Completion
from semantic_kernel.contents import ChatHistory
chat_history = ChatHistory()
chat_history.add_system_message("You are a helpful assistant.")
async def chat(user_input: str):
chat_history.add_user_message(user_input)
result = await kernel.invoke_prompt(
prompt="{{$chat_history}}{{$user_input}}",
chat_history=chat_history,
user_input=user_input
)
chat_history.add_assistant_message(str(result))
return result
response = await chat("Hello, how are you?")
Function Calling
from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior
# Enable auto function calling
execution_settings = OpenAIChatPromptExecutionSettings(
function_choice_behavior=FunctionChoiceBehavior.Auto()
)
# Kernel will automatically call functions when needed
result = await kernel.invoke_prompt(
"What is 25 multiplied by 4?",
settings=execution_settings
)
Planners
Function Calling Stepwise Planner
from semantic_kernel.planners.function_calling_stepwise_planner import (
FunctionCallingStepwisePlanner,
FunctionCallingStepwisePlannerOptions
)
planner = FunctionCallingStepwisePlanner(
service_id="chat",
options=FunctionCallingStepwisePlannerOptions(
max_iterations=10,
max_tokens=4000
)
)
result = await planner.invoke(
kernel,
"Send an email to John about the meeting tomorrow at 3pm"
)
Handlebars Planner
from seman
Установить semantic-kernel в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл semantic-kernel?
Build AI applications with Microsoft Semantic Kernel. Create plugins, planners, memory systems, and AI orchestration. Use for enterprise AI integration, .NET/Python AI development, and LLM application frameworks.
Как установить скилл semantic-kernel?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл semantic-kernel запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic