fix
This commit is contained in:
parent
9ca2f45bf4
commit
871f8e3a61
43
Chat.go
43
Chat.go
@ -245,46 +245,6 @@ func generateWelcomeChatHTML() string {
|
|||||||
return htmlString
|
return htmlString
|
||||||
}
|
}
|
||||||
|
|
||||||
func generatePricingTableChatHTML() string {
|
|
||||||
stripeTable := `
|
|
||||||
<stripe-pricing-table pricing-table-id="prctbl_1PJAxDP2nW0okNQyY0Q3mbg4"
|
|
||||||
publishable-key="pk_live_51OxXuWP2nW0okNQyme1qdwbL535jbMmM1uIUi6U5zcvEUUwKraktmpCzudXNdPSTxlHpw2FbCtxpwbyFFcasQ7aj000tJJGpWW">
|
|
||||||
</stripe-pricing-table>`
|
|
||||||
|
|
||||||
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>`
|
|
||||||
|
|
||||||
htmlString := "<div class='columns is-centered' id='chat-container'><div class='column is-12-mobile is-8-tablet is-6-desktop' id='chat-messages'>"
|
|
||||||
|
|
||||||
NextMessages := []TemplateMessage{}
|
|
||||||
nextMsg := TemplateMessage{
|
|
||||||
Icon: "icons/bouvai2.png", // Assuming Icon is a field you want to include from Message
|
|
||||||
Content: "<br>" + stripeTable + 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, "notFlex": true})
|
|
||||||
if err != nil {
|
|
||||||
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 {
|
func generateEnterKeyChatHTML() string {
|
||||||
welcomeMessage := `To start using JADE, please enter at least one key in the settings.`
|
welcomeMessage := `To start using JADE, please enter at least one key in the settings.`
|
||||||
|
|
||||||
@ -485,8 +445,6 @@ func LoadUsageKPIHandler(c *fiber.Ctx) error {
|
|||||||
TotalCount += usage.TotalCount
|
TotalCount += usage.TotalCount
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(TotalCost, TotalCount)
|
|
||||||
|
|
||||||
out, err := pongo2.Must(pongo2.FromFile("views/partials/popover-usage.html")).Execute(pongo2.Context{
|
out, err := pongo2.Must(pongo2.FromFile("views/partials/popover-usage.html")).Execute(pongo2.Context{
|
||||||
"usages": usages,
|
"usages": usages,
|
||||||
"TotalCost": TotalCost,
|
"TotalCost": TotalCost,
|
||||||
@ -563,6 +521,7 @@ func GenerateModelPopoverHTML(refresh bool) string {
|
|||||||
"LLMs": llms,
|
"LLMs": llms,
|
||||||
"ModelInfos": modelInfos,
|
"ModelInfos": modelInfos,
|
||||||
"DeleteUpdate": refresh,
|
"DeleteUpdate": refresh,
|
||||||
|
"IsSub": IsCurrentUserSubscribed(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
50
Stripe.go
50
Stripe.go
@ -1,7 +1,55 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "github.com/gofiber/fiber/v2"
|
import (
|
||||||
|
"github.com/flosch/pongo2"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
)
|
||||||
|
|
||||||
func PricingTableHandler(c *fiber.Ctx) error {
|
func PricingTableHandler(c *fiber.Ctx) error {
|
||||||
return c.SendString(generatePricingTableChatHTML())
|
return c.SendString(generatePricingTableChatHTML())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func generatePricingTableChatHTML() string {
|
||||||
|
stripeTable := `
|
||||||
|
<stripe-pricing-table pricing-table-id="prctbl_1PJAxDP2nW0okNQyY0Q3mbg4"
|
||||||
|
publishable-key="pk_live_51OxXuWP2nW0okNQyme1qdwbL535jbMmM1uIUi6U5zcvEUUwKraktmpCzudXNdPSTxlHpw2FbCtxpwbyFFcasQ7aj000tJJGpWW">
|
||||||
|
</stripe-pricing-table>`
|
||||||
|
|
||||||
|
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>`
|
||||||
|
|
||||||
|
htmlString := "<div class='columns is-centered' id='chat-container'><div class='column is-12-mobile is-8-tablet is-6-desktop' id='chat-messages'>"
|
||||||
|
|
||||||
|
NextMessages := []TemplateMessage{}
|
||||||
|
nextMsg := TemplateMessage{
|
||||||
|
Icon: "icons/bouvai2.png", // Assuming Icon is a field you want to include from Message
|
||||||
|
Content: "<br>" + stripeTable + 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, "notFlex": true})
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
htmlString += botOut
|
||||||
|
htmlString += "<div style='height: 10px;'></div>"
|
||||||
|
htmlString += "</div></div>"
|
||||||
|
|
||||||
|
// Render the HTML template with the messages
|
||||||
|
return htmlString
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsCurrentUserSubscribed() bool {
|
||||||
|
// TODO Ask Stripe if user is subscribed
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
2
utils.go
2
utils.go
@ -172,7 +172,7 @@ func GetAvailableModels() []ModelInfo {
|
|||||||
name,
|
name,
|
||||||
icon
|
icon
|
||||||
}
|
}
|
||||||
} FILTER .modelID != 'none' AND .company.name != 'huggingface'
|
} FILTER .modelID != 'none' AND .company.name != 'huggingface' AND .company IN global currentUser.setting.keys.company
|
||||||
`, &models)
|
`, &models)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
{% for modelInfo in ModelInfos %}
|
{% for modelInfo in ModelInfos %}
|
||||||
<option value="{{ modelInfo.ModelID }}">{{ modelInfo.ModelID }}</option>
|
<option value="{{ modelInfo.ModelID }}">{{ modelInfo.ModelID }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<option value="custom">Inference Endpoints</option>
|
{% if IsSub %}<option value="custom">Inference Endpoints</option> {% endif %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<input class="input is-small mb-3 is-hidden" type="text" id="model-cid-input" name="model-cid-input"
|
<input class="input is-small mb-3 is-hidden" type="text" id="model-cid-input" name="model-cid-input"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user