wip
This commit is contained in:
@ -19,17 +19,28 @@ Objective: Identify locations from images/text, manage a saved list (create, upd
|
||||
|
||||
Core Logic:
|
||||
|
||||
**Handle Image/Text Location (if no query was handled in Step 2):**
|
||||
* If location details (InputName, InputAddress, etc.) were successfully extracted from the input in Step 1:
|
||||
* Use listLocations to check if a location matching InputName or InputAddress already exists in the saved list.
|
||||
* **If *no match*** is found:
|
||||
* Use createLocation, providing the extracted InputName (required) and any other details like InputAddress.
|
||||
* If no location details could be extracted from the input, use stopAgent.
|
||||
**Extract Location Details:** Attempt to extract location details (like InputName, InputAddress) from the user's input (image or text).
|
||||
* If no details can be extracted, inform the user and use stopAgent.
|
||||
|
||||
**Check for Existing Location:** If details *were* extracted:
|
||||
* Use listLocations with the extracted InputName and/or InputAddress to search for potentially matching locations already saved in the list.
|
||||
|
||||
**Decide Action based on Search Results:**
|
||||
* **If listLocations returns one or more likely matches:**
|
||||
* Identify the *best* match (based on name, address similarity).
|
||||
* **Crucially:** Call upsertLocation, providing the locationId of that best match. Include the newly extracted InputName (required) and any other extracted details (InputAddress, etc.) to potentially *update* the existing record or simply link the current input to it.
|
||||
* **If listLocations returns no matches OR no returned location is a confident match:**
|
||||
* Call upsertLocation providing *only* the newly extracted InputName (required) and any other extracted details (InputAddress, etc.). **Do NOT provide a locationId in this case.** This will create a *new* location entry.
|
||||
|
||||
4. **Finalize:** After successfully calling upsertLocation (or determining no action could be taken), use stopAgent.
|
||||
|
||||
Tool Usage:
|
||||
* listLocations: Check saved locations. Used to find matches for user queries or to detect existing entries before creating/updating. Returns matching location(s) including their locationId.
|
||||
* createLocation: Save a *new* location. Requires name, can include address, etc. You may also use this to update the information in a location, by providing a locationId obtained from listLocations if you believe this location already exists.
|
||||
* stopAgent: Signals the end of the agent's processing for the current turn. Call this *after* providing the summary message.
|
||||
|
||||
* **listLocations**: Searches the saved locations list based on provided criteria (like name or address). Used specifically to check if a location potentially already exists before using upsertLocation. Returns a list of matching locations, *each including its locationId*.
|
||||
* **upsertLocation**: Creates or updates a location in the saved list. Requires name. Can include address, etc.
|
||||
* **To UPDATE:** If you identified an existing location using listLocations, provide its locationId along with any new/updated details (name, address, etc.).
|
||||
* **To CREATE:** If no existing location was found (or you are creating intentionally), provide the location details (name, address, etc.) but **omit the locationId**.
|
||||
* **stopAgent**: Signals the end of the agent's processing for the current turn. Call this *after* completing the location task (create/update/failed extraction).
|
||||
`
|
||||
|
||||
const replyTool = `
|
||||
@ -68,8 +79,8 @@ const locationTools = `
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "createLocation",
|
||||
"description": "Creates a new location entry in the user's saved list. Use only after listLocations confirms the location does not already exist.",
|
||||
"name": "upsertLocation",
|
||||
"description": "Upserts a location. This is used for both creating new locations, and updating existing ones. Providing locationId from an existing ID from listLocations, will make this an update function. Not providing one will create a new location. You must provide a locationId if you think the input is a location that already exists.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -79,7 +90,7 @@ const locationTools = `
|
||||
},
|
||||
"locationId": {
|
||||
"type": "string",
|
||||
"description": "The UUID of the location. You should only provide this IF you believe the contact already exists, from listLocation."
|
||||
"description": "The UUID of the location. You should only provide this IF you believe the location already exists, from listLocation."
|
||||
},
|
||||
"address": {
|
||||
"type": "string",
|
||||
@ -114,14 +125,11 @@ func getLocationAgentTools(allowReply bool) string {
|
||||
}
|
||||
|
||||
type listLocationArguments struct{}
|
||||
type createLocationArguments struct {
|
||||
type upsertLocationArguments struct {
|
||||
Name string `json:"name"`
|
||||
LocationID *string `json:"locationId"`
|
||||
Address *string `json:"address"`
|
||||
}
|
||||
type updateLocationArguments struct {
|
||||
LocationID string `json:"locationId"`
|
||||
}
|
||||
|
||||
func NewLocationAgentWithComm(log *log.Logger, locationModel models.LocationModel) client.AgentClient {
|
||||
client := NewLocationAgent(log, locationModel)
|
||||
@ -143,8 +151,8 @@ func NewLocationAgent(log *log.Logger, locationModel models.LocationModel) clien
|
||||
return locationModel.List(context.Background(), info.UserId)
|
||||
})
|
||||
|
||||
agentClient.ToolHandler.AddTool("createLocation", func(info client.ToolHandlerInfo, _args string, call client.ToolCall) (any, error) {
|
||||
args := createLocationArguments{}
|
||||
agentClient.ToolHandler.AddTool("upsertLocation", func(info client.ToolHandlerInfo, _args string, call client.ToolCall) (any, error) {
|
||||
args := upsertLocationArguments{}
|
||||
err := json.Unmarshal([]byte(_args), &args)
|
||||
if err != nil {
|
||||
return model.Locations{}, err
|
||||
|
@ -114,7 +114,7 @@ func NewOrchestratorAgent(log *log.Logger, noteAgent NoteAgent, contactAgent cli
|
||||
})
|
||||
|
||||
agent.ToolHandler.AddTool("noteAgent", func(info client.ToolHandlerInfo, args string, call client.ToolCall) (any, error) {
|
||||
go noteAgent.GetNotes(info.UserId, info.ImageId, imageName, imageData)
|
||||
// go noteAgent.GetNotes(info.UserId, info.ImageId, imageName, imageData)
|
||||
|
||||
return "noteAgent called successfully", nil
|
||||
})
|
||||
@ -126,13 +126,13 @@ func NewOrchestratorAgent(log *log.Logger, noteAgent NoteAgent, contactAgent cli
|
||||
})
|
||||
|
||||
agent.ToolHandler.AddTool("locationAgent", func(info client.ToolHandlerInfo, args string, call client.ToolCall) (any, error) {
|
||||
go locationAgent.RunAgent(info.UserId, info.ImageId, imageName, imageData)
|
||||
// go locationAgent.RunAgent(info.UserId, info.ImageId, imageName, imageData)
|
||||
|
||||
return "locationAgent called successfully", nil
|
||||
})
|
||||
|
||||
agent.ToolHandler.AddTool("eventAgent", func(info client.ToolHandlerInfo, args string, call client.ToolCall) (any, error) {
|
||||
go eventAgent.RunAgent(info.UserId, info.ImageId, imageName, imageData)
|
||||
// go eventAgent.RunAgent(info.UserId, info.ImageId, imageName, imageData)
|
||||
|
||||
return "eventAgent called successfully", nil
|
||||
})
|
||||
|
@ -31,8 +31,8 @@ func (m EventModel) List(ctx context.Context, userId uuid.UUID) ([]model.Events,
|
||||
func (m EventModel) Save(ctx context.Context, userId uuid.UUID, event model.Events) (model.Events, error) {
|
||||
// TODO tx here
|
||||
insertEventStmt := Events.
|
||||
INSERT(Events.Name, Events.Description, Events.StartDateTime, Events.EndDateTime, Events.LocationID).
|
||||
VALUES(event.Name, event.Description, event.StartDateTime, event.EndDateTime, event.LocationID).
|
||||
INSERT(Events.MutableColumns).
|
||||
MODEL(event).
|
||||
RETURNING(Events.AllColumns)
|
||||
|
||||
insertedEvent := model.Events{}
|
||||
|
Reference in New Issue
Block a user