mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-21 10:55:13 +00:00
All 5 Go recipes and their markdown docs used incorrect API patterns that don't match the real github.com/github/copilot-sdk/go v0.1.23: - copilot.NewClient() -> copilot.NewClient(nil) (*ClientOptions param) - client.Start() -> client.Start(ctx) (context.Context required) - copilot.SessionConfig -> &copilot.SessionConfig (pointer required) - session.On(func(event copilot.Event)) -> session.On(func(event copilot.SessionEvent)) - Type assertions -> event.Type string check + *event.Data.Content deref - session.WaitForIdle() -> session.SendAndWait(ctx, ...) (WaitForIdle doesn't exist) - copilot.SystemMessage -> copilot.SystemMessageConfig All 5 recipes verified to compile against SDK v0.1.23.
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
|
|
copilot "github.com/github/copilot-sdk/go"
|
|
)
|
|
|
|
func main() {
|
|
ctx := context.Background()
|
|
client := copilot.NewClient(nil)
|
|
|
|
if err := client.Start(ctx); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer client.Stop()
|
|
|
|
// Create multiple independent sessions
|
|
session1, err := client.CreateSession(ctx, &copilot.SessionConfig{Model: "gpt-5"})
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer session1.Destroy()
|
|
|
|
session2, err := client.CreateSession(ctx, &copilot.SessionConfig{Model: "gpt-5"})
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer session2.Destroy()
|
|
|
|
session3, err := client.CreateSession(ctx, &copilot.SessionConfig{Model: "claude-sonnet-4.5"})
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer session3.Destroy()
|
|
|
|
fmt.Println("Created 3 independent sessions")
|
|
|
|
// Each session maintains its own conversation history
|
|
session1.Send(ctx, copilot.MessageOptions{Prompt: "You are helping with a Python project"})
|
|
session2.Send(ctx, copilot.MessageOptions{Prompt: "You are helping with a TypeScript project"})
|
|
session3.Send(ctx, copilot.MessageOptions{Prompt: "You are helping with a Go project"})
|
|
|
|
fmt.Println("Sent initial context to all sessions")
|
|
|
|
// Follow-up messages stay in their respective contexts
|
|
session1.Send(ctx, copilot.MessageOptions{Prompt: "How do I create a virtual environment?"})
|
|
session2.Send(ctx, copilot.MessageOptions{Prompt: "How do I set up tsconfig?"})
|
|
session3.Send(ctx, copilot.MessageOptions{Prompt: "How do I initialize a module?"})
|
|
|
|
fmt.Println("Sent follow-up questions to each session")
|
|
fmt.Println("All sessions will be destroyed on exit")
|
|
}
|