Implement Execute method call in Create function for improved assistant creation handling
This commit is contained in:
parent
71698b1405
commit
240cddbcaf
3 changed files with 44 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
13
agent/assistant/hook/create_test.go
Normal file
13
agent/assistant/hook/create_test.go
Normal 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)
|
||||
}
|
||||
25
agent/testutils/testutils.go
Normal file
25
agent/testutils/testutils.go
Normal 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()
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue