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{}
|
||||
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,
|
||||
Hidden: false, // Assuming Hidden is a field you want to include from Message
|
||||
Id: "0",
|
||||
@ -223,7 +223,7 @@ func generateEnterKeyChatHTML() string {
|
||||
|
||||
NextMessages := []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),
|
||||
Hidden: false, // Assuming Hidden is a field you want to include from Message
|
||||
Id: "0",
|
||||
|
86
Request.go
86
Request.go
@ -147,54 +147,62 @@ func GenerateMultipleMessagesHandler(c *fiber.Ctx) error {
|
||||
select {
|
||||
case firstDone <- idx:
|
||||
// Generate the HTML content
|
||||
out := "<div class='message-header'>"
|
||||
out += "<p>"
|
||||
out += templateMessage.Name
|
||||
out += " </p>"
|
||||
out += "</div>"
|
||||
out += "<div class='message-body'>"
|
||||
out += " <ct class='content'>"
|
||||
out += templateMessage.Content
|
||||
out += " </ct>"
|
||||
out += "</div>"
|
||||
outContent := "<div class='message-header'>"
|
||||
outContent += "<p>"
|
||||
outContent += templateMessage.Name
|
||||
outContent += " </p>"
|
||||
outContent += "</div>"
|
||||
outContent += "<div class='message-body'>"
|
||||
outContent += " <ct class='content'>"
|
||||
outContent += templateMessage.Content
|
||||
outContent += " </ct>"
|
||||
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
|
||||
sseChanel.SendEvent(
|
||||
"swapContent-"+fmt.Sprintf("%d", message.Area.Position),
|
||||
out,
|
||||
)
|
||||
outIcon := `<img src="` + selectedLLMs[idx].Model.Company.Icon + `" alt="User Image">`
|
||||
|
||||
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)
|
||||
}
|
||||
sseChanel.SendEvent(
|
||||
"swapContent-"+fmt.Sprintf("%d", message.Area.Position),
|
||||
outContent,
|
||||
)
|
||||
|
||||
// Replace newline characters to prevent premature termination
|
||||
out = strings.ReplaceAll(out, "\n", "")
|
||||
sseChanel.SendEvent(
|
||||
"swapSelectionBtn-"+selectedLLMs[idx].ID.String(),
|
||||
outBtn,
|
||||
)
|
||||
|
||||
// Send Content event
|
||||
sseChanel.SendEvent(
|
||||
"swapSelectionBtn-"+selectedLLMs[idx].ID.String(),
|
||||
out,
|
||||
)
|
||||
|
||||
// Send Icon Swap event
|
||||
sseChanel.SendEvent(
|
||||
"swapIcon-"+fmt.Sprintf("%d", message.Area.Position),
|
||||
`<img src="`+selectedLLMs[idx].Model.Company.Icon+`" alt="User Image">`,
|
||||
)
|
||||
}()
|
||||
sseChanel.SendEvent(
|
||||
"swapIcon-"+fmt.Sprintf("%d", message.Area.Position),
|
||||
outIcon,
|
||||
)
|
||||
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
|
||||
sseChanel.SendEvent(
|
||||
"swapSelectionBtn-"+templateMessage.ModelID,
|
||||
"New button",
|
||||
out,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ func (app *FiberSSEApp) CreateChannel(name, base string) *FiberSSEChannel {
|
||||
newChannel := &FiberSSEChannel{
|
||||
Name: name,
|
||||
Base: base,
|
||||
Events: make(chan *FiberSSEEvent),
|
||||
Events: make(chan *FiberSSEEvent, 100),
|
||||
ParentSSEApp: app,
|
||||
Handlers: make(map[string][]FiberSSEEventHandler),
|
||||
EventHandlers: make(map[string][]FiberSSEOnEventHandler),
|
||||
|
Loading…
x
Reference in New Issue
Block a user