Skip to content

Instantly share code, notes, and snippets.

View wullemsb's full-sized avatar

Wullems Bart wullemsb

View GitHub Profile
session.On<AssistantMessageDeltaEvent>(evt =>
{
if(!string.IsNullOrEmpty(delta.Data?.DeltaContent))
channel.Writer.TryWrite(delta.Data.DeltaContent);
});
session.On<SessionIdleEvent>(evt= >
{
channel.Writer.TryComplete();
});
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;
#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
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:
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,
});
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,
});
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
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,
});
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}.";
}
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"),