fix: run fmt and lint
This commit is contained in:
parent
a849e02917
commit
3d605a4f53
2 changed files with 22 additions and 13 deletions
|
|
@ -33,7 +33,10 @@ func NewGitHubCopilotProvider(uri string, connectMode string, model string) (*Gi
|
||||||
CLIUrl: uri,
|
CLIUrl: uri,
|
||||||
})
|
})
|
||||||
if err := client.Start(context.Background()); err != nil {
|
if err := client.Start(context.Background()); err != nil {
|
||||||
return nil, fmt.Errorf("can't connect to Github Copilot: %w; `https://github.com/github/copilot-sdk/blob/main/docs/getting-started.md#connecting-to-an-external-cli-server` for details", err)
|
return nil, fmt.Errorf(
|
||||||
|
"can't connect to Github Copilot: %w; `https://github.com/github/copilot-sdk/blob/main/docs/getting-started.md#connecting-to-an-external-cli-server` for details",
|
||||||
|
err,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
session, err := client.CreateSession(context.Background(), &copilot.SessionConfig{
|
session, err := client.CreateSession(context.Background(), &copilot.SessionConfig{
|
||||||
|
|
@ -67,7 +70,13 @@ func (p *GitHubCopilotProvider) Close() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *GitHubCopilotProvider) Chat(ctx context.Context, messages []Message, tools []ToolDefinition, model string, options map[string]interface{}) (*LLMResponse, error) {
|
func (p *GitHubCopilotProvider) Chat(
|
||||||
|
ctx context.Context,
|
||||||
|
messages []Message,
|
||||||
|
tools []ToolDefinition,
|
||||||
|
model string,
|
||||||
|
options map[string]any,
|
||||||
|
) (*LLMResponse, error) {
|
||||||
type tempMessage struct {
|
type tempMessage struct {
|
||||||
Role string `json:"role"`
|
Role string `json:"role"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
|
|
@ -104,7 +113,7 @@ func (p *GitHubCopilotProvider) Chat(ctx context.Context, messages []Message, to
|
||||||
Content: content,
|
Content: content,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
func (p *GitHubCopilotProvider) GetDefaultModel() string {
|
|
||||||
|
|
||||||
|
func (p *GitHubCopilotProvider) GetDefaultModel() string {
|
||||||
return "gpt-4.1"
|
return "gpt-4.1"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,14 @@ import (
|
||||||
type mockRegistryTool struct {
|
type mockRegistryTool struct {
|
||||||
name string
|
name string
|
||||||
desc string
|
desc string
|
||||||
params map[string]interface{}
|
params map[string]any
|
||||||
result *ToolResult
|
result *ToolResult
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockRegistryTool) Name() string { return m.name }
|
func (m *mockRegistryTool) Name() string { return m.name }
|
||||||
func (m *mockRegistryTool) Description() string { return m.desc }
|
func (m *mockRegistryTool) Description() string { return m.desc }
|
||||||
func (m *mockRegistryTool) Parameters() map[string]interface{} { return m.params }
|
func (m *mockRegistryTool) Parameters() map[string]any { return m.params }
|
||||||
func (m *mockRegistryTool) Execute(_ context.Context, _ map[string]interface{}) *ToolResult {
|
func (m *mockRegistryTool) Execute(_ context.Context, _ map[string]any) *ToolResult {
|
||||||
return m.result
|
return m.result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ func newMockTool(name, desc string) *mockRegistryTool {
|
||||||
return &mockRegistryTool{
|
return &mockRegistryTool{
|
||||||
name: name,
|
name: name,
|
||||||
desc: desc,
|
desc: desc,
|
||||||
params: map[string]interface{}{"type": "object"},
|
params: map[string]any{"type": "object"},
|
||||||
result: SilentResult("ok"),
|
result: SilentResult("ok"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +109,7 @@ func TestToolRegistry_Execute_Success(t *testing.T) {
|
||||||
r.Register(&mockRegistryTool{
|
r.Register(&mockRegistryTool{
|
||||||
name: "greet",
|
name: "greet",
|
||||||
desc: "says hello",
|
desc: "says hello",
|
||||||
params: map[string]interface{}{},
|
params: map[string]any{},
|
||||||
result: SilentResult("hello"),
|
result: SilentResult("hello"),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -203,7 +203,7 @@ func TestToolRegistry_GetDefinitions(t *testing.T) {
|
||||||
if defs[0]["type"] != "function" {
|
if defs[0]["type"] != "function" {
|
||||||
t.Errorf("expected type 'function', got %v", defs[0]["type"])
|
t.Errorf("expected type 'function', got %v", defs[0]["type"])
|
||||||
}
|
}
|
||||||
fn, ok := defs[0]["function"].(map[string]interface{})
|
fn, ok := defs[0]["function"].(map[string]any)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("expected 'function' key to be a map")
|
t.Fatal("expected 'function' key to be a map")
|
||||||
}
|
}
|
||||||
|
|
@ -217,7 +217,7 @@ func TestToolRegistry_GetDefinitions(t *testing.T) {
|
||||||
|
|
||||||
func TestToolRegistry_ToProviderDefs(t *testing.T) {
|
func TestToolRegistry_ToProviderDefs(t *testing.T) {
|
||||||
r := NewToolRegistry()
|
r := NewToolRegistry()
|
||||||
params := map[string]interface{}{"type": "object", "properties": map[string]interface{}{}}
|
params := map[string]any{"type": "object", "properties": map[string]any{}}
|
||||||
r.Register(&mockRegistryTool{
|
r.Register(&mockRegistryTool{
|
||||||
name: "beta",
|
name: "beta",
|
||||||
desc: "tool B",
|
desc: "tool B",
|
||||||
|
|
@ -310,7 +310,7 @@ func TestToolToSchema(t *testing.T) {
|
||||||
if schema["type"] != "function" {
|
if schema["type"] != "function" {
|
||||||
t.Errorf("expected type 'function', got %v", schema["type"])
|
t.Errorf("expected type 'function', got %v", schema["type"])
|
||||||
}
|
}
|
||||||
fn, ok := schema["function"].(map[string]interface{})
|
fn, ok := schema["function"].(map[string]any)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatal("expected 'function' to be a map")
|
t.Fatal("expected 'function' to be a map")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue