refactor(tool-calls): to be handled more generally
This commit is contained in:
@ -263,3 +263,27 @@ func (client AgentClient) Request(request *AgentRequestBody) (AgentResponse, err
|
||||
|
||||
return agentResponse, nil
|
||||
}
|
||||
|
||||
func (client AgentClient) Process(info ToolHandlerInfo, request AgentRequestBody) error {
|
||||
var err error
|
||||
|
||||
for err == nil {
|
||||
log.Printf("Latest message: %+v\n", request.AgentMessages.Messages[len(request.AgentMessages.Messages)-1])
|
||||
|
||||
response, requestError := client.Request(&request)
|
||||
if requestError != nil {
|
||||
return requestError
|
||||
}
|
||||
|
||||
log.Println(response)
|
||||
|
||||
a, innerErr := client.ToolHandler.Handle(info, &request)
|
||||
|
||||
err = innerErr
|
||||
|
||||
log.Println(a)
|
||||
log.Println("--------------------------")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -185,28 +185,7 @@ func (agent EventLocationAgent) GetLocations(userId uuid.UUID, imageId uuid.UUID
|
||||
UserId: userId,
|
||||
}
|
||||
|
||||
// TODO: this should go into a loop with toolHandler Handle function and not be here bruh.
|
||||
_, err = agent.toolHandler.Handle(toolHandlerInfo, &request)
|
||||
|
||||
for err == nil {
|
||||
log.Printf("Latest message: %+v\n", request.AgentMessages.Messages[len(request.AgentMessages.Messages)-1])
|
||||
|
||||
response, requestError := agent.client.Request(&request)
|
||||
if requestError != nil {
|
||||
return requestError
|
||||
}
|
||||
|
||||
log.Println(response)
|
||||
|
||||
a, innerErr := agent.toolHandler.Handle(toolHandlerInfo, &request)
|
||||
|
||||
err = innerErr
|
||||
|
||||
log.Println(a)
|
||||
log.Println("--------------------------")
|
||||
}
|
||||
|
||||
return err
|
||||
return agent.client.Process(toolHandlerInfo, request)
|
||||
}
|
||||
|
||||
func NewLocationEventAgent(locationModel models.LocationModel, eventModel models.EventModel, contactModel models.ContactModel) (EventLocationAgent, error) {
|
||||
|
Reference in New Issue
Block a user