logging: pt1

This commit is contained in:
Ettore Di Giacinto
2024-04-15 00:13:10 +02:00
parent ac8f6e94ff
commit f0bc2be678
14 changed files with 118 additions and 126 deletions

View File

@@ -2,6 +2,7 @@ package agent
import (
"context"
"log/slog"
"strings"
"time"
)
@@ -20,16 +21,17 @@ type options struct {
randomIdentity bool
userActions Actions
enableHUD, standaloneJob, showCharacter, enableKB bool
debugMode bool
canStopItself bool
initiateConversations bool
characterfile string
statefile string
context context.Context
permanentGoal string
periodicRuns time.Duration
kbResults int
ragdb RAGDB
logLevel slog.Level
canStopItself bool
initiateConversations bool
characterfile string
statefile string
context context.Context
permanentGoal string
periodicRuns time.Duration
kbResults int
ragdb RAGDB
prompts []PromptBlock
@@ -52,6 +54,7 @@ func defaultOptions() *options {
APIURL: "http://localhost:8080",
Model: "echidna",
},
logLevel: slog.LevelInfo,
character: Character{
Name: "John Doe",
Age: "",
@@ -88,6 +91,13 @@ var CanStopItself = func(o *options) error {
return nil
}
func LogLevel(level slog.Level) Option {
return func(o *options) error {
o.logLevel = level
return nil
}
}
func EnableKnowledgeBaseWithResults(results int) Option {
return func(o *options) error {
o.enableKB = true
@@ -101,11 +111,6 @@ var EnableInitiateConversations = func(o *options) error {
return nil
}
var DebugMode = func(o *options) error {
o.debugMode = true
return nil
}
// EnableStandaloneJob is an option to enable the agent
// to run jobs in the background automatically
var EnableStandaloneJob = func(o *options) error {