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)
|
_, 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 := ""
|
out := ""
|
||||||
if with_user_message {
|
if with_user_message {
|
||||||
messageID := insertUserMessage(c, message)
|
messageID := insertUserMessage(c, message)
|
||||||
@ -90,7 +99,12 @@ func GeneratePlaceholderHTML(c *fiber.Ctx, message string, selectedLLMIds []stri
|
|||||||
out += messageOut
|
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
|
out += messageOut
|
||||||
|
|
||||||
// defer sendEvent("hide-placeholder", "")
|
// defer sendEvent("hide-placeholder", "")
|
||||||
@ -104,6 +118,15 @@ func GenerateMultipleMessagesHandler(c *fiber.Ctx) error {
|
|||||||
insertArea(c)
|
insertArea(c)
|
||||||
selectedLLMs := lastSelectedLLMs
|
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
|
// Create a wait group to synchronize the goroutines
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
@ -208,16 +231,17 @@ func GenerateMultipleMessagesHandler(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// I do a ping because of sse size limit
|
// I do a ping because of sse size limit
|
||||||
|
fmt.Println("Sending event: ", "swapContent-"+fmt.Sprintf("%d", message.Area.Position)+"-"+user.ID.String())
|
||||||
sendEvent(
|
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>`,
|
`<hx hx-get="/messageContent?id=`+message.ID.String()+`" hx-trigger="load" hx-swap="outerHTML"></hx>`,
|
||||||
)
|
)
|
||||||
sendEvent(
|
sendEvent(
|
||||||
"swapSelectionBtn-"+selectedLLMs[idx].ID.String(),
|
"swapSelectionBtn-"+selectedLLMs[idx].ID.String()+"-"+user.ID.String(),
|
||||||
outBtn,
|
outBtn,
|
||||||
)
|
)
|
||||||
sendEvent(
|
sendEvent(
|
||||||
"swapIcon-"+fmt.Sprintf("%d", message.Area.Position),
|
"swapIcon-"+fmt.Sprintf("%d", message.Area.Position)+"-"+user.ID.String(),
|
||||||
outIcon,
|
outIcon,
|
||||||
)
|
)
|
||||||
}()
|
}()
|
||||||
@ -237,7 +261,7 @@ func GenerateMultipleMessagesHandler(c *fiber.Ctx) error {
|
|||||||
// Send Content event
|
// Send Content event
|
||||||
go func() {
|
go func() {
|
||||||
sendEvent(
|
sendEvent(
|
||||||
"swapSelectionBtn-"+selectedLLMs[idx].ID.String(),
|
"swapSelectionBtn-"+selectedLLMs[idx].ID.String()+"-"+user.ID.String(),
|
||||||
outBtn,
|
outBtn,
|
||||||
)
|
)
|
||||||
}()
|
}()
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
{% if IsPlaceholder %}
|
{% if IsPlaceholder %}
|
||||||
|
|
||||||
<figure class="image is-48x48 message-icon" style="flex-shrink: 0;"
|
<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 }}">
|
<img src="icons/bouvai2.png" alt="User Image" id="selectedIcon-{{ ConversationAreaId }}">
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
@ -72,7 +72,7 @@
|
|||||||
{% elif IsPlaceholder %}
|
{% elif IsPlaceholder %}
|
||||||
<div class="is-flex is-align-items-start">
|
<div class="is-flex is-align-items-start">
|
||||||
<div class="message-content" id="content-{{ ConversationAreaId }}"
|
<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>
|
<hx hx-trigger="load" hx-get="/generateMultipleMessages" id="generate-multiple-messages"></hx>
|
||||||
<div class='message-header'>
|
<div class='message-header'>
|
||||||
<p>
|
<p>
|
||||||
@ -98,7 +98,8 @@
|
|||||||
|
|
||||||
{% for selectedLLM in SelectedLLMs %}
|
{% for selectedLLM in SelectedLLMs %}
|
||||||
<button disable class="button is-small is-primary message-button is-outlined mr-1"
|
<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">
|
<span class="icon is-small">
|
||||||
<!--img src="icons/{{ selectedLLM.Company }}.png" alt="{{ selectedLLM.Name }}"
|
<!--img src="icons/{{ selectedLLM.Company }}.png" alt="{{ selectedLLM.Name }}"
|
||||||
style="max-height: 100%; max-width: 100%;"-->
|
style="max-height: 100%; max-width: 100%;"-->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user