-
Notifications
You must be signed in to change notification settings - Fork 855
Add minimal chat samples for all SDK languages #492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,261
−31
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ee9df36
Add minimal chat samples for all SDK languages
SteveSandersonMS 3d57c5c
Simplify
SteveSandersonMS 9b6fbd8
Simplify
SteveSandersonMS 0cdf409
Fix Python sample event type comparison
SteveSandersonMS f7c7c93
Add CLIArgs option and fix CLI process error reporting in Go SDK
SteveSandersonMS f766aba
Use local CLI path in Go sample
SteveSandersonMS 8d06915
Add Go sample exe to gitignore and fix Python ruff lint
SteveSandersonMS 57535b4
Update .gitignore
SteveSandersonMS 393ef10
Add CLI error reporting tests and fixes for all SDKs
SteveSandersonMS beb427c
Improve Go SDK error propagation and enhance CLI error tests
SteveSandersonMS 2b5cd6c
Simplify CLI error test assertions with specific expected messages
SteveSandersonMS bff6d90
Format Python code
SteveSandersonMS e0e11a1
Fix generic catch clause in .NET test
SteveSandersonMS 8b11a6c
Run gofmt
SteveSandersonMS 3e74ff4
Fix CI test failures for CLI error propagation
SteveSandersonMS dccd8a7
Fix Go stderr capture on Unix: use cmd.Stderr instead of StderrPipe
SteveSandersonMS 66628ea
Fix Go stderr capture: wait for reader goroutine before accessing buffer
SteveSandersonMS 79e22d5
Simplify Go SDK
SteveSandersonMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| using GitHub.Copilot.SDK; | ||
|
|
||
| await using var client = new CopilotClient(); | ||
| await using var session = await client.CreateSessionAsync(); | ||
|
|
||
| using var _ = session.On(evt => | ||
| { | ||
| Console.ForegroundColor = ConsoleColor.Blue; | ||
| switch (evt) | ||
| { | ||
| case AssistantReasoningEvent reasoning: | ||
| Console.WriteLine($"[reasoning: {reasoning.Data.Content}]"); | ||
| break; | ||
| case ToolExecutionStartEvent tool: | ||
| Console.WriteLine($"[tool: {tool.Data.ToolName}]"); | ||
| break; | ||
| } | ||
| Console.ResetColor(); | ||
| }); | ||
|
|
||
| Console.WriteLine("Chat with Copilot (Ctrl+C to exit)\n"); | ||
|
|
||
| while (true) | ||
| { | ||
| Console.Write("You: "); | ||
| var input = Console.ReadLine()?.Trim(); | ||
| if (string.IsNullOrEmpty(input)) continue; | ||
| Console.WriteLine(); | ||
|
|
||
| var reply = await session.SendAndWaitAsync(new MessageOptions { Prompt = input }); | ||
| Console.WriteLine($"\nAssistant: {reply?.Data.Content}\n"); | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="..\src\GitHub.Copilot.SDK.csproj" /> | ||
| </ItemGroup> | ||
| </Project> |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor inconsistency: Missing tool arguments in output
The .NET sample only logs the tool name, while the Node.js, Python, and Go samples all include the tool arguments in their output.
For consistency across all SDK samples, consider adding the arguments:
This would match the pattern in:
`[tool: ${event.data.toolName} ${JSON.stringify(event.data.arguments)}]`f"[tool: {event.data.tool_name} {json.dumps(event.data.arguments)}]"fmt.Sprintf("[tool: %s %s]", *event.Data.ToolName, args)