fex
This commit is contained in:
parent
aa41e35cb1
commit
920c34c25c
4
Chat.go
4
Chat.go
@ -196,7 +196,7 @@ func generateWelcomeChatHTML() string {
|
|||||||
|
|
||||||
NextMessages := []TemplateMessage{}
|
NextMessages := []TemplateMessage{}
|
||||||
nextMsg := TemplateMessage{
|
nextMsg := TemplateMessage{
|
||||||
Icon: "bouvai2", // Assuming Icon is a field you want to include from Message
|
Icon: "icons/bouvai2.png", // Assuming Icon is a field you want to include from Message
|
||||||
Content: "<br>" + markdownToHTML(welcomeMessage) + loginButton,
|
Content: "<br>" + markdownToHTML(welcomeMessage) + loginButton,
|
||||||
Hidden: false, // Assuming Hidden is a field you want to include from Message
|
Hidden: false, // Assuming Hidden is a field you want to include from Message
|
||||||
Id: "0",
|
Id: "0",
|
||||||
@ -223,7 +223,7 @@ func generateEnterKeyChatHTML() string {
|
|||||||
|
|
||||||
NextMessages := []TemplateMessage{}
|
NextMessages := []TemplateMessage{}
|
||||||
nextMsg := TemplateMessage{
|
nextMsg := TemplateMessage{
|
||||||
Icon: "bouvai2", // Assuming Icon is a field you want to include from Message
|
Icon: "icons/bouvai2.png", // Assuming Icon is a field you want to include from Message
|
||||||
Content: "<br>" + markdownToHTML(welcomeMessage),
|
Content: "<br>" + markdownToHTML(welcomeMessage),
|
||||||
Hidden: false, // Assuming Hidden is a field you want to include from Message
|
Hidden: false, // Assuming Hidden is a field you want to include from Message
|
||||||
Id: "0",
|
Id: "0",
|
||||||
|
86
Request.go
86
Request.go
@ -147,54 +147,62 @@ func GenerateMultipleMessagesHandler(c *fiber.Ctx) error {
|
|||||||
select {
|
select {
|
||||||
case firstDone <- idx:
|
case firstDone <- idx:
|
||||||
// Generate the HTML content
|
// Generate the HTML content
|
||||||
out := "<div class='message-header'>"
|
outContent := "<div class='message-header'>"
|
||||||
out += "<p>"
|
outContent += "<p>"
|
||||||
out += templateMessage.Name
|
outContent += templateMessage.Name
|
||||||
out += " </p>"
|
outContent += " </p>"
|
||||||
out += "</div>"
|
outContent += "</div>"
|
||||||
out += "<div class='message-body'>"
|
outContent += "<div class='message-body'>"
|
||||||
out += " <ct class='content'>"
|
outContent += " <ct class='content'>"
|
||||||
out += templateMessage.Content
|
outContent += templateMessage.Content
|
||||||
out += " </ct>"
|
outContent += " </ct>"
|
||||||
out += "</div>"
|
outContent += "</div>"
|
||||||
|
|
||||||
go func() {
|
outBtn, err := selectBtnTmpl.Execute(map[string]interface{}{
|
||||||
|
"message": templateMessage,
|
||||||
|
"ConversationAreaId": message.Area.Position,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error in modelSelecBtnTmpl.Execute: in HandleGenerateMultipleMessages 3")
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
outBtn = strings.ReplaceAll(outBtn, "\n", "")
|
||||||
|
|
||||||
// Send Content event
|
outIcon := `<img src="` + selectedLLMs[idx].Model.Company.Icon + `" alt="User Image">`
|
||||||
sseChanel.SendEvent(
|
|
||||||
"swapContent-"+fmt.Sprintf("%d", message.Area.Position),
|
|
||||||
out,
|
|
||||||
)
|
|
||||||
|
|
||||||
out, err := selectBtnTmpl.Execute(map[string]interface{}{
|
sseChanel.SendEvent(
|
||||||
"message": templateMessage,
|
"swapContent-"+fmt.Sprintf("%d", message.Area.Position),
|
||||||
"ConversationAreaId": message.Area.Position,
|
outContent,
|
||||||
})
|
)
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error in modelSelecBtnTmpl.Execute: in HandleGenerateMultipleMessages 3")
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace newline characters to prevent premature termination
|
sseChanel.SendEvent(
|
||||||
out = strings.ReplaceAll(out, "\n", "")
|
"swapSelectionBtn-"+selectedLLMs[idx].ID.String(),
|
||||||
|
outBtn,
|
||||||
|
)
|
||||||
|
|
||||||
// Send Content event
|
sseChanel.SendEvent(
|
||||||
sseChanel.SendEvent(
|
"swapIcon-"+fmt.Sprintf("%d", message.Area.Position),
|
||||||
"swapSelectionBtn-"+selectedLLMs[idx].ID.String(),
|
outIcon,
|
||||||
out,
|
)
|
||||||
)
|
|
||||||
|
|
||||||
// Send Icon Swap event
|
|
||||||
sseChanel.SendEvent(
|
|
||||||
"swapIcon-"+fmt.Sprintf("%d", message.Area.Position),
|
|
||||||
`<img src="`+selectedLLMs[idx].Model.Company.Icon+`" alt="User Image">`,
|
|
||||||
)
|
|
||||||
}()
|
|
||||||
default:
|
default:
|
||||||
|
out, err := selectBtnTmpl.Execute(map[string]interface{}{
|
||||||
|
"message": templateMessage,
|
||||||
|
"ConversationAreaId": message.Area.Position,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error in modelSelecBtnTmpl.Execute: in HandleGenerateMultipleMessages 3")
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace newline characters to prevent premature termination
|
||||||
|
out = strings.ReplaceAll(out, "\n", "")
|
||||||
|
|
||||||
|
fmt.Println("Sending event: swapSelectionBtn-" + templateMessage.ModelID)
|
||||||
|
|
||||||
// Send Content event
|
// Send Content event
|
||||||
sseChanel.SendEvent(
|
sseChanel.SendEvent(
|
||||||
"swapSelectionBtn-"+templateMessage.ModelID,
|
"swapSelectionBtn-"+templateMessage.ModelID,
|
||||||
"New button",
|
out,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ func (app *FiberSSEApp) CreateChannel(name, base string) *FiberSSEChannel {
|
|||||||
newChannel := &FiberSSEChannel{
|
newChannel := &FiberSSEChannel{
|
||||||
Name: name,
|
Name: name,
|
||||||
Base: base,
|
Base: base,
|
||||||
Events: make(chan *FiberSSEEvent),
|
Events: make(chan *FiberSSEEvent, 100),
|
||||||
ParentSSEApp: app,
|
ParentSSEApp: app,
|
||||||
Handlers: make(map[string][]FiberSSEEventHandler),
|
Handlers: make(map[string][]FiberSSEEventHandler),
|
||||||
EventHandlers: make(map[string][]FiberSSEOnEventHandler),
|
EventHandlers: make(map[string][]FiberSSEOnEventHandler),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user