more logging
This commit is contained in:
5
Makefile
5
Makefile
@@ -11,4 +11,7 @@ webui:
|
||||
cd example/webui && $(GOCMD) run ./
|
||||
|
||||
webui-image:
|
||||
docker build -t $(IMAGE_NAME) -f Dockerfile.webui .
|
||||
docker build -t $(IMAGE_NAME) -f Dockerfile.webui .
|
||||
|
||||
webui-push:
|
||||
docker push $(IMAGE_NAME)
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/mudler/local-agent-framework/agent"
|
||||
"github.com/mudler/local-agent-framework/xlog"
|
||||
|
||||
. "github.com/mudler/local-agent-framework/agent"
|
||||
@@ -169,6 +170,9 @@ func (a *AgentPool) startAgentWithConfig(name string, config *AgentConfig) error
|
||||
WithContext(ctx),
|
||||
WithPeriodicRuns(config.PeriodicRuns),
|
||||
WithPermanentGoal(config.PermanentGoal),
|
||||
WithCharacter(agent.Character{
|
||||
Name: name,
|
||||
}),
|
||||
WithActions(
|
||||
actions...,
|
||||
),
|
||||
|
||||
@@ -13,6 +13,10 @@ type Discord struct {
|
||||
defaultChannel string
|
||||
}
|
||||
|
||||
// NewDiscord creates a new Discord connector
|
||||
// with the given configuration
|
||||
// - token: Discord token
|
||||
// - defaultChannel: Discord channel to always answer even if not mentioned
|
||||
func NewDiscord(config map[string]string) *Discord {
|
||||
return &Discord{
|
||||
token: config["token"],
|
||||
|
||||
@@ -13,27 +13,40 @@ import (
|
||||
)
|
||||
|
||||
type GithubIssues struct {
|
||||
token string
|
||||
repository string
|
||||
owner string
|
||||
agent *agent.Agent
|
||||
pollInterval time.Duration
|
||||
client *github.Client
|
||||
token string
|
||||
repository string
|
||||
owner string
|
||||
replyIfNoReplies bool
|
||||
agent *agent.Agent
|
||||
pollInterval time.Duration
|
||||
client *github.Client
|
||||
}
|
||||
|
||||
// NewGithubIssueWatcher creates a new GithubIssues connector
|
||||
// with the given configuration
|
||||
// - token: Github token
|
||||
// - repository: Github repository name
|
||||
// - owner: Github repository owner
|
||||
// - replyIfNoReplies: If true, the bot will reply to issues with no comments
|
||||
func NewGithubIssueWatcher(config map[string]string) *GithubIssues {
|
||||
client := github.NewClient(nil).WithAuthToken(config["token"])
|
||||
replyIfNoReplies := false
|
||||
if config["replyIfNoReplies"] == "true" {
|
||||
replyIfNoReplies = true
|
||||
}
|
||||
|
||||
interval, err := time.ParseDuration(config["pollInterval"])
|
||||
if err != nil {
|
||||
interval = 1 * time.Minute
|
||||
interval = 10 * time.Minute
|
||||
}
|
||||
|
||||
return &GithubIssues{
|
||||
client: client,
|
||||
token: config["token"],
|
||||
repository: config["repository"],
|
||||
owner: config["owner"],
|
||||
pollInterval: interval,
|
||||
client: client,
|
||||
token: config["token"],
|
||||
repository: config["repository"],
|
||||
owner: config["owner"],
|
||||
replyIfNoReplies: replyIfNoReplies,
|
||||
pollInterval: interval,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,12 +157,19 @@ func (g *GithubIssues) issuesService() {
|
||||
|
||||
if len(comments) == 0 || !botAnsweredAlready {
|
||||
// if no comments, or bot didn't answer yet, we must answer
|
||||
xlog.Info("No comments, or bot didn't answer yet")
|
||||
xlog.Info("Comments:", len(comments))
|
||||
xlog.Info("Bot answered already", botAnsweredAlready)
|
||||
xlog.Info("No comments, or bot didn't answer yet",
|
||||
"comments", len(comments),
|
||||
"botAnsweredAlready", botAnsweredAlready,
|
||||
"agent", g.agent.Character.Name,
|
||||
)
|
||||
mustAnswer = true
|
||||
}
|
||||
|
||||
if len(comments) != 0 && g.replyIfNoReplies {
|
||||
xlog.Info("Ignoring issue with comments", "issue", issue.GetNumber(), "agent", g.agent.Character.Name)
|
||||
mustAnswer = false
|
||||
}
|
||||
|
||||
if !mustAnswer {
|
||||
continue
|
||||
}
|
||||
@@ -158,7 +178,7 @@ func (g *GithubIssues) issuesService() {
|
||||
agent.WithConversationHistory(messages),
|
||||
)
|
||||
if res.Error != nil {
|
||||
xlog.Error("Error asking", "error", res.Error)
|
||||
xlog.Error("Error asking", "error", res.Error, "agent", g.agent.Character.Name)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -170,7 +190,7 @@ func (g *GithubIssues) issuesService() {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
xlog.Error("Error creating comment", "error", err)
|
||||
xlog.Error("Error creating comment", "error", err, "agent", g.agent.Character.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ func Info(msg string, args ...any) {
|
||||
|
||||
func Debug(msg string, args ...any) {
|
||||
_log(slog.LevelDebug, msg, args...)
|
||||
logger.Debug(msg, args...)
|
||||
}
|
||||
|
||||
func Error(msg string, args ...any) {
|
||||
|
||||
Reference in New Issue
Block a user