mirror of
https://github.com/github/awesome-copilot.git
synced 2026-04-15 20:55:55 +00:00
docs: update go sdk examples (#1393)
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
66a60afe70
commit
aaf86f6055
@@ -39,28 +39,22 @@ func main() {
|
||||
// Create session
|
||||
session, err := client.CreateSession(ctx, &copilot.SessionConfig{
|
||||
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
|
||||
Model: "gpt-5",
|
||||
Model: "gpt-5.4",
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer session.Destroy()
|
||||
defer session.Disconnect()
|
||||
|
||||
// Event handler
|
||||
session.On(func(event copilot.SessionEvent) {
|
||||
switch event.Type {
|
||||
case "assistant.message":
|
||||
if event.Data.Content != nil {
|
||||
fmt.Printf("\nCopilot: %s\n", *event.Data.Content)
|
||||
}
|
||||
case "tool.execution_start":
|
||||
if event.Data.ToolName != nil {
|
||||
fmt.Printf(" → Running: %s\n", *event.Data.ToolName)
|
||||
}
|
||||
case "tool.execution_complete":
|
||||
if event.Data.ToolName != nil {
|
||||
fmt.Printf(" ✓ Completed: %s\n", *event.Data.ToolName)
|
||||
}
|
||||
switch d := event.Data.(type) {
|
||||
case *copilot.AssistantMessageData:
|
||||
fmt.Printf("\nCopilot: %s\n", d.Content)
|
||||
case *copilot.ToolExecutionStartData:
|
||||
fmt.Printf(" → Running: %s\n", d.ToolName)
|
||||
case *copilot.ToolExecutionCompleteData:
|
||||
fmt.Printf(" ✓ Completed (success=%v)\n", d.Success)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user