Merge pull request #1296 from trheyi/main
Implement Execute method call in Create function for improved assista…
This commit is contained in:
commit
c8dbf3bc0d
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
|
// Create create a new assistant
|
||||||
func (s *Script) Create(ctx *context.Context, messages []context.Message) (*context.ResponseHookCreate, error) {
|
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
|
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