File tree Expand file tree Collapse file tree 11 files changed +212
-0
lines changed
Expand file tree Collapse file tree 11 files changed +212
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,15 @@ SDK for programmatic control of GitHub Copilot CLI.
1010dotnet add package GitHub.Copilot.SDK
1111```
1212
13+ ## Run the Sample
14+
15+ Try the interactive chat sample (from the repo root):
16+
17+ ``` bash
18+ cd dotnet/samples
19+ dotnet run
20+ ```
21+
1322## Quick Start
1423
1524``` csharp
Original file line number Diff line number Diff line change 1+ using GitHub . Copilot . SDK ;
2+
3+ await using var client = new CopilotClient ( ) ;
4+ await using var session = await client . CreateSessionAsync ( ) ;
5+
6+ using var _ = session . On ( evt =>
7+ {
8+ if ( evt is AssistantMessageEvent msg )
9+ Console . WriteLine ( $ "\n Assistant: { msg . Data ? . Content } ") ;
10+ else if ( evt is AssistantMessageDeltaEvent delta )
11+ Console . Write ( delta . Data ? . DeltaContent ) ;
12+ } ) ;
13+
14+ Console . WriteLine ( "Chat with Copilot (Ctrl+C to exit)\n " ) ;
15+
16+ while ( true )
17+ {
18+ Console . Write ( "You: " ) ;
19+ var input = Console . ReadLine ( ) ? . Trim ( ) ;
20+ if ( string . IsNullOrEmpty ( input ) ) continue ;
21+
22+ Console . Write ( "Assistant: " ) ;
23+ await session . SendAndWaitAsync ( new MessageOptions { Prompt = input } ) ;
24+ Console . WriteLine ( ) ;
25+ }
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+ <PropertyGroup >
3+ <OutputType >Exe</OutputType >
4+ <TargetFramework >net8.0</TargetFramework >
5+ <ImplicitUsings >enable</ImplicitUsings >
6+ <Nullable >enable</Nullable >
7+ </PropertyGroup >
8+ <ItemGroup >
9+ <ProjectReference Include =" ..\src\GitHub.Copilot.SDK.csproj" />
10+ </ItemGroup >
11+ </Project >
Original file line number Diff line number Diff line change @@ -10,6 +10,15 @@ A Go SDK for programmatic access to the GitHub Copilot CLI.
1010go get github.com/github/copilot-sdk/go
1111```
1212
13+ ## Run the Sample
14+
15+ Try the interactive chat sample (from the repo root):
16+
17+ ``` bash
18+ cd go/samples
19+ go run chat.go
20+ ```
21+
1322## Quick Start
1423
1524``` go
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "bufio"
5+ "context"
6+ "fmt"
7+ "os"
8+ "strings"
9+
10+ "github.com/github/copilot-sdk/go"
11+ )
12+
13+ func main () {
14+ ctx := context .Background ()
15+ client := copilot .NewClient (nil )
16+ if err := client .Start (ctx ); err != nil {
17+ panic (err )
18+ }
19+ defer client .Stop ()
20+
21+ session , err := client .CreateSession (ctx , nil )
22+ if err != nil {
23+ panic (err )
24+ }
25+ defer session .Destroy ()
26+
27+ session .On (func (event copilot.SessionEvent ) {
28+ if event .Type == copilot .AssistantMessage && event .Data .Content != nil {
29+ fmt .Printf ("\n Assistant: %s\n " , * event .Data .Content )
30+ } else if event .Type == copilot .AssistantMessageDelta && event .Data .DeltaContent != nil {
31+ fmt .Print (* event .Data .DeltaContent )
32+ }
33+ })
34+
35+ fmt .Println ("Chat with Copilot (Ctrl+C to exit)\n " )
36+ scanner := bufio .NewScanner (os .Stdin )
37+
38+ for {
39+ fmt .Print ("You: " )
40+ if ! scanner .Scan () {
41+ break
42+ }
43+ input := strings .TrimSpace (scanner .Text ())
44+ if input == "" {
45+ continue
46+ }
47+
48+ fmt .Print ("Assistant: " )
49+ session .SendAndWait (ctx , copilot.MessageOptions {Prompt : input })
50+ fmt .Println ()
51+ }
52+ }
Original file line number Diff line number Diff line change 1+ module github.com/github/copilot-sdk/go/samples
2+
3+ go 1.24
4+
5+ require github.com/github/copilot-sdk/go v0.0.0
6+
7+ require github.com/google/jsonschema-go v0.4.2 // indirect
8+
9+ replace github.com/github/copilot-sdk/go => ../
Original file line number Diff line number Diff line change @@ -10,6 +10,16 @@ TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC.
1010npm install @github/copilot-sdk
1111```
1212
13+ ## Run the Sample
14+
15+ Try the interactive chat sample (from the repo root):
16+
17+ ``` bash
18+ cd nodejs/samples
19+ npm install
20+ npm start
21+ ```
22+
1323## Quick Start
1424
1525``` typescript
Original file line number Diff line number Diff line change 1+ import * as readline from "node:readline" ;
2+ import { CopilotClient , type SessionEvent } from "@github/copilot-sdk" ;
3+
4+ async function main ( ) {
5+ const client = new CopilotClient ( ) ;
6+ const session = await client . createSession ( ) ;
7+
8+ session . on ( ( event : SessionEvent ) => {
9+ if ( event . type === "assistant.message" ) {
10+ console . log ( `\nAssistant: ${ event . data ?. content } ` ) ;
11+ } else if ( event . type === "assistant.message_delta" ) {
12+ process . stdout . write ( event . data ?. delta ?? "" ) ;
13+ }
14+ } ) ;
15+
16+ const rl = readline . createInterface ( { input : process . stdin , output : process . stdout } ) ;
17+ const prompt = ( q : string ) => new Promise < string > ( ( r ) => rl . question ( q , r ) ) ;
18+
19+ console . log ( "Chat with Copilot (Ctrl+C to exit)\n" ) ;
20+
21+ while ( true ) {
22+ const input = await prompt ( "You: " ) ;
23+ if ( ! input . trim ( ) ) continue ;
24+
25+ process . stdout . write ( "Assistant: " ) ;
26+ await session . sendAndWait ( { prompt : input } ) ;
27+ console . log ( ) ;
28+ }
29+ }
30+
31+ main ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " copilot-sdk-sample" ,
3+ "type" : " module" ,
4+ "scripts" : {
5+ "start" : " npx tsx chat.ts"
6+ },
7+ "dependencies" : {
8+ "@github/copilot-sdk" : " file:.."
9+ },
10+ "devDependencies" : {
11+ "tsx" : " ^4.20.6" ,
12+ "@types/node" : " ^22.0.0"
13+ }
14+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,15 @@ pip install -e ".[dev]"
1212uv pip install -e " .[dev]"
1313```
1414
15+ ## Run the Sample
16+
17+ Try the interactive chat sample (from the repo root):
18+
19+ ``` bash
20+ cd python/samples
21+ python chat.py
22+ ```
23+
1524## Quick Start
1625
1726``` python
You can’t perform that action at this time.
0 commit comments