Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ GOLANGCI := $(GOBIN_DIR)/golangci-lint
GOFUMPT := $(GOBIN_DIR)/gofumpt
GOIMPORTS := $(GOBIN_DIR)/goimports
GOVULNCHECK := $(GOBIN_DIR)/govulncheck
OAPICODEGEN := $(GOBIN_DIR)/oapi-codegen

# ---------------------------------------------------------------------------
# Phony declarations (alphabetical).
# ---------------------------------------------------------------------------
.PHONY: all bench boundary-guard build ci clean cover fmt help lint lint-fix \
.PHONY: all bench boundary-guard build ci clean cover fmt gen help lint lint-fix \
security test test-10x test-race tidy version vet

# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -96,7 +97,7 @@ tidy: ## Tidy go.mod / go.sum.
# ---------------------------------------------------------------------------
# Composite gate used by CI and pre-push.
# ---------------------------------------------------------------------------
ci: tidy fmt vet boundary-guard lint test-race security ## Run everything CI runs.
ci: tidy gen fmt vet boundary-guard lint test-race security ## Run everything CI runs.
@echo "All CI checks passed."

# ---------------------------------------------------------------------------
Expand All @@ -107,6 +108,10 @@ version: ## Print the version that will be embedded.
@echo "Commit: $(COMMIT)"
@echo "Date: $(DATE)"

gen: ## Generate code from the OpenAPI spec (requires oapi-codegen).
go generate ./internal/spec/
@echo "Code generation complete."

clean: ## Remove build artefacts.
rm -rf coverage.out coverage.html
go clean -testcache
Expand Down
7 changes: 4 additions & 3 deletions agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestAgent_ChatWithTools(t *testing.T) {
json.NewEncoder(w).Encode(ChatWithToolsResponse{
ChatResponse: ChatResponse{SessionID: "s-tools"},
ToolCalls: []ToolCall{
{ID: "tc-1", Name: "greet", Arguments: `{"name":"world"}`},
{ID: "tc-1", Name: "greet", Arguments: map[string]interface{}{"name": "world"}},
},
})
} else {
Expand All @@ -80,9 +80,10 @@ func TestAgent_ChatWithTools(t *testing.T) {
Description: "Greets someone",
Parameters: json.RawMessage(`{"type":"object","properties":{"name":{"type":"string"}}}`),
},
Run: func(ctx context.Context, args string) (string, error) {
Run: func(ctx context.Context, args map[string]interface{}) (string, error) {
var p struct{ Name string }
json.Unmarshal([]byte(args), &p)
b, _ := json.Marshal(args)
json.Unmarshal(b, &p)
return "Hello, " + p.Name + "!", nil
},
},
Expand Down
4 changes: 2 additions & 2 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func BenchmarkChatWithTools(b *testing.B) {
if round%2 == 1 {
json.NewEncoder(w).Encode(ChatWithToolsResponse{
ChatResponse: ChatResponse{SessionID: "s-1", Response: ""},
ToolCalls: []ToolCall{{ID: "tc-1", Name: "echo", Arguments: `{"msg":"hi"}`}},
ToolCalls: []ToolCall{{ID: "tc-1", Name: "echo", Arguments: map[string]interface{}{"msg": "hi"}}},
FinishReason: "tool_calls",
})
} else {
Expand All @@ -274,7 +274,7 @@ func BenchmarkChatWithTools(b *testing.B) {
tools := []Tool{
{
Schema: ToolSchema{Name: "echo", Description: "echo", Parameters: json.RawMessage(`{"type":"object"}`)},
Run: func(_ context.Context, args string) (string, error) { return "echoed", nil },
Run: func(_ context.Context, args map[string]interface{}) (string, error) { return "echoed", nil },
},
}
ctx := context.Background()
Expand Down
7 changes: 7 additions & 0 deletions codegen_tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build tools

package hawksdk

import (
_ "github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen"
)
25 changes: 25 additions & 0 deletions go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading