This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using GitHub.Copilot.SDK; | |
| await using var client = new CopilotClient(); | |
| await client.StartAsync(); | |
| await using var session = await client.CreateSessionAsync(new SessionConfig | |
| { | |
| OnPermissionRequest = async (request, invocation) => | |
| { | |
| // request.Kind — string discriminator for the type of operation being requested: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using GitHub.Copilot.SDK; | |
| await using var client = new CopilotClient(); | |
| await client.StartAsync(); | |
| await using var session = await client.CreateSessionAsync(new SessionConfig | |
| { | |
| OnPermissionRequest = PermissionHandler.ApproveAll, | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using GitHub.Copilot.SDK; | |
| await using var client = new CopilotClient(); | |
| await client.StartAsync(); | |
| var session = await client.CreateSessionAsync(new SessionConfig | |
| { | |
| Model = "gpt-4.1", | |
| OnPermissionRequest = PermissionHandler.ApproveAll, | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using GitHub.Copilot.SDK; | |
| await using var client = new CopilotClient(); | |
| await client.StartAsync(); | |
| var session = await client.CreateSessionAsync(new SessionConfig | |
| { | |
| Model = "gpt-4.1", | |
| OnPermissionRequest = PermissionHandler.ApproveAll, | |
| Streaming = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using GitHub.Copilot.SDK; | |
| await using var client = new CopilotClient(); | |
| await client.StartAsync(); | |
| var session = await client.CreateSessionAsync(new SessionConfig | |
| { | |
| Model = "gpt-4.1" | |
| OnPermissionRequest = PermissionHandler.ApproveAll, | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using GitHub.Copilot.SDK; | |
| using Microsoft.Extensions.AI; | |
| // Define the tool | |
| [AIFunction("get_current_weather", "Gets the current weather for a given city")] | |
| static string GetCurrentWeather(string city) | |
| { | |
| // In a real app, call a weather API here | |
| return $"It's 18°C and partly cloudy in {city}."; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| wait using var client = new CopilotClient(); | |
| await using var session = await client.CreateSessionAsync(new SessionConfig | |
| { | |
| Model = "gpt-5.2-codex", // Your deployment name | |
| Provider = new ProviderConfig | |
| { | |
| Type = "openai", | |
| BaseUrl = "https://your-resource.openai.azure.com/openai/v1/", | |
| WireApi = "responses", // Use "completions" for older models | |
| ApiKey = Environment.GetEnvironmentVariable("FOUNDRY_API_KEY"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var session = await client.CreateSessionAsync(new SessionConfig | |
| { | |
| Model = "gpt-4.1", | |
| OnPermissionRequest = async (request, invocation) => | |
| { | |
| // Approve read operations automatically, prompt for anything else | |
| if (request.Kind == "read") | |
| return new PermissionRequestResult() {Kind=PermissionRequestResultKind.Approved }; | |
| Console.WriteLine("Agent wants to perform: {request.Kind} — {request.Description}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| builder.Services.AddSingleton<CopilotClient>(sp => | |
| { | |
| var clientOptions = new CopilotClientOptions(); | |
| clientOptions.AutoStart=true; | |
| var client = new CopilotClient(clientOptions); | |
| return client; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using GitHub.Copilot.SDK; | |
| await using var client = new CopilotClient(); | |
| await using var session = await client.CreateSessionAsync(new SessionConfig | |
| { | |
| Model = "gpt-4.1", | |
| OnPermissionRequest = PermissionHandler.ApproveAll | |
| }); | |
| var response = await session.SendAndWaitAsync(new MessageOptions { Prompt = "What does this codebase do?" }); |
NewerOlder