Initiate agents from pool

This commit is contained in:
mudler
2024-04-07 20:13:28 +02:00
parent 23867bf0e6
commit 59b91d1403
3 changed files with 93 additions and 10 deletions

View File

@@ -39,10 +39,7 @@ type Agent struct {
func New(opts ...Option) (*Agent, error) {
options, err := newOptions(opts...)
if err != nil {
if err != nil {
err = fmt.Errorf("failed to set options: %v", err)
}
return nil, err
return nil, fmt.Errorf("failed to set options: %v", err)
}
client := llm.NewClient(options.LLMAPI.APIKey, options.LLMAPI.APIURL)
@@ -126,6 +123,12 @@ func (a *Agent) CurrentConversation() []openai.ChatCompletionMessage {
return a.currentConversation
}
func (a *Agent) SetConversation(conv []openai.ChatCompletionMessage) {
a.Lock()
defer a.Unlock()
a.currentConversation = conv
}
func (a *Agent) ResetConversation() {
a.Lock()
defer a.Unlock()

View File

@@ -94,6 +94,20 @@ func WithLLMAPIURL(url string) Option {
}
}
func WithStateFile(path string) Option {
return func(o *options) error {
o.statefile = path
return nil
}
}
func WithCharacterFile(path string) Option {
return func(o *options) error {
o.characterfile = path
return nil
}
}
func WithLLMAPIKey(key string) Option {
return func(o *options) error {
o.LLMAPI.APIKey = key