This commit is contained in:
Adrien Bouvais 2024-05-25 17:50:27 +02:00
parent a4a528b6ca
commit 459746144e
3 changed files with 12 additions and 13 deletions

View File

@ -163,6 +163,7 @@ func GenerateMultipleMessagesHandler(c *fiber.Ctx) error {
FILTER .id = <uuid>$0;
`, &message, messageID)
if err != nil {
fmt.Println("Panic here but why ?")
panic(err)
}

View File

@ -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 = <uuid>"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)
}

View File

@ -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'));
}