Moving the copilot-sdk cookbook content in here

This commit is contained in:
Aaron Powell
2026-01-29 14:29:36 +11:00
parent ccdfd66cc2
commit f59e0b4080
53 changed files with 5385 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
#:package GitHub.Copilot.SDK@*
#:property PublishAot=false
using GitHub.Copilot.SDK;
await using var client = new CopilotClient();
await client.StartAsync();
// Create session with a memorable ID
var session = await client.CreateSessionAsync(new SessionConfig
{
SessionId = "user-123-conversation",
Model = "gpt-5"
});
await session.SendAsync(new MessageOptions { Prompt = "Let's discuss TypeScript generics" });
Console.WriteLine($"Session created: {session.SessionId}");
// Destroy session but keep data on disk
await session.DisposeAsync();
Console.WriteLine("Session destroyed (state persisted)");
// Resume the previous session
var resumed = await client.ResumeSessionAsync("user-123-conversation");
Console.WriteLine($"Resumed: {resumed.SessionId}");
await resumed.SendAsync(new MessageOptions { Prompt = "What were we discussing?" });
// List sessions
var sessions = await client.ListSessionsAsync();
Console.WriteLine("Sessions: " + string.Join(", ", sessions.Select(s => s.SessionId)));
// Delete session permanently
await client.DeleteSessionAsync("user-123-conversation");
Console.WriteLine("Session deleted");
await resumed.DisposeAsync();
await client.StopAsync();