This commit is contained in:
Adrien Bouvais 2024-06-01 20:22:23 +02:00
parent 4660c0db36
commit b4c79167fa
6 changed files with 73 additions and 7 deletions

45
Chat.go
View File

@ -302,6 +302,51 @@ func generateWelcomeChatHTML() string {
return htmlString
}
func generateHelpChatHandler(c *fiber.Ctx) error {
return c.SendString(generateHelpChatHTML())
}
func generateHelpChatHTML() string {
out, err := explainLLMconvChatTmpl.Execute(pongo2.Context{})
if err != nil {
fmt.Println("Error executing explain LLM and Conversation template")
panic(err)
}
htmlString := "<div class='columns is-centered' id='chat-container'><div class='column is-12-mobile is-8-tablet is-6-desktop' id='chat-messages'>"
closeBtn := `
<div class="is-flex is-justify-content-flex-end">
<a class="button is-small is-danger is-outlined" hx-get="/loadChat" hx-target="#chat-container" hx-swap="outerHTML"
hx-trigger="click">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</a>
</div>`
NextMessages := []TemplateMessage{}
nextMsg := TemplateMessage{
Icon: "icons/bouvai2.png", // Assuming Icon is a field you want to include from Message
Content: out + closeBtn,
Hidden: false, // Assuming Hidden is a field you want to include from Message
Id: "0",
Name: "JADE",
}
NextMessages = append(NextMessages, nextMsg)
botOut, err := botTmpl.Execute(pongo2.Context{"Messages": NextMessages, "ConversationAreaId": 0, "NotClickable": true})
if err != nil {
fmt.Println("Error executing bot template")
panic(err)
}
htmlString += botOut
htmlString += "<div style='height: 10px;'></div>"
htmlString += "</div></div>"
// Render the HTML template with the messages
return htmlString
}
func generateEnterKeyChatHTML() string {
welcomeMessage := `
<p class="mt-2">JADE require at least one API key to work. Add one in the settings at the bottom right of the page.</p>

View File

@ -20,7 +20,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/main .
############################
# STEP 2 build a small image
############################
FROM alpine:latest
FROM gcr.io/distroless/static
WORKDIR /

View File

@ -26,6 +26,7 @@ var (
conversationPopoverTmpl *pongo2.Template
welcomeChatTmpl *pongo2.Template
chatInputTmpl *pongo2.Template
explainLLMconvChatTmpl *pongo2.Template
clients = make(map[chan SSE]bool)
mu sync.Mutex
)
@ -60,6 +61,7 @@ func main() {
messageEditTmpl = pongo2.Must(pongo2.FromFile("views/partials/message-edit-form.html"))
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"))
// Import HTML using django engine/template
engine := django.New("./views", ".html")
@ -93,6 +95,7 @@ func main() {
app.Get("/userMessage", GetUserMessageHandler)
app.Post("/editMessage", EditMessageHandler)
app.Post("/archiveDefaultConversation", ArchiveDefaultConversationHandler)
app.Get("/help", generateHelpChatHandler)
// Settings routes
app.Post("/addKeys", addKeys)

View File

@ -0,0 +1 @@
<p>Explain LLM and Conversation</p>

View File

@ -117,6 +117,13 @@
</span>
<span>Terms and conditions</span>
</a>
<a class="button is-small mt-1" hx-get="/help" hx-target="#chat-container" hx-swap="outerHTML"
hx-trigger="click">
<span class="icon is-small">
<i class="fa-solid fa-info"></i>
</span>
<span>Help</span>
</a>
<a class="button is-small mt-1" href="mailto:adrien.bouvais.pro@gmail.com">
<span class="icon is-small">
<i class="fa-solid fa-address-card"></i>

View File

@ -1,10 +1,20 @@
<strong>Welcome to JADE, a chatbot that makes requests to various third-party APIs to provide information and
services.</strong>
<p>So you like chatGPT and want more GPT-4o but don't want to pay 20$/month?.</p>
<p>No fancy stuff, easy to use, pay as you use, multi-models, work on low 3g...</p>
<p><strong>JADE allows you to pay by the token.</strong> So if you use it a little, you pay near nothing.</p>
<p>To start using JADE, please login.</p>
<p>To start using JADE, please sign in.</p>
<a class="button is-primary is-small" href="/signin">
Log in
</a>
Sign in
</a>
<p>You can find more informations about JADE bellow:</p>
<ul>
<li>All Models</li>
<li>Multi-Models</li>
<li>Compare & Pick</li>
<li>Reduce Hallucination</li>
<li>Multi-Models</li>
</ul>
<p>JADE start with a free tier that allow you to use ask 500 messages a month. You can then upgrade for $0.95/month.</p>