GitHub Copilot SDKκ° μ μμΌλ‘ 곡κ°λμ΄ λΉ λ₯΄κ² λλ¬λ³Ό μ μλ μν μ½λλ₯Ό μμ±ν΄λ΄€μ΅λλ€. μΆν μ μ λ²μ κΉμ§ μ§μΌλ΄μΌ νκ² μΌλ, μΌλ¨ μ΄ν΄λ³΄κΈ°λ‘λ AOT μ§μλ νκ³ μλ κ²μΌλ‘ 보μ¬μ λ§μ‘±μ€λ½μ΅λλ€. ![]()
GitHub Copilot SDKλ μμ€ν μ μ€μΉλ GitHub Copilot CLIλ₯Ό μ°Ύμμ νμ©νλ λνΌμ΄λ―λ‘ OSμ 무κ΄νκ² μ§μλλ©°, μ격 μλ² ννλ‘λ μ°κ²°μ΄ κ°λ₯ν κ²μΌλ‘ 보μ λλ€.
μλ μ½λλ₯Ό ghcopilot.cs λ‘ μ μ₯νμκ³ , dotnet run ghcopilot.cs λλ chmod +x ghcopilot.cs; ./ghcopilot.cs λͺ
λ Ήμ΄λ‘ μ€ννλ©΄ μ€νν΄λ³Ό μ μμ΅λλ€.
#!/usr/bin/env dotnet
#:package GitHub.Copilot.SDK@0.*
#:property PublishAot=true
using GitHub.Copilot.SDK;
using System.Threading.Tasks;
await using var client = new CopilotClient(new()
{
// Windows κΈ°μ€. Linux, macOSμ κ²½μ° λ€λ₯Έ κ²½λ‘ νμ κΈ°μ€ νμ.
CliPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"Microsoft", "WinGet", "Links", "copilot.exe"),
});
await client.StartAsync();
// Create a session (OnPermissionRequest is required)
await using var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "gpt-5.4",
OnPermissionRequest = PermissionHandler.ApproveAll,
});
// Wait for response using session.idle event
var done = new TaskCompletionSource();
session.On(e =>
{
if (e is AssistantMessageEvent msg)
{
Console.WriteLine(msg.Data.Content);
}
else if (e is SessionIdleEvent)
{
done.SetResult();
}
});
// Send a message and wait for completion
await session.SendAsync(new MessageOptions { Prompt = "What is 2+2?" });
await done.Task;