fix: make new_conversation to work (#112)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
committed by
GitHub
parent
5fdd464fad
commit
c940141e61
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/mudler/LocalAgent/pkg/xlog"
|
||||
"github.com/mudler/LocalAgent/services/actions"
|
||||
@@ -12,6 +13,7 @@ import (
|
||||
"github.com/mudler/LocalAgent/core/types"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/sashabaranov/go-openai"
|
||||
"github.com/sashabaranov/go-openai/jsonschema"
|
||||
)
|
||||
|
||||
@@ -235,6 +237,43 @@ var _ = Describe("Agent test", func() {
|
||||
|
||||
})
|
||||
|
||||
It("Can initiate conversations", func() {
|
||||
|
||||
message := openai.ChatCompletionMessage{}
|
||||
mu := &sync.Mutex{}
|
||||
agent, err := New(
|
||||
WithLLMAPIURL(apiURL),
|
||||
WithModel(testModel),
|
||||
WithLLMAPIKey(apiKeyURL),
|
||||
WithNewConversationSubscriber(func(m openai.ChatCompletionMessage) {
|
||||
mu.Lock()
|
||||
message = m
|
||||
mu.Unlock()
|
||||
}),
|
||||
WithActions(
|
||||
actions.NewSearch(map[string]string{}),
|
||||
),
|
||||
EnablePlanning,
|
||||
EnableForceReasoning,
|
||||
EnableInitiateConversations,
|
||||
EnableStandaloneJob,
|
||||
EnableHUD,
|
||||
WithPeriodicRuns("1s"),
|
||||
WithPermanentGoal("use the new_conversation tool"),
|
||||
// EnableStandaloneJob,
|
||||
// WithRandomIdentity(),
|
||||
)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
go agent.Run()
|
||||
defer agent.Stop()
|
||||
|
||||
Eventually(func() string {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
return message.Content
|
||||
}, "10m", "10s").ShouldNot(BeEmpty())
|
||||
})
|
||||
|
||||
/*
|
||||
It("it automatically performs things in the background", func() {
|
||||
agent, err := New(
|
||||
|
||||
Reference in New Issue
Block a user