Merge pull request #1299 from trheyi/main
Add test for assistant creation and script execution
This commit is contained in:
commit
d385d3bf86
1 changed files with 21 additions and 0 deletions
|
|
@ -1,8 +1,11 @@
|
||||||
package hook_test
|
package hook_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/yaoapp/yao/agent/assistant"
|
||||||
|
agentContext "github.com/yaoapp/yao/agent/context"
|
||||||
"github.com/yaoapp/yao/agent/testutils"
|
"github.com/yaoapp/yao/agent/testutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -10,4 +13,22 @@ import (
|
||||||
func TestCreate(t *testing.T) {
|
func TestCreate(t *testing.T) {
|
||||||
testutils.Prepare(t)
|
testutils.Prepare(t)
|
||||||
defer testutils.Clean(t)
|
defer testutils.Clean(t)
|
||||||
|
|
||||||
|
agent, err := assistant.Get("tests.create")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to get the tests.create assistant: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
if agent.Script == nil {
|
||||||
|
t.Fatalf("The tests.create assistant has no script")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx := &agentContext.Context{
|
||||||
|
Context: context.Background(),
|
||||||
|
ChatID: "chat-test-create-hook",
|
||||||
|
AssistantID: "tests.create",
|
||||||
|
Sid: "test-session-create-hook",
|
||||||
|
}
|
||||||
|
|
||||||
|
agent.Script.Create(ctx, []agentContext.Message{{Role: "user", Content: "Hello, how are you?"}})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue