diff --git a/Request.go b/Request.go index b38d7f5..c96a262 100644 --- a/Request.go +++ b/Request.go @@ -163,6 +163,7 @@ func GenerateMultipleMessagesHandler(c *fiber.Ctx) error { FILTER .id = $0; `, &message, messageID) if err != nil { + fmt.Println("Panic here but why ?") panic(err) } diff --git a/database.go b/database.go index aab501a..6529886 100644 --- a/database.go +++ b/database.go @@ -5,7 +5,6 @@ package main import ( "context" - "fmt" "time" "github.com/edgedb/edgedb-go" @@ -140,14 +139,13 @@ func insertArea() (edgedb.UUID, int64) { var inserted struct{ id edgedb.UUID } err := edgeClient.QuerySingle(edgeCtx, ` WITH - positionVar := count((SELECT Area FILTER .conversation = global currentConversation AND .conversation.user = global currentUser)) + 1 + positionVar := count((SELECT Area FILTER .conversation = global currentConversation)) + 1 INSERT Area { position := positionVar, conversation := global currentConversation } `, &inserted) if err != nil { - fmt.Println("Couldn't insert area") panic(err) } @@ -156,7 +154,7 @@ func insertArea() (edgedb.UUID, int64) { SELECT Area { position, } - FILTER .conversation = global currentConversation AND .conversation.user = global currentUser + FILTER .conversation = global currentConversation ORDER BY .position desc LIMIT 1 `, &positionSet) @@ -169,15 +167,15 @@ func insertArea() (edgedb.UUID, int64) { func insertUserMessage(content string) edgedb.UUID { // Insert a new user. - var lastAreaID edgedb.UUID + var lastArea Area err := edgeClient.QuerySingle(edgeCtx, ` SELECT Area { id } - FILTER .conversation = global currentConversation AND .conversation.user = global currentUser - ORDER BY .position desc + FILTER .conversation = global currentConversation + ORDER BY .position DESC LIMIT 1 - `, &lastAreaID) + `, &lastArea) if err != nil { panic(err) } @@ -197,7 +195,7 @@ func insertUserMessage(content string) edgedb.UUID { SELECT LLM FILTER .id = "a32c43ec-12fc-11ef-9dc9-b38e0de8bff0" ) } - `, &inserted, "user", content, lastAreaID) + `, &inserted, "user", content, lastArea.ID) if err != nil { panic(err) } @@ -205,7 +203,7 @@ func insertUserMessage(content string) edgedb.UUID { } func insertBotMessage(content string, selected bool, llmUUID edgedb.UUID) edgedb.UUID { - var lastAreaID edgedb.UUID + var lastArea Area err := edgeClient.QuerySingle(edgeCtx, ` SELECT Area { id @@ -213,7 +211,7 @@ func insertBotMessage(content string, selected bool, llmUUID edgedb.UUID) edgedb FILTER .conversation = global currentConversation AND .conversation.user = global currentUser ORDER BY .position desc LIMIT 1 - `, &lastAreaID) + `, &lastArea) if err != nil { panic(err) } @@ -240,7 +238,7 @@ func insertBotMessage(content string, selected bool, llmUUID edgedb.UUID) edgedb LIMIT 1 ) } - `, &inserted, "bot", llmUUID, content, selected, lastAreaID) + `, &inserted, "bot", llmUUID, content, selected, lastArea.ID) if err != nil { panic(err) } diff --git a/views/partials/popover-models.html b/views/partials/popover-models.html index 73e9288..d49c901 100644 --- a/views/partials/popover-models.html +++ b/views/partials/popover-models.html @@ -212,7 +212,7 @@ function getSelectedModelsIDs() { var selectedModelsIDs = []; - var selectedModels = document.getElementsByClassName('selected'); + var selectedModels = document.getElementsByClassName('selected icon-llm'); for (var i = 0; i < selectedModels.length; i++) { selectedModelsIDs.push(selectedModels[i].getAttribute('data-id')); }