From 0596ea2b1ef4b5898a33c7e35b102dc538b52bde Mon Sep 17 00:00:00 2001 From: John Costa Date: Mon, 14 Apr 2025 10:22:54 +0100 Subject: [PATCH 1/6] debug --- backend/models/user.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/models/user.go b/backend/models/user.go index 3563222..8c370ed 100644 --- a/backend/models/user.go +++ b/backend/models/user.go @@ -90,6 +90,8 @@ func (m UserModel) ListWithProperties(ctx context.Context, userId uuid.UUID) ([] images := []ImageWithProperties{} + fmt.Println(listWithPropertiesStmt.DebugSql()) + err := listWithPropertiesStmt.QueryContext(ctx, m.dbPool, &images) fmt.Println(images) From 1f83b721a666be7643bbf440d94885d8b1d5ddbb Mon Sep 17 00:00:00 2001 From: John Costa Date: Mon, 14 Apr 2025 10:28:31 +0100 Subject: [PATCH 2/6] fix: prompts --- backend/agents/contact_agent.go | 7 ++++--- backend/agents/location_agent.go | 7 ++++--- backend/models/user.go | 3 --- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/backend/agents/contact_agent.go b/backend/agents/contact_agent.go index a649889..3c0fe3a 100644 --- a/backend/agents/contact_agent.go +++ b/backend/agents/contact_agent.go @@ -20,10 +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. Call finish if you dont think theres anything else to do. + +You should not use linkContact if you are not sure the image contains a contact found in listContacts. ` const contactTools = ` diff --git a/backend/agents/location_agent.go b/backend/agents/location_agent.go index 25da2e0..5e56d54 100644 --- a/backend/agents/location_agent.go +++ b/backend/agents/location_agent.go @@ -16,15 +16,16 @@ 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. diff --git a/backend/models/user.go b/backend/models/user.go index 8c370ed..b2d2a55 100644 --- a/backend/models/user.go +++ b/backend/models/user.go @@ -90,11 +90,8 @@ func (m UserModel) ListWithProperties(ctx context.Context, userId uuid.UUID) ([] images := []ImageWithProperties{} - fmt.Println(listWithPropertiesStmt.DebugSql()) - err := listWithPropertiesStmt.QueryContext(ctx, m.dbPool, &images) - fmt.Println(images) if err != nil { return images, err } From 55aa1e67babf2a67a42a3b9ddcaf05dff868d035 Mon Sep 17 00:00:00 2001 From: John Costa Date: Mon, 14 Apr 2025 10:30:21 +0100 Subject: [PATCH 3/6] horrible --- backend/main.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/backend/main.go b/backend/main.go index 63d9c07..9ab0731 100644 --- a/backend/main.go +++ b/backend/main.go @@ -93,19 +93,36 @@ func main() { } 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 +130,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 } } From d7ab3f56dcc5726637bf39db3881465b829327d5 Mon Sep 17 00:00:00 2001 From: John Costa Date: Mon, 14 Apr 2025 10:30:46 +0100 Subject: [PATCH 4/6] stupid --- backend/models/user.go | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/models/user.go b/backend/models/user.go index b2d2a55..4a1f2eb 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" From ecc2da5f8649503da6f41071b90f8ac691aa7d68 Mon Sep 17 00:00:00 2001 From: John Costa Date: Mon, 14 Apr 2025 10:33:56 +0100 Subject: [PATCH 5/6] fix more prompt --- backend/agents/event_agent.go | 4 +++- backend/agents/location_agent.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/agents/event_agent.go b/backend/agents/event_agent.go index a375ea1..4e646ee 100644 --- a/backend/agents/event_agent.go +++ b/backend/agents/event_agent.go @@ -22,7 +22,7 @@ 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. @@ -32,6 +32,8 @@ Links an image to a events. finish Call when there is nothing else to do. + +You should not use linkEvent if you are not sure the image contains an event found in listEvents. ` const eventTools = ` diff --git a/backend/agents/location_agent.go b/backend/agents/location_agent.go index 5e56d54..ec1dca5 100644 --- a/backend/agents/location_agent.go +++ b/backend/agents/location_agent.go @@ -28,10 +28,12 @@ createLocation Use this to create a new location. linkLocation -Links an image to a location. +Links an image to a location, finish Call when there is nothing else to do. + +You should not use linkLocation if you are not sure the image contains a location found in linkLocation. ` const locationTools = ` From 51d36bf15bc7898cd820a0841089bf0bc7c62379 Mon Sep 17 00:00:00 2001 From: John Costa Date: Mon, 14 Apr 2025 10:36:21 +0100 Subject: [PATCH 6/6] more prompt --- backend/agents/contact_agent.go | 8 +++++--- backend/agents/event_agent.go | 5 ++--- backend/agents/location_agent.go | 5 ++--- backend/main.go | 2 -- backend/models/user.go | 1 - 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/backend/agents/contact_agent.go b/backend/agents/contact_agent.go index 3c0fe3a..aa81665 100644 --- a/backend/agents/contact_agent.go +++ b/backend/agents/contact_agent.go @@ -21,10 +21,12 @@ 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. -Call linkContact when you think this image contains an existing contact. -Call finish if you dont think theres anything else to do. -You should not use linkContact if you are not sure the image contains a contact found in listContacts. +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. ` const contactTools = ` diff --git a/backend/agents/event_agent.go b/backend/agents/event_agent.go index 4e646ee..20dadd3 100644 --- a/backend/agents/event_agent.go +++ b/backend/agents/event_agent.go @@ -28,12 +28,11 @@ 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. - -You should not use linkEvent if you are not sure the image contains an event found in listEvents. ` const eventTools = ` diff --git a/backend/agents/location_agent.go b/backend/agents/location_agent.go index ec1dca5..b219449 100644 --- a/backend/agents/location_agent.go +++ b/backend/agents/location_agent.go @@ -28,12 +28,11 @@ createLocation 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. - -You should not use linkLocation if you are not sure the image contains a location found in linkLocation. ` const locationTools = ` diff --git a/backend/main.go b/backend/main.go index 9ab0731..f460bc2 100644 --- a/backend/main.go +++ b/backend/main.go @@ -85,8 +85,6 @@ func main() { return } - fmt.Printf("Returned from DB: %+x\n", images) - type DataType struct { Type string `json:"type"` Data any `json:"data"` diff --git a/backend/models/user.go b/backend/models/user.go index 4a1f2eb..7afeebd 100644 --- a/backend/models/user.go +++ b/backend/models/user.go @@ -88,7 +88,6 @@ 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) if err != nil {