diff --git a/backend/agents/contact_agent.go b/backend/agents/contact_agent.go index a649889..aa81665 100644 --- a/backend/agents/contact_agent.go +++ b/backend/agents/contact_agent.go @@ -20,8 +20,11 @@ You can use tools to achieve your task. You should use listContacts to make sure that you don't create duplicate contacts. -Call createContact when you see there is a new contact on this image. Do not create duplicate contacts. -Or call linkContact when you think this image contains an existing contact. +Call createContact when you see there is a new contact on this image. + +Call linkContact when you think this image contains an existing contact. +Links an image to a contact. Only call this when you know theres a very close match from listContacts. +Otherwise create a new contact. Call finish if you dont think theres anything else to do. ` diff --git a/backend/agents/event_agent.go b/backend/agents/event_agent.go index a375ea1..20dadd3 100644 --- a/backend/agents/event_agent.go +++ b/backend/agents/event_agent.go @@ -22,13 +22,14 @@ This could be a friend suggesting to meet, a conference, or anything that looks There are various tools you can use to perform this task. listEvents -Lists the users already existing events, you should do this before using createEvents to avoid creating duplicates. +Lists the users already existing events. createEvent Use this to create a new events. linkEvent -Links an image to a events. +Links an image to an event. Only call this when you know theres a very close match from listEvents. +Otherwise create a new event. finish Call when there is nothing else to do. diff --git a/backend/agents/location_agent.go b/backend/agents/location_agent.go index 25da2e0..b219449 100644 --- a/backend/agents/location_agent.go +++ b/backend/agents/location_agent.go @@ -16,18 +16,20 @@ import ( const locationPrompt = ` You are an agent. -The user will send you images and you have to identify if they have any location or a place. This could a picture of a real place, an address, or it's name. +The user will send you images and you have to identify if they have any location or a place. +This could a picture of a real place, an address, or it's name. There are various tools you can use to perform this task. listLocations -Lists the users already existing locations, you should do this before using createLocation to avoid creating duplicates. +Lists the users already existing locations. createLocation -Use this to create a new location. Avoid making duplicates and only create a new location if listLocations doesnt contain the location on the image. +Use this to create a new location. linkLocation -Links an image to a location. +Links an image to a location. Only call this when you know theres a very close match from listLocation. +Otherwise create a new location. finish Call when there is nothing else to do. diff --git a/backend/main.go b/backend/main.go index 63d9c07..f460bc2 100644 --- a/backend/main.go +++ b/backend/main.go @@ -85,27 +85,42 @@ func main() { return } - fmt.Printf("Returned from DB: %+x\n", images) - type DataType struct { Type string `json:"type"` Data any `json:"data"` } dataTypes := make([]DataType, 0) + + // lord + // forgive me + idMap := make(map[uuid.UUID]bool) + for _, image := range images { for _, location := range image.Locations { + _, exists := idMap[location.ID] + if exists { + continue + } dataTypes = append(dataTypes, DataType{ Type: "location", Data: location, }) + + idMap[location.ID] = true } for _, event := range image.Events { + _, exists := idMap[event.ID] + if exists { + continue + } dataTypes = append(dataTypes, DataType{ Type: "event", Data: event, }) + + idMap[event.ID] = true } for _, note := range image.Notes { @@ -113,13 +128,20 @@ func main() { Type: "note", Data: note, }) + idMap[note.ID] = true } for _, contact := range image.Contacts { + _, exists := idMap[contact.ID] + if exists { + continue + } + dataTypes = append(dataTypes, DataType{ Type: "contact", Data: contact, }) + idMap[contact.ID] = true } } diff --git a/backend/models/user.go b/backend/models/user.go index 3563222..7afeebd 100644 --- a/backend/models/user.go +++ b/backend/models/user.go @@ -4,7 +4,6 @@ import ( "context" "database/sql" "errors" - "fmt" "log" "screenmark/screenmark/.gen/haystack/haystack/model" . "screenmark/screenmark/.gen/haystack/haystack/table" @@ -89,10 +88,8 @@ func (m UserModel) ListWithProperties(ctx context.Context, userId uuid.UUID) ([] WHERE(UserImages.UserID.EQ(UUID(userId))) images := []ImageWithProperties{} - err := listWithPropertiesStmt.QueryContext(ctx, m.dbPool, &images) - fmt.Println(images) if err != nil { return images, err }