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
| session.On<AssistantMessageDeltaEvent>(evt => | |
| { | |
| if(!string.IsNullOrEmpty(delta.Data?.DeltaContent)) | |
| channel.Writer.TryWrite(delta.Data.DeltaContent); | |
| }); | |
| session.On<SessionIdleEvent>(evt= > | |
| { | |
| channel.Writer.TryComplete(); | |
| }); |
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
| IDisposable? subscription = null; | |
| subscription = session.On(evt => | |
| { | |
| switch (evt) | |
| { | |
| case AssistantMessageDeltaEvent delta | |
| when !string.IsNullOrEmpty(delta.Data?.DeltaContent): | |
| channel.Writer.TryWrite(delta.Data.DeltaContent); | |
| break; |
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
| #Requires -Version 7 | |
| param() | |
| # Force output encoding to UTF-8 without BOM to ensure proper display of special characters in the status line. | |
| $utf8 = New-Object System.Text.UTF8Encoding $false | |
| [Console]::OutputEncoding = $utf8 | |
| $OutputEncoding = $utf8 | |
| $payload = $input | ConvertFrom-Json |
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"), |
NewerOlder