event for each users
This commit is contained in:
parent
84f6b9e381
commit
cfb7ade6a2
34
Request.go
34
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(),
|
||||
`<hx hx-get="/messageContent?id=`+message.ID.String()+`" hx-trigger="load" hx-swap="outerHTML"></hx>`,
|
||||
)
|
||||
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,
|
||||
)
|
||||
}()
|
||||
|
@ -6,7 +6,7 @@
|
||||
{% if IsPlaceholder %}
|
||||
|
||||
<figure class="image is-48x48 message-icon" style="flex-shrink: 0;"
|
||||
sse-swap="swapIcon-{{ ConversationAreaId }}">
|
||||
sse-swap="swapIcon-{{ ConversationAreaId }}-{{ userID }}">
|
||||
<img src="icons/bouvai2.png" alt="User Image" id="selectedIcon-{{ ConversationAreaId }}">
|
||||
</figure>
|
||||
|
||||
@ -72,7 +72,7 @@
|
||||
{% elif IsPlaceholder %}
|
||||
<div class="is-flex is-align-items-start">
|
||||
<div class="message-content" id="content-{{ ConversationAreaId }}"
|
||||
sse-swap="swapContent-{{ ConversationAreaId }}">
|
||||
sse-swap="swapContent-{{ ConversationAreaId }}-{{ userID }}">
|
||||
<hx hx-trigger="load" hx-get="/generateMultipleMessages" id="generate-multiple-messages"></hx>
|
||||
<div class='message-header'>
|
||||
<p>
|
||||
@ -98,7 +98,8 @@
|
||||
|
||||
{% for selectedLLM in SelectedLLMs %}
|
||||
<button disable class="button is-small is-primary message-button is-outlined mr-1"
|
||||
sse-swap="swapSelectionBtn-{{ selectedLLM.ID.String() }}" hx-swap="outerHTML" hx-target="this">
|
||||
sse-swap="swapSelectionBtn-{{ selectedLLM.ID.String() }}-{{ userID }}" hx-swap="outerHTML"
|
||||
hx-target="this">
|
||||
<span class="icon is-small">
|
||||
<!--img src="icons/{{ selectedLLM.Company }}.png" alt="{{ selectedLLM.Name }}"
|
||||
style="max-height: 100%; max-width: 100%;"-->
|
||||
|
Loading…
x
Reference in New Issue
Block a user