feat(event-location): communicating using tool calls correctly
This commit is contained in:
@ -182,7 +182,7 @@ func (client AgentClient) Request(req *AgentRequestBody) (AgentResponse, error)
|
|||||||
return agentResponse, nil
|
return agentResponse, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client AgentClient) ToolLoop(info ToolHandlerInfo, req *AgentRequestBody) error {
|
func (client *AgentClient) ToolLoop(info ToolHandlerInfo, req *AgentRequestBody) error {
|
||||||
for {
|
for {
|
||||||
err := client.Process(info, req)
|
err := client.Process(info, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -235,7 +235,7 @@ func (client *AgentClient) Process(info ToolHandlerInfo, req *AgentRequestBody)
|
|||||||
return err
|
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
|
var tools any
|
||||||
err := json.Unmarshal([]byte(client.Options.JsonTools), &tools)
|
err := json.Unmarshal([]byte(client.Options.JsonTools), &tools)
|
||||||
|
|
||||||
|
@ -65,6 +65,11 @@ const eventTools = `
|
|||||||
"endDateTime": {
|
"endDateTime": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The end time as an ISO 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"]
|
"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.
|
// 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)
|
locationAgent.RunAgent(info.UserId, info.ImageId, info.ImageName, *info.Image)
|
||||||
|
|
||||||
|
log.Debugf("Reply from location %s\n", locationAgent.Reply)
|
||||||
return locationAgent.Reply, nil
|
return locationAgent.Reply, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -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.ToolHandler.AddTool("reply", func(info client.ToolHandlerInfo, args string, call client.ToolCall) (any, error) {
|
||||||
agentClient.Log.Debug(args)
|
|
||||||
return "ok", nil
|
return "ok", nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user