diff --git a/Chat.go b/Chat.go index b0dc193..9eaff00 100644 --- a/Chat.go +++ b/Chat.go @@ -245,46 +245,6 @@ func generateWelcomeChatHTML() string { return htmlString } -func generatePricingTableChatHTML() string { - stripeTable := ` - - ` - - closeBtn := ` -
- - - - - -
` - - htmlString := "
" - - NextMessages := []TemplateMessage{} - nextMsg := TemplateMessage{ - Icon: "icons/bouvai2.png", // Assuming Icon is a field you want to include from Message - Content: "
" + 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 += "
" - htmlString += "
" - - // Render the HTML template with the messages - return htmlString -} - func generateEnterKeyChatHTML() string { 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 } - fmt.Println(TotalCost, TotalCount) - out, err := pongo2.Must(pongo2.FromFile("views/partials/popover-usage.html")).Execute(pongo2.Context{ "usages": usages, "TotalCost": TotalCost, @@ -563,6 +521,7 @@ func GenerateModelPopoverHTML(refresh bool) string { "LLMs": llms, "ModelInfos": modelInfos, "DeleteUpdate": refresh, + "IsSub": IsCurrentUserSubscribed(), }) if err != nil { panic(err) diff --git a/Stripe.go b/Stripe.go index 86a99bb..51a08bd 100644 --- a/Stripe.go +++ b/Stripe.go @@ -1,7 +1,55 @@ package main -import "github.com/gofiber/fiber/v2" +import ( + "github.com/flosch/pongo2" + "github.com/gofiber/fiber/v2" +) func PricingTableHandler(c *fiber.Ctx) error { return c.SendString(generatePricingTableChatHTML()) } + +func generatePricingTableChatHTML() string { + stripeTable := ` + + ` + + closeBtn := ` +
+ + + + + +
` + + htmlString := "
" + + NextMessages := []TemplateMessage{} + nextMsg := TemplateMessage{ + Icon: "icons/bouvai2.png", // Assuming Icon is a field you want to include from Message + Content: "
" + 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 += "
" + htmlString += "
" + + // Render the HTML template with the messages + return htmlString +} + +func IsCurrentUserSubscribed() bool { + // TODO Ask Stripe if user is subscribed + return false +} diff --git a/utils.go b/utils.go index 92c1fc6..52183d2 100644 --- a/utils.go +++ b/utils.go @@ -172,7 +172,7 @@ func GetAvailableModels() []ModelInfo { name, icon } - } FILTER .modelID != 'none' AND .company.name != 'huggingface' + } FILTER .modelID != 'none' AND .company.name != 'huggingface' AND .company IN global currentUser.setting.keys.company `, &models) if err != nil { panic(err) diff --git a/views/partials/popover-models.html b/views/partials/popover-models.html index 2fbfd82..f18cce3 100644 --- a/views/partials/popover-models.html +++ b/views/partials/popover-models.html @@ -48,7 +48,7 @@ {% for modelInfo in ModelInfos %} {% endfor %} - + {% if IsSub %} {% endif %}