diff --git a/Request.go b/Request.go index 864b2c4..52783af 100644 --- a/Request.go +++ b/Request.go @@ -83,6 +83,15 @@ func GeneratePlaceholderHTML(c *fiber.Ctx, message string, selectedLLMIds []stri _, position := insertArea(c) + var user User + err := edgeGlobalClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": c.Cookies("jade-edgedb-auth-token")}).QuerySingle(context.Background(), ` + SELECT global currentUser { id } LIMIT 1 + `, &user) + if err != nil { + fmt.Println("Error getting user") + panic(err) + } + out := "" if with_user_message { messageID := insertUserMessage(c, message) @@ -90,7 +99,12 @@ func GeneratePlaceholderHTML(c *fiber.Ctx, message string, selectedLLMIds []stri out += messageOut } - messageOut, _ := botTmpl.Execute(pongo2.Context{"IsPlaceholder": true, "SelectedLLMs": selectedLLMs, "ConversationAreaId": position + 1}) + messageOut, _ := botTmpl.Execute(pongo2.Context{ + "IsPlaceholder": true, + "SelectedLLMs": selectedLLMs, + "ConversationAreaId": position + 1, + "userID": user.ID.String(), + }) out += messageOut // defer sendEvent("hide-placeholder", "") @@ -104,6 +118,15 @@ func GenerateMultipleMessagesHandler(c *fiber.Ctx) error { insertArea(c) selectedLLMs := lastSelectedLLMs + var user User + err := edgeGlobalClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": c.Cookies("jade-edgedb-auth-token")}).QuerySingle(context.Background(), ` + SELECT global currentUser { id } LIMIT 1 + `, &user) + if err != nil { + fmt.Println("Error getting user") + panic(err) + } + // Create a wait group to synchronize the goroutines var wg sync.WaitGroup @@ -208,16 +231,17 @@ func GenerateMultipleMessagesHandler(c *fiber.Ctx) error { go func() { // I do a ping because of sse size limit + fmt.Println("Sending event: ", "swapContent-"+fmt.Sprintf("%d", message.Area.Position)+"-"+user.ID.String()) sendEvent( - "swapContent-"+fmt.Sprintf("%d", message.Area.Position), + "swapContent-"+fmt.Sprintf("%d", message.Area.Position)+"-"+user.ID.String(), ``, ) sendEvent( - "swapSelectionBtn-"+selectedLLMs[idx].ID.String(), + "swapSelectionBtn-"+selectedLLMs[idx].ID.String()+"-"+user.ID.String(), outBtn, ) sendEvent( - "swapIcon-"+fmt.Sprintf("%d", message.Area.Position), + "swapIcon-"+fmt.Sprintf("%d", message.Area.Position)+"-"+user.ID.String(), outIcon, ) }() @@ -237,7 +261,7 @@ func GenerateMultipleMessagesHandler(c *fiber.Ctx) error { // Send Content event go func() { sendEvent( - "swapSelectionBtn-"+selectedLLMs[idx].ID.String(), + "swapSelectionBtn-"+selectedLLMs[idx].ID.String()+"-"+user.ID.String(), outBtn, ) }() diff --git a/views/partials/message-bot.html b/views/partials/message-bot.html index 275c464..48294ae 100644 --- a/views/partials/message-bot.html +++ b/views/partials/message-bot.html @@ -6,7 +6,7 @@ {% if IsPlaceholder %}
+ sse-swap="swapIcon-{{ ConversationAreaId }}-{{ userID }}"> User Image
@@ -72,7 +72,7 @@ {% elif IsPlaceholder %}
+ sse-swap="swapContent-{{ ConversationAreaId }}-{{ userID }}">

@@ -98,7 +98,8 @@ {% for selectedLLM in SelectedLLMs %}