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
@@ -59,10 +59,10 @@ func ralphLoop(ctx context.Context, mode string, maxIterations int) error {
|
||||
fmt.Printf("\n=== Iteration %d/%d ===\n", i, maxIterations)
|
||||
|
||||
session, err := client.CreateSession(ctx, &copilot.SessionConfig{
|
||||
Model: "gpt-5.1-codex-mini",
|
||||
Model: "gpt-5.3-codex",
|
||||
WorkingDirectory: cwd,
|
||||
OnPermissionRequest: func(_ copilot.PermissionRequest, _ map[string]string) copilot.PermissionRequestResult {
|
||||
return copilot.PermissionRequestResult{Kind: "approved"}
|
||||
OnPermissionRequest: func(_ copilot.PermissionRequest, _ copilot.PermissionInvocation) (copilot.PermissionRequestResult, error) {
|
||||
return copilot.PermissionRequestResult{Kind: "approved"}, nil
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
@@ -70,17 +70,17 @@ func ralphLoop(ctx context.Context, mode string, maxIterations int) error {
|
||||
}
|
||||
|
||||
// Log tool usage for visibility
|
||||
session.On(func(event copilot.Event) {
|
||||
if toolExecution, ok := event.(copilot.ToolExecutionStartEvent); ok {
|
||||
fmt.Printf(" ⚙ %s\n", toolExecution.Data.ToolName)
|
||||
session.On(func(event copilot.SessionEvent) {
|
||||
if d, ok := event.Data.(*copilot.ToolExecutionStartData); ok {
|
||||
fmt.Printf(" ⚙ %s\n", d.ToolName)
|
||||
}
|
||||
})
|
||||
|
||||
_, err = session.SendAndWait(ctx, copilot.MessageOptions{
|
||||
Prompt: string(prompt),
|
||||
})
|
||||
if destroyErr := session.Destroy(); destroyErr != nil {
|
||||
log.Printf("failed to destroy session on iteration %d: %v", i, destroyErr)
|
||||
if destroyErr := session.Disconnect(); destroyErr != nil {
|
||||
log.Printf("failed to disconnect session on iteration %d: %v", i, destroyErr)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("send failed on iteration %d: %w", i, err)
|
||||
|
||||
Reference in New Issue
Block a user