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

@@ -3,6 +3,7 @@ package agent
import (
"context"
"fmt"
"log/slog"
"os"
"sync"
"time"
@@ -34,6 +35,7 @@ type Agent struct {
selfEvaluationInProgress bool
pause bool
logger *slog.Logger
newConversations chan openai.ChatCompletionMessage
}
@@ -74,12 +76,15 @@ func New(opts ...Option) (*Agent, error) {
}
}
if a.options.debugMode {
fmt.Println("=== Agent in Debug mode ===")
fmt.Println(a.Character.String())
fmt.Println(a.State().String())
fmt.Println("Permanent goal: ", a.options.permanentGoal)
}
var programLevel = new(slog.LevelVar) // Info by default
h := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: programLevel})
a.logger = slog.New(h)
programLevel.Set(a.options.logLevel)
a.logger.Info("Agent in Debug mode", "agent", a.Character.Name)
a.logger.Info("Character", "agent", a.Character.Name, "character", a.Character.String())
a.logger.Info("State", "agent", a.Character.Name, "state", a.State().String())
a.logger.Info("Permanent goal", "agent", a.Character.Name, "goal", a.options.permanentGoal)
return a, nil
}
@@ -107,7 +112,7 @@ func (a *Agent) ConversationChannel() chan openai.ChatCompletionMessage {
func (a *Agent) Ask(opts ...JobOption) *JobResult {
a.StopAction()
j := NewJob(append(opts, WithReasoningCallback(a.options.reasoningCallback), WithResultCallback(a.options.resultCallback))...)
// fmt.Println("Job created", text)
// slog.Info("Job created", text)
a.jobQueue <- j
return j.Result.WaitResult()
}
@@ -165,10 +170,7 @@ func (a *Agent) runAction(chosenAction Action, decisionResult *decisionResult) (
}
}
if a.options.debugMode {
fmt.Println("Action", chosenAction.Definition().Name)
fmt.Println("Result", result)
}
a.logger.Info("Running action", "action", chosenAction.Definition().Name, "agent", a.Character.Name)
if chosenAction.Definition().Name.Is(action.StateActionName) {
// We need to store the result in the state
@@ -198,9 +200,7 @@ func (a *Agent) consumeJob(job *Job, role string) {
a.Unlock()
if paused {
if a.options.debugMode {
fmt.Println("Agent is paused, skipping job")
}
a.logger.Info("Agent is paused, skipping job", "agent", a.Character.Name)
job.Result.Finish(fmt.Errorf("agent is paused"))
return
}
@@ -270,9 +270,8 @@ func (a *Agent) consumeJob(job *Job, role string) {
if userMessage != "" {
results, err := a.options.ragdb.Search(userMessage, a.options.kbResults)
if err != nil {
if a.options.debugMode {
fmt.Println("Error finding similar strings inside KB:", err)
}
a.logger.Info("Error finding similar strings inside KB:", "error", err)
// job.Result.Finish(fmt.Errorf("error finding similar strings inside KB: %w", err))
// return
}
@@ -283,10 +282,8 @@ func (a *Agent) consumeJob(job *Job, role string) {
for _, r := range results {
formatResults += fmt.Sprintf("- %s \n", r)
}
if a.options.debugMode {
fmt.Println("Found similar strings in KB:")
fmt.Println(formatResults)
}
a.logger.Info("Found similar strings in KB", "agent", a.Character.Name, "results", formatResults)
// a.currentConversation = append(a.currentConversation,
// openai.ChatCompletionMessage{
// Role: "system",
@@ -341,9 +338,7 @@ func (a *Agent) consumeJob(job *Job, role string) {
}
if chosenAction.Definition().Name.Is(action.StopActionName) {
if a.options.debugMode {
fmt.Println("LLM decided to stop")
}
a.logger.Info("LLM decided to stop")
job.Result.Finish(nil)
return
}
@@ -362,9 +357,7 @@ func (a *Agent) consumeJob(job *Job, role string) {
return
}
if a.options.debugMode {
fmt.Println("===> Generating parameters for", chosenAction.Definition().Name)
}
a.logger.Info("===> Generating parameters for", "action", chosenAction.Definition().Name)
params, err := a.generateParameters(ctx, pickTemplate, chosenAction, a.currentConversation, reasoning)
if err != nil {
@@ -372,10 +365,8 @@ func (a *Agent) consumeJob(job *Job, role string) {
return
}
if a.options.debugMode {
fmt.Println("===> Generated parameters for", chosenAction.Definition().Name)
fmt.Println(params.actionParams.String())
}
a.logger.Info("===> Generated parameters for", "action", chosenAction.Definition().Name)
a.logger.Info(params.actionParams.String())
if params.actionParams == nil {
job.Result.Finish(fmt.Errorf("no parameters"))
@@ -549,9 +540,7 @@ func (a *Agent) consumeJob(job *Job, role string) {
// If we didn't got any message, we can use the response from the action
if chosenAction.Definition().Name.Is(action.ReplyActionName) && msg.Content == "" {
if a.options.debugMode {
fmt.Println("No output returned from conversation, using the action response as a reply.")
}
a.logger.Info("No output returned from conversation, using the action response as a reply.")
msg.Content = replyResponse.Message
}
@@ -570,9 +559,7 @@ func (a *Agent) periodicallyRun() {
// This would be a special action that would be picked up by the agent
// and would be used to contact the user.
if a.options.debugMode {
fmt.Println("START -- Periodically run is starting")
}
a.logger.Info("START -- Periodically run is starting")
if len(a.CurrentConversation()) != 0 {
// Here the LLM could decide to store some part of the conversation too in the memory
@@ -602,9 +589,8 @@ func (a *Agent) periodicallyRun() {
a.consumeJob(whatNext, SystemRole)
a.ResetConversation()
if a.options.debugMode {
fmt.Println("STOP -- Periodically run is done")
}
a.logger.Info("STOP -- Periodically run is done")
// Save results from state
// a.ResetConversation()

View File

@@ -2,6 +2,7 @@ package agent_test
import (
"fmt"
"log/slog"
"github.com/mudler/local-agent-framework/action"
. "github.com/mudler/local-agent-framework/agent"
@@ -18,13 +19,13 @@ var _ Action = &TestAction{}
var debugOptions = []JobOption{
WithReasoningCallback(func(state ActionCurrentState) bool {
fmt.Println("Reasoning", state)
slog.Info("Reasoning", state)
return true
}),
WithResultCallback(func(state ActionState) {
fmt.Println("Reasoning", state.Reasoning)
fmt.Println("Action", state.Action)
fmt.Println("Result", state.Result)
slog.Info("Reasoning", state.Reasoning)
slog.Info("Action", state.Action)
slog.Info("Result", state.Result)
}),
}
@@ -172,7 +173,6 @@ var _ = Describe("Agent test", func() {
WithLLMAPIURL(apiModel),
WithModel(testModel),
EnableHUD,
DebugMode,
// EnableStandaloneJob,
// WithRandomIdentity(),
WithPermanentGoal("I want to learn to play music"),
@@ -194,16 +194,15 @@ var _ = Describe("Agent test", func() {
WithLLMAPIURL(apiModel),
WithModel(testModel),
EnableHUD,
DebugMode,
EnableStandaloneJob,
WithAgentReasoningCallback(func(state ActionCurrentState) bool {
fmt.Println("Reasoning", state)
slog.Info("Reasoning", state)
return true
}),
WithAgentResultCallback(func(state ActionState) {
fmt.Println("Reasoning", state.Reasoning)
fmt.Println("Action", state.Action)
fmt.Println("Result", state.Result)
slog.Info("Reasoning", state.Reasoning)
slog.Info("Action", state.Action)
slog.Info("Result", state.Result)
}),
WithActions(
&FakeInternetAction{
@@ -230,14 +229,12 @@ var _ = Describe("Agent test", func() {
Expect(err).ToNot(HaveOccurred())
go agent.Run()
defer agent.Stop()
Eventually(func() string {
fmt.Println(agent.State())
return agent.State().Goal
}, "10m", "10s").Should(ContainSubstring("weather"), fmt.Sprint(agent.State()))
Eventually(func() string {
fmt.Println(agent.State())
return agent.State().String()
}, "10m", "10s").Should(ContainSubstring("store"), fmt.Sprint(agent.State()))

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 {

View File

@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"log/slog"
"os"
"path/filepath"
"sync"
@@ -32,7 +33,6 @@ type AgentConfig struct {
Model string `json:"model" form:"model"`
Name string `json:"name" form:"name"`
HUD bool `json:"hud" form:"hud"`
Debug bool `json:"debug" form:"debug"`
StandaloneJob bool `json:"standalone_job" form:"standalone_job"`
RandomIdentity bool `json:"random_identity" form:"random_identity"`
InitiateConversations bool `json:"initiate_conversations" form:"initiate_conversations"`
@@ -175,14 +175,14 @@ func (a *AgentConfig) availableActions(ctx context.Context) []Action {
actions := []Action{}
for _, action := range a.Actions {
fmt.Println("Set Action", action)
slog.Info("Set Action", action)
var config map[string]string
if err := json.Unmarshal([]byte(action.Config), &config); err != nil {
fmt.Println("Error unmarshalling action config", err)
slog.Info("Error unmarshalling action config", err)
continue
}
fmt.Println("Config", config)
slog.Info("Config", config)
switch action.Name {
case ActionSearch:
@@ -218,20 +218,20 @@ func (a *AgentConfig) availableConnectors() []Connector {
connectors := []Connector{}
for _, c := range a.Connector {
fmt.Println("Set Connector", c)
slog.Info("Set Connector", c)
var config map[string]string
if err := json.Unmarshal([]byte(c.Config), &config); err != nil {
fmt.Println("Error unmarshalling connector config", err)
slog.Info("Error unmarshalling connector config", err)
continue
}
fmt.Println("Config", config)
slog.Info("Config", config)
switch c.Type {
case ConnectorTelegram:
cc, err := connector.NewTelegramConnector(config)
if err != nil {
fmt.Println("Error creating telegram connector", err)
slog.Info("Error creating telegram connector", err)
continue
}
@@ -266,15 +266,15 @@ func (a *AgentPool) startAgentWithConfig(name string, config *AgentConfig) error
connectors := config.availableConnectors()
fmt.Println("Creating agent", name)
fmt.Println("Model", model)
fmt.Println("API URL", a.apiURL)
slog.Info("Creating agent", name)
slog.Info("Model", model)
slog.Info("API URL", a.apiURL)
actions := config.availableActions(ctx)
stateFile, characterFile := a.stateFiles(name)
fmt.Println("Actions", actions)
slog.Info("Actions", actions)
opts := []Option{
WithModel(model),
WithLLMAPIURL(a.apiURL),
@@ -288,7 +288,7 @@ func (a *AgentPool) startAgentWithConfig(name string, config *AgentConfig) error
WithCharacterFile(characterFile),
WithRAGDB(a.ragDB),
WithAgentReasoningCallback(func(state ActionCurrentState) bool {
fmt.Println("Reasoning", state.Reasoning)
slog.Info("Reasoning", state.Reasoning)
manager.Send(
NewMessage(
fmt.Sprintf(`Thinking: %s`, htmlIfy(state.Reasoning)),
@@ -311,7 +311,7 @@ func (a *AgentPool) startAgentWithConfig(name string, config *AgentConfig) error
a.agentStatus[name].addResult(state)
a.Unlock()
fmt.Println("Reasoning", state.Reasoning)
slog.Info("Reasoning", state.Reasoning)
text := fmt.Sprintf(`Reasoning: %s
Action taken: %+v
@@ -337,8 +337,8 @@ func (a *AgentPool) startAgentWithConfig(name string, config *AgentConfig) error
if config.HUD {
opts = append(opts, EnableHUD)
}
if config.Debug {
opts = append(opts, DebugMode)
if os.Getenv("DEBUG") != "" {
opts = append(opts, LogLevel(slog.LevelDebug))
}
if config.StandaloneJob {
opts = append(opts, EnableStandaloneJob)
@@ -365,8 +365,7 @@ func (a *AgentPool) startAgentWithConfig(name string, config *AgentConfig) error
opts = append(opts, EnableKnowledgeBaseWithResults(config.KnowledgeBaseResults))
}
fmt.Println("Starting agent", name)
fmt.Printf("Config %+v\n", config)
slog.Info("Starting agent", "name", name, "config", config)
agent, err := New(opts...)
if err != nil {
return err
@@ -377,7 +376,7 @@ func (a *AgentPool) startAgentWithConfig(name string, config *AgentConfig) error
go func() {
if err := agent.Run(); err != nil {
fmt.Println("Agent stop: ", err.Error())
slog.Info("Agent stop: ", err.Error())
}
}()

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"log/slog"
"net/http"
"os"
@@ -53,7 +54,7 @@ func (a *App) KnowledgeBaseFile(db *InMemoryDatabase) func(c *fiber.Ctx) error {
return err
}
fmt.Println("File uploaded to: " + destination)
slog.Info("File uploaded to: " + destination)
fmt.Printf("Payload: %+v\n", payload)
content, err := readPdf(destination) // Read local pdf file
@@ -61,7 +62,7 @@ func (a *App) KnowledgeBaseFile(db *InMemoryDatabase) func(c *fiber.Ctx) error {
panic(err)
}
fmt.Println("Content is", content)
slog.Info("Content is", content)
chunkSize := defaultChunkSize
if payload.ChunkSize > 0 {
chunkSize = payload.ChunkSize
@@ -130,7 +131,7 @@ func (a *App) Notify(pool *AgentPool) func(c *fiber.Ctx) error {
func (a *App) Delete(pool *AgentPool) func(c *fiber.Ctx) error {
return func(c *fiber.Ctx) error {
if err := pool.Remove(c.Params("name")); err != nil {
fmt.Println("Error removing agent", err)
slog.Info("Error removing agent", err)
return c.Status(http.StatusInternalServerError).SendString(err.Error())
}
return c.Redirect("/agents")
@@ -139,7 +140,7 @@ func (a *App) Delete(pool *AgentPool) func(c *fiber.Ctx) error {
func (a *App) Pause(pool *AgentPool) func(c *fiber.Ctx) error {
return func(c *fiber.Ctx) error {
fmt.Println("Pausing agent", c.Params("name"))
slog.Info("Pausing agent", c.Params("name"))
agent := pool.GetAgent(c.Params("name"))
if agent != nil {
agent.Pause()
@@ -217,7 +218,7 @@ func (a *App) ImportAgent(pool *AgentPool) func(c *fiber.Ctx) error {
return err
}
fmt.Println("Importing agent", config.Name)
slog.Info("Importing agent", config.Name)
if config.Name == "" {
c.Status(http.StatusBadRequest).SendString("Name is required")
@@ -257,13 +258,13 @@ func (a *App) Chat(pool *AgentPool) func(c *fiber.Ctx) error {
go func() {
agent := pool.GetAgent(agentName)
if agent == nil {
fmt.Println("Agent not found in pool", c.Params("name"))
slog.Info("Agent not found in pool", c.Params("name"))
return
}
res := agent.Ask(
WithText(query),
)
fmt.Println("response is", res.Response)
slog.Info("response is", res.Response)
manager.Send(
NewMessage(
chatDiv(res.Response, "blue"),

View File

@@ -1,7 +1,7 @@
package connector
import (
"fmt"
"log/slog"
"strings"
"github.com/bwmarrin/discordgo"
@@ -39,7 +39,7 @@ func (d *Discord) Start(a *agent.Agent) {
// Create a new Discord session using the provided bot token.
dg, err := discordgo.New(Token)
if err != nil {
fmt.Println("error creating Discord session,", err)
slog.Info("error creating Discord session,", err)
return
}
@@ -52,7 +52,7 @@ func (d *Discord) Start(a *agent.Agent) {
// Open a websocket connection to Discord and begin listening.
err = dg.Open()
if err != nil {
fmt.Println("error opening connection,", err)
slog.Info("error opening connection,", err)
return
}
@@ -84,7 +84,7 @@ func (d *Discord) messageCreate(a *agent.Agent) func(s *discordgo.Session, m *di
)
_, err := s.ChannelMessageSend(m.ChannelID, job.Response)
if err != nil {
fmt.Println("error sending message,", err)
slog.Info("error sending message,", err)
}
}

View File

@@ -2,6 +2,7 @@ package connector
import (
"fmt"
"log/slog"
"strings"
"time"
@@ -57,7 +58,7 @@ func (g *GithubIssues) Start(a *agent.Agent) {
for {
select {
case <-ticker.C:
fmt.Println("Looking into github issues...")
slog.Info("Looking into github issues...")
g.issuesService()
case <-a.Context().Done():
return
@@ -79,7 +80,7 @@ func (g *GithubIssues) issuesService() {
g.repository,
&github.IssueListByRepoOptions{})
if err != nil {
fmt.Println("Error listing issues", err)
slog.Info("Error listing issues", err)
}
for _, issue := range issues {
// Do something with the issue
@@ -99,7 +100,7 @@ func (g *GithubIssues) issuesService() {
}
if userName == user.GetLogin() {
fmt.Println("Ignoring issue opened by the bot")
slog.Info("Ignoring issue opened by the bot")
continue
}
messages := []openai.ChatCompletionMessage{
@@ -133,7 +134,7 @@ func (g *GithubIssues) issuesService() {
// if last comment is from the user and mentions the bot username, we must answer
if comment.User.GetName() != user.GetLogin() && len(comments)-1 == i {
if strings.Contains(comment.GetBody(), fmt.Sprintf("@%s", user.GetLogin())) {
fmt.Println("Bot was mentioned in the last comment")
slog.Info("Bot was mentioned in the last comment")
mustAnswer = true
}
}
@@ -141,9 +142,9 @@ func (g *GithubIssues) issuesService() {
if len(comments) == 0 || !botAnsweredAlready {
// if no comments, or bot didn't answer yet, we must answer
fmt.Println("No comments, or bot didn't answer yet")
fmt.Println("Comments:", len(comments))
fmt.Println("Bot answered already", botAnsweredAlready)
slog.Info("No comments, or bot didn't answer yet")
slog.Info("Comments:", len(comments))
slog.Info("Bot answered already", botAnsweredAlready)
mustAnswer = true
}
@@ -163,7 +164,7 @@ func (g *GithubIssues) issuesService() {
},
)
if err != nil {
fmt.Println("Error creating comment", err)
slog.Info("Error creating comment", err)
}
}
}

View File

@@ -3,6 +3,7 @@ package connector
import (
"fmt"
"log"
"log/slog"
"os"
"strings"
@@ -60,11 +61,11 @@ func (t *Slack) Start(a *agent.Agent) {
for evt := range client.Events {
switch evt.Type {
case socketmode.EventTypeConnecting:
fmt.Println("Connecting to Slack with Socket Mode...")
slog.Info("Connecting to Slack with Socket Mode...")
case socketmode.EventTypeConnectionError:
fmt.Println("Connection failed. Retrying later...")
slog.Info("Connection failed. Retrying later...")
case socketmode.EventTypeConnected:
fmt.Println("Connected to Slack with Socket Mode.")
slog.Info("Connected to Slack with Socket Mode.")
case socketmode.EventTypeEventsAPI:
eventsAPIEvent, ok := evt.Data.(slackevents.EventsAPIEvent)
if !ok {
@@ -91,7 +92,7 @@ func (t *Slack) Start(a *agent.Agent) {
if t.channelID == "" && !t.alwaysReply || // If we have set alwaysReply and no channelID
t.channelID != ev.Channel { // If we have a channelID and it's not the same as the event channel
// Skip messages from other channels
fmt.Println("Skipping reply to channel", ev.Channel, t.channelID)
slog.Info("Skipping reply to channel", ev.Channel, t.channelID)
continue
}
@@ -123,7 +124,7 @@ func (t *Slack) Start(a *agent.Agent) {
// strip our id from the message
message = strings.ReplaceAll(message, "<@"+b.UserID+"> ", "")
fmt.Println("Message", message)
slog.Info("Message", message)
go func() {
res := a.Ask(

View File

@@ -2,8 +2,8 @@ package main
import (
"embed"
"fmt"
"log"
"log/slog"
"net/http"
"os"
@@ -75,9 +75,9 @@ func main() {
}
if len(db.Database) > 0 && kbdisableIndexing != "true" {
fmt.Println("Loading knowledgebase from disk, to skip run with KBDISABLEINDEX=true")
slog.Info("Loading knowledgebase from disk, to skip run with KBDISABLEINDEX=true")
if err := db.SaveToStore(); err != nil {
fmt.Println("Error storing in the KB", err)
slog.Info("Error storing in the KB", err)
}
}

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"io"
"log/slog"
"net/http"
"os"
"path/filepath"
@@ -120,7 +121,7 @@ func getWebPage(url string) (string, error) {
func Sitemap(url string) (res []string, err error) {
err = sitemap.ParseFromSite(url, func(e sitemap.Entry) error {
fmt.Println("Sitemap page: " + e.GetLocation())
slog.Info("Sitemap page: " + e.GetLocation())
content, err := getWebPage(e.GetLocation())
if err == nil {
res = append(res, content)
@@ -133,10 +134,10 @@ func Sitemap(url string) (res []string, err error) {
func WebsiteToKB(website string, chunkSize int, db *InMemoryDatabase) {
content, err := Sitemap(website)
if err != nil {
fmt.Println("Error walking sitemap for website", err)
slog.Info("Error walking sitemap for website", err)
}
fmt.Println("Found pages: ", len(content))
fmt.Println("ChunkSize: ", chunkSize)
slog.Info("Found pages: ", len(content))
slog.Info("ChunkSize: ", chunkSize)
StringsToKB(db, chunkSize, content...)
}
@@ -144,9 +145,9 @@ func WebsiteToKB(website string, chunkSize int, db *InMemoryDatabase) {
func StringsToKB(db *InMemoryDatabase, chunkSize int, content ...string) {
for _, c := range content {
chunks := splitParagraphIntoChunks(c, chunkSize)
fmt.Println("chunks: ", len(chunks))
slog.Info("chunks: ", len(chunks))
for _, chunk := range chunks {
fmt.Println("Chunk size: ", len(chunk))
slog.Info("Chunk size: ", len(chunk))
db.AddEntry(chunk)
}
@@ -154,7 +155,7 @@ func StringsToKB(db *InMemoryDatabase, chunkSize int, content ...string) {
}
if err := db.SaveToStore(); err != nil {
fmt.Println("Error storing in the KB", err)
slog.Info("Error storing in the KB", err)
}
}

View File

@@ -91,8 +91,6 @@
<input type="text" name="kb_results" id="kb_results" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md bg-gray-700 text-white" placeholder="3">
</div>
<label for="debug" class="block text-lg font-medium text-gray-400">Debug</label>
<input type="checkbox" name="debug" id="debug" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md bg-gray-700 text-white">
<label for="standalone_job" class="block text-lg font-medium text-gray-400">Standalone Job</label>
<input type="checkbox" name="standalone_job" id="standalone_job" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-lg border-gray-300 rounded-md bg-gray-700 text-white">

View File

@@ -3,6 +3,7 @@ package external
import (
"context"
"fmt"
"log/slog"
"strings"
"github.com/google/go-github/v61/github"
@@ -52,7 +53,7 @@ func (g *GithubIssuesLabeler) Run(params action.ActionParams) (string, error) {
labels, _, err := g.client.Issues.AddLabelsToIssue(g.context, result.Owner, result.Repository, result.IssueNumber, []string{result.Label})
//labelsNames := []string{}
for _, l := range labels {
fmt.Println("Label added:", l.Name)
slog.Info("Label added:", l.Name)
//labelsNames = append(labelsNames, l.GetName())
}

View File

@@ -3,6 +3,7 @@ package external
import (
"context"
"fmt"
"log/slog"
"github.com/google/go-github/v61/github"
"github.com/mudler/local-agent-framework/action"
@@ -49,7 +50,7 @@ func (g *GithubIssueSearch) Run(params action.ActionParams) (string, error) {
resultString = fmt.Sprintf("Error listing issues: %v", err)
}
for _, i := range issues.Issues {
fmt.Println("Issue found:", i.GetTitle())
slog.Info("Issue found:", i.GetTitle())
resultString += fmt.Sprintf("Issue found: %s\n", i.GetTitle())
resultString += fmt.Sprintf("URL: %s\n", i.GetHTMLURL())
// resultString += fmt.Sprintf("Body: %s\n", i.GetBody())

3
external/search.go vendored
View File

@@ -2,6 +2,7 @@ package external
import (
"fmt"
"log/slog"
"github.com/mudler/local-agent-framework/action"
"github.com/sap-nocops/duckduckgogo/client"
@@ -20,7 +21,7 @@ func NewSearch(config map[string]string) *SearchAction {
}
}
fmt.Println("Search action with results: ", intResult)
slog.Info("Search action with results: ", intResult)
return &SearchAction{results: intResult}
}