Implement Execute method call in Create function for improved assistant creation handling

This commit is contained in:
Max 2025-11-13 12:20:27 +08:00
parent 71698b1405
commit 240cddbcaf
3 changed files with 44 additions and 0 deletions

View file

@ -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
}

View file

@ -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)
}

View file

@ -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()
}