fix: openclaw crash because of empty config

This commit is contained in:
Lixeer
2026-02-15 06:11:07 +08:00
parent 0aab8d8afc
commit 6c392c3387

View File

@@ -5,7 +5,9 @@ import (
"fmt" "fmt"
json "encoding/json" json "encoding/json"
copilot "github.com/github/copilot-sdk/go" copilot "github.com/github/copilot-sdk/go"
) )
type GitHubCopilotProvider struct { type GitHubCopilotProvider struct {
@@ -18,7 +20,9 @@ type GitHubCopilotProvider struct {
func NewGitHubCopilotProvider(uri string, connectMode string, model string) *GitHubCopilotProvider { func NewGitHubCopilotProvider(uri string, connectMode string, model string) *GitHubCopilotProvider {
var session *copilot.Session var session *copilot.Session
if connectMode == "" {
connectMode = "grpc"
}
switch connectMode { switch connectMode {
case "stdio": case "stdio":
@@ -37,6 +41,7 @@ func NewGitHubCopilotProvider(uri string, connectMode string, model string) *Git
}, },
}) })
} }
return &GitHubCopilotProvider{ return &GitHubCopilotProvider{
@@ -66,10 +71,11 @@ func (p *GitHubCopilotProvider) Chat(ctx context.Context, messages []Message, to
fmt.Println("[DEBUG] call p.session.Send")
content,_ := p.session.Send(ctx,copilot.MessageOptions{ content,_ := p.session.Send(ctx,copilot.MessageOptions{
Prompt: string(fullcontent), Prompt: string(fullcontent),
}) })
fmt.Println("[DEBUG] end cal")
return &LLMResponse{ return &LLMResponse{
FinishReason : "stop", FinishReason : "stop",