mirror of
https://github.com/github/awesome-copilot.git
synced 2026-04-15 12:45:57 +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
@@ -35,12 +35,12 @@ func main() {
|
||||
|
||||
session, err := client.CreateSession(ctx, &copilot.SessionConfig{
|
||||
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
|
||||
Model: "gpt-5",
|
||||
Model: "gpt-5.4",
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create session: %v", err)
|
||||
}
|
||||
defer session.Destroy()
|
||||
defer session.Disconnect()
|
||||
|
||||
result, err := session.SendAndWait(ctx, copilot.MessageOptions{Prompt: "Hello!"})
|
||||
if err != nil {
|
||||
@@ -48,8 +48,10 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
if result != nil && result.Data.Content != nil {
|
||||
fmt.Println(*result.Data.Content)
|
||||
if result != nil {
|
||||
if d, ok := result.Data.(*copilot.AssistantMessageData); ok {
|
||||
fmt.Println(d.Content)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -180,12 +182,12 @@ func doWork() error {
|
||||
|
||||
session, err := client.CreateSession(ctx, &copilot.SessionConfig{
|
||||
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
|
||||
Model: "gpt-5",
|
||||
Model: "gpt-5.4",
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create session: %w", err)
|
||||
}
|
||||
defer session.Destroy()
|
||||
defer session.Disconnect()
|
||||
|
||||
// ... do work ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user