Maybe instant message
This commit is contained in:
parent
b2dd946917
commit
84f6b9e381
12
Chat.go
12
Chat.go
@ -177,12 +177,12 @@ func generateChatHTML(c *fiber.Ctx) string {
|
||||
}
|
||||
}
|
||||
|
||||
out, err := messageUserPlaceholderTmpl.Execute(pongo2.Context{})
|
||||
if err != nil {
|
||||
fmt.Println("Error executing message user placeholder template")
|
||||
panic(err)
|
||||
}
|
||||
htmlString += out
|
||||
// out, err := messagesPlaceholderTmpl.Execute(pongo2.Context{})
|
||||
// if err != nil {
|
||||
// fmt.Println("Error executing message user placeholder template")
|
||||
// panic(err)
|
||||
// }
|
||||
// htmlString += out
|
||||
|
||||
htmlString += "</div></div>"
|
||||
|
||||
|
@ -93,6 +93,8 @@ func GeneratePlaceholderHTML(c *fiber.Ctx, message string, selectedLLMIds []stri
|
||||
messageOut, _ := botTmpl.Execute(pongo2.Context{"IsPlaceholder": true, "SelectedLLMs": selectedLLMs, "ConversationAreaId": position + 1})
|
||||
out += messageOut
|
||||
|
||||
// defer sendEvent("hide-placeholder", "")
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
|
4
main.go
4
main.go
@ -27,7 +27,7 @@ var (
|
||||
welcomeChatTmpl *pongo2.Template
|
||||
chatInputTmpl *pongo2.Template
|
||||
explainLLMconvChatTmpl *pongo2.Template
|
||||
messageUserPlaceholderTmpl *pongo2.Template
|
||||
messagesPlaceholderTmpl *pongo2.Template
|
||||
clients = make(map[chan SSE]bool)
|
||||
mu sync.Mutex
|
||||
)
|
||||
@ -63,7 +63,7 @@ func main() {
|
||||
welcomeChatTmpl = pongo2.Must(pongo2.FromFile("views/partials/welcome-chat.html"))
|
||||
chatInputTmpl = pongo2.Must(pongo2.FromFile("views/partials/chat-input.html"))
|
||||
explainLLMconvChatTmpl = pongo2.Must(pongo2.FromFile("views/partials/explain-llm-conv-chat.html"))
|
||||
messageUserPlaceholderTmpl = pongo2.Must(pongo2.FromFile("views/partials/message-user-placeholder.html"))
|
||||
messagesPlaceholderTmpl = pongo2.Must(pongo2.FromFile("views/partials/messages-placeholder.html"))
|
||||
|
||||
// Import HTML using django engine/template
|
||||
engine := django.New("./views", ".html")
|
||||
|
@ -27,7 +27,7 @@
|
||||
<button disabled type="submit" class="send-button button is-primary is-small" hx-post="/generatePlaceholder"
|
||||
hx-swap="beforeend" hx-target="#chat-messages" id="chat-input-send-btn" class="chat-input"
|
||||
hx-include="[name='message']" hx-vals="js:{selectedLLMIds: getSelectedModelsIDs()}"
|
||||
onclick="clearTextArea()">
|
||||
onclick="onClickSendButton()">
|
||||
<span class="icon">
|
||||
<i class="fa-solid fa-chevron-right"></i>
|
||||
</span>
|
||||
@ -94,11 +94,11 @@
|
||||
document.getElementById('chat-input-send-btn').disabled = textarea.value.trim().length === 0 || document.getElementsByClassName('selected icon-llm').length === 0 || generateMultipleMessages !== null;
|
||||
}
|
||||
|
||||
function clearTextArea() {
|
||||
function onClickSendButton() {
|
||||
setTimeout(function () {
|
||||
textarea.value = '';
|
||||
toggleSendButton();
|
||||
}, 200);
|
||||
}, 20);
|
||||
}
|
||||
|
||||
function updateIcon(icon, ConversationAreaId) {
|
||||
|
@ -81,6 +81,7 @@
|
||||
</div>
|
||||
<div class="message-body">
|
||||
<div class="content">
|
||||
<br>
|
||||
<img src="/puff.svg" />
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,30 +0,0 @@
|
||||
<div class="message-user mt-3 is-hidden" id="msg-placeholder">
|
||||
<div class="columns is-mobile">
|
||||
<div class="column is-narrow" id="icon-column">
|
||||
<figure class="image is-48x48 message-icon" style="flex-shrink: 0;">
|
||||
<img src="icons/bouvai2.png" alt="User Image">
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
<div class="column" id="content-column" style="width: 100px;">
|
||||
<div class="is-flex is-align-items-start">
|
||||
<div class="message-content" style="width: 100%; overflow-y: hidden;">
|
||||
<div class="message-header">
|
||||
<p>
|
||||
You
|
||||
</p>
|
||||
</div>
|
||||
<div class="message-body">
|
||||
<div class="content" style="overflow-x: auto; width: 100%;" id="content-placeholder">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// When receiving the SSE event
|
||||
</script>
|
58
views/partials/messages-placeholder.html
Normal file
58
views/partials/messages-placeholder.html
Normal file
@ -0,0 +1,58 @@
|
||||
<div class="is-hidden" id="msg-placeholder">
|
||||
<div class="message-user mt-3">
|
||||
<div class="columns is-mobile">
|
||||
<div class="column is-narrow" id="icon-column">
|
||||
<figure class="image is-48x48 message-icon" style="flex-shrink: 0;">
|
||||
<img src="icons/bouvai2.png" alt="User Image">
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
<div class="column" id="content-column" style="width: 100px;">
|
||||
<div class="is-flex is-align-items-start">
|
||||
<div class="message-content" style="width: 100%; overflow-y: hidden;">
|
||||
<div class="message-header">
|
||||
<p>
|
||||
You
|
||||
</p>
|
||||
</div>
|
||||
<div class="message-body">
|
||||
<div class="content" style="overflow-x: auto; width: 100%;" id="content-placeholder">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style='height: 10px;'></div>
|
||||
|
||||
<div class="message-user mt-3">
|
||||
<div class="columns is-mobile">
|
||||
<div class="column is-narrow" id="icon-column">
|
||||
<figure class="image is-48x48 message-icon" style="flex-shrink: 0;">
|
||||
<img src="icons/bouvai2.png" alt="User Image">
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
<div class="column" id="content-column" style="width: 100px;">
|
||||
<div class="is-flex is-align-items-start">
|
||||
<div class="message-content" style="width: 100%; overflow-y: hidden;">
|
||||
<div class="message-header">
|
||||
<p>
|
||||
Waiting...
|
||||
</p>
|
||||
</div>
|
||||
<div class="message-body">
|
||||
<br>
|
||||
<div class="content">
|
||||
<img src="/puff.svg" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user