커널을 빌드하는 방법
의미 체계 커널 SDK를 사용하려면 최소한의 설정이 필요합니다. 자체 AI 에이전트 만들기를 시작하려면 SDK 패키지와 LLM(대규모 언어 모델) 서비스의 엔드포인트만 있으면 됩니다. SDK는 이 엔드포인트를 사용하여 LLM에 연결하고 프롬프트를 실행합니다. 의미 체계 커널 SDK는 HuggingFace, OpenAI, Azure OpenAI LLM을 지원합니다. 이 예제에서는 Azure OpenAI를 사용합니다.
의미 체계 커널 SDK 사용을 시작하는 단계는 다음과 같습니다.
의미 체계 커널 SDK를 설치합니다.
Visual Studio Code에서
dotnet add package Microsoft.SemanticKernel --version 1.30.0명령을 사용할 수 있습니다.Azure Portal로 이동합니다.
아직 없는 경우 새 Azure OpenAI 리소스를 만듭니다.
사용하려는 모델에 대한 배포를 만듭니다.
키 및 엔드포인트를 검색합니다.
커널 작성기 서비스에 키와 엔드포인트를 추가합니다.
using Microsoft.SemanticKernel;
// Populate values from your OpenAI deployment
var modelId = "";
var endpoint = "";
var apiKey = "";
// Create a kernel with Azure OpenAI chat completion
var builder = Kernel.CreateBuilder().AddAzureOpenAIChatCompletion(modelId, endpoint, apiKey);
// Build the kernel
Kernel kernel = builder.Build();
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion
# Populate values from your OpenAI deployment
model_id = ""
endpoint = ""
api_key = ""
# Create a kernel and add Azure OpenAI chat completion
kernel = Kernel()
kernel.add_service(
AzureChatCompletion(
deployment_name=model_id,
endpoint=endpoint,
api_key=api_key
)
)
kernel.add_service(chatcompletion)
다음 연습에서는 고유한 의미 체계 커널 프로젝트를 설정하는 방법을 연습할 수 있습니다.