Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
hupe1980 committed Jul 29, 2023
1 parent 34cad6d commit 8f21dc5
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/openai_functions_agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/hupe1980/golc"
"github.com/hupe1980/golc/agent"
"github.com/hupe1980/golc/agent/toolkit"
"github.com/hupe1980/golc/model/chatmodel"
"github.com/hupe1980/golc/toolkit"
"github.com/playwright-community/playwright-go"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/react_description_agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/hupe1980/golc"
"github.com/hupe1980/golc/agent"
"github.com/hupe1980/golc/agent/toolkit"
"github.com/hupe1980/golc/model/llm"
"github.com/hupe1980/golc/toolkit"
"github.com/playwright-community/playwright-go"
)

Expand Down
File renamed without changes.
41 changes: 41 additions & 0 deletions toolkit/browser_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package toolkit

import (
"testing"

"github.com/hupe1980/golc/schema"
"github.com/stretchr/testify/require"
)

// TestNewBrowser tests the creation of a new Browser object
func TestNewBrowser(t *testing.T) {
browser, err := NewBrowser(nil)
require.NoError(t, err)
require.NotNil(t, browser)

// Ensure that the Browser has the expected tools
expectedToolNames := []string{
"CurrentPage",
"NavigateBrowser",
"ExtractText",
}
tools := browser.Tools()
require.Len(t, tools, len(expectedToolNames))

for _, name := range expectedToolNames {
assertToolExists(t, tools, name)
}
}

// assertToolExists checks if a tool with the specified name exists in the list of tools.
func assertToolExists(t *testing.T, tools []schema.Tool, name string) {
t.Helper()

for _, tool := range tools {
if tool.Name() == name {
return // Found the tool
}
}

require.Fail(t, "tool not found: "+name)
}
2 changes: 2 additions & 0 deletions toolkit/toolkit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// package toolkit provides a collection of tools.
package toolkit

0 comments on commit 8f21dc5

Please sign in to comment.