fix(logger): nil pointer error + log debug level clean

This commit is contained in:
2025-04-17 11:07:37 +01:00
parent 1e5028177f
commit d1fd2aeaf1
4 changed files with 7 additions and 5 deletions

View File

@ -160,8 +160,6 @@ func (client AgentClient) Request(req *AgentRequestBody) (AgentResponse, error)
return AgentResponse{}, errors.New("Unsupported. We currently only accept 1 choice from AI.")
}
client.Log.SetLevel(log.DebugLevel)
msg := agentResponse.Choices[0].Message
if len(msg.Content) > 0 {
@ -229,7 +227,6 @@ func (client *AgentClient) Process(info ToolHandlerInfo, req *AgentRequestBody)
client.Reply = toolCall.Function.Arguments
}
client.Log.SetLevel(log.DebugLevel)
client.Log.Debugf("Response: %s", toolResponse.Content)
req.Chat.AddToolResponse(toolResponse)

View File

@ -116,7 +116,7 @@ func NewEventAgent(log *log.Logger, eventsModel models.EventModel, locationModel
EndToolCall: "finish",
})
locationAgent := NewLocationAgent(log.With("Locations 📍"), locationModel)
locationAgent := NewLocationAgent(log.WithPrefix("Events 📅 > Locations 📍"), locationModel)
locationQuery := "Can you get me the ID of the location present in this image?"
locationAgent.Options.Query = &locationQuery

View File

@ -71,6 +71,7 @@ func (agent NoteAgent) GetNotes(userId uuid.UUID, imageId uuid.UUID, imageName s
func NewNoteAgent(log *log.Logger, noteModel models.NoteModel) NoteAgent {
client := client.CreateAgentClient(client.CreateAgentClientOptions{
SystemPrompt: noteAgentPrompt,
Log: log,
})
agent := NoteAgent{

View File

@ -14,11 +14,15 @@ import (
)
func createLogger(prefix string) *log.Logger {
return log.NewWithOptions(os.Stdout, log.Options{
logger := log.NewWithOptions(os.Stdout, log.Options{
ReportTimestamp: true,
TimeFormat: time.Kitchen,
Prefix: prefix,
})
logger.SetLevel(log.DebugLevel)
return logger
}
func ListenNewImageEvents(db *sql.DB, eventManager *EventManager) {