webui, fixes

This commit is contained in:
mudler
2024-04-05 17:14:53 +02:00
parent 32f4e53242
commit 5f29125bbb
13 changed files with 510 additions and 142 deletions

View File

@@ -3,6 +3,7 @@ package agent
import (
"context"
"strings"
"time"
)
type Option func(*options) error
@@ -24,6 +25,7 @@ type options struct {
statefile string
context context.Context
permanentGoal string
periodicRuns time.Duration
// callbacks
reasoningCallback func(ActionCurrentState) bool
@@ -99,6 +101,17 @@ func WithPermanentGoal(goal string) Option {
}
}
func WithPeriodicRuns(duration string) Option {
return func(o *options) error {
t, err := time.ParseDuration(duration)
if err != nil {
o.periodicRuns, _ = time.ParseDuration("1m")
}
o.periodicRuns = t
return nil
}
}
func WithContext(ctx context.Context) Option {
return func(o *options) error {
o.context = ctx