Created
February 25, 2026 16:49
-
-
Save AlbertoMonteiro/0d73aa30e999c297d313982daa37050f to your computer and use it in GitHub Desktop.
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
| #:package GitHub.Copilot.SDK@0.1.26 | |
| using GitHub.Copilot.SDK; | |
| using Microsoft.Extensions.AI; | |
| using System.ComponentModel; | |
| // Create and start client | |
| await using var client = new CopilotClient(new() { Cwd = Environment.CurrentDirectory }); | |
| await client.StartAsync(); | |
| // Create a session | |
| await using var session = await client.CreateSessionAsync(new SessionConfig | |
| { | |
| Model = "gemini-3-flash-preview", // Your deployment name | |
| Provider = new ProviderConfig | |
| { | |
| Type = "openai", | |
| BaseUrl = "https://generativelanguage.googleapis.com/v1beta/openai/", | |
| WireApi = "completions", // Use "completions" for older models | |
| ApiKey = "TBD" | |
| }, | |
| Tools = [ | |
| AIFunctionFactory.Create( | |
| async ([Description("Issue identifier")] string id) => "hard issue from .NET process", | |
| "lookup_issue", | |
| "Fetch issue details from our tracker"), | |
| ], | |
| WorkingDirectory = Environment.CurrentDirectory | |
| }); | |
| Console.WriteLine("Start to chat"); | |
| var (left, top) = Console.GetCursorPosition(); | |
| Console.SetCursorPosition(left, top + 10); | |
| Console.WriteLine("Press any key to send another message, or Ctrl+C to exit."); | |
| Console.SetCursorPosition(left, top); | |
| while (true) | |
| { | |
| var prompt = Console.ReadLine(); | |
| // Send a message and wait for completion | |
| var response = await session.SendAndWaitAsync(new MessageOptions { Prompt = prompt }); | |
| Console.WriteLine(response?.Data.Content); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment