diff --git a/agent/assistant/hook/create.go b/agent/assistant/hook/create.go index 1d5fec4f..aba8ebcd 100644 --- a/agent/assistant/hook/create.go +++ b/agent/assistant/hook/create.go @@ -4,5 +4,11 @@ import "github.com/yaoapp/yao/agent/context" // Create create a new assistant func (s *Script) Create(ctx *context.Context, messages []context.Message) (*context.ResponseHookCreate, error) { + res, err := s.Execute(ctx, "Create", messages) + if err != nil { + return nil, err + } + + _ = res return &context.ResponseHookCreate{}, nil } diff --git a/agent/assistant/hook/create_test.go b/agent/assistant/hook/create_test.go new file mode 100644 index 00000000..20a33957 --- /dev/null +++ b/agent/assistant/hook/create_test.go @@ -0,0 +1,13 @@ +package hook_test + +import ( + "testing" + + "github.com/yaoapp/yao/agent/testutils" +) + +// TestCreate test the create hook +func TestCreate(t *testing.T) { + testutils.Prepare(t) + defer testutils.Clean(t) +} diff --git a/agent/testutils/testutils.go b/agent/testutils/testutils.go new file mode 100644 index 00000000..5ea25003 --- /dev/null +++ b/agent/testutils/testutils.go @@ -0,0 +1,25 @@ +package testutils + +import ( + "testing" + + "github.com/yaoapp/yao/agent" + "github.com/yaoapp/yao/config" + "github.com/yaoapp/yao/test" +) + +// Prepare prepare the test environment +func Prepare(t *testing.T) { + test.Prepare(t, config.Conf) + + // Load agent + err := agent.Load(config.Conf) + if err != nil { + t.Fatal(err) + } +} + +// Clean clean the test environment +func Clean(t *testing.T) { + test.Clean() +}