From 8fff043849b5807e50cc62e8880d0e8f2f84222a Mon Sep 17 00:00:00 2001 From: John Costa Date: Thu, 17 Apr 2025 11:15:02 +0100 Subject: [PATCH] feat(event-location): communicating using tool calls correctly --- backend/agents/client/client.go | 4 ++-- backend/agents/event_agent.go | 8 +++++++- backend/agents/location_agent.go | 1 - 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/agents/client/client.go b/backend/agents/client/client.go index 42be680..4186e54 100644 --- a/backend/agents/client/client.go +++ b/backend/agents/client/client.go @@ -182,7 +182,7 @@ func (client AgentClient) Request(req *AgentRequestBody) (AgentResponse, error) return agentResponse, nil } -func (client AgentClient) ToolLoop(info ToolHandlerInfo, req *AgentRequestBody) error { +func (client *AgentClient) ToolLoop(info ToolHandlerInfo, req *AgentRequestBody) error { for { err := client.Process(info, req) if err != nil { @@ -235,7 +235,7 @@ func (client *AgentClient) Process(info ToolHandlerInfo, req *AgentRequestBody) return err } -func (client AgentClient) RunAgent(userId uuid.UUID, imageId uuid.UUID, imageName string, imageData []byte) error { +func (client *AgentClient) RunAgent(userId uuid.UUID, imageId uuid.UUID, imageName string, imageData []byte) error { var tools any err := json.Unmarshal([]byte(client.Options.JsonTools), &tools) diff --git a/backend/agents/event_agent.go b/backend/agents/event_agent.go index e9575a3..b2c73a1 100644 --- a/backend/agents/event_agent.go +++ b/backend/agents/event_agent.go @@ -65,7 +65,12 @@ const eventTools = ` "endDateTime": { "type": "string", "description": "The end time as an ISO string" - } + }, + "locationId": { + "type": "string", + "description": "The UUID of this location. You should use getEventLocationId to get this information, but only if you believe the event contains a location" + + } }, "required": ["name"] } @@ -185,6 +190,7 @@ func NewEventAgent(log *log.Logger, eventsModel models.EventModel, locationModel // TODO: reenable this when I'm creating the agent locally instead of getting it from above. locationAgent.RunAgent(info.UserId, info.ImageId, info.ImageName, *info.Image) + log.Debugf("Reply from location %s\n", locationAgent.Reply) return locationAgent.Reply, nil }) diff --git a/backend/agents/location_agent.go b/backend/agents/location_agent.go index ba24e13..0c5f1e4 100644 --- a/backend/agents/location_agent.go +++ b/backend/agents/location_agent.go @@ -161,7 +161,6 @@ func NewLocationAgent(log *log.Logger, locationModel models.LocationModel) clien }) agentClient.ToolHandler.AddTool("reply", func(info client.ToolHandlerInfo, args string, call client.ToolCall) (any, error) { - agentClient.Log.Debug(args) return "ok", nil })