🪙 feat: automatically add start balance (#168)

* Adding information about the starting balance

* Adding information about the starting balance

* chore: type fixes

* fix: MDX build errors

* chore: explicit typing

* chore: improve typing for author metadata socials

* chore: strict assertion

---------

Co-authored-by: MSITE.TOP <admin@msite.top>
This commit is contained in:
Danny Avila
2024-11-16 10:20:25 -05:00
committed by GitHub
parent 816db32535
commit eec560869e
12 changed files with 40 additions and 10 deletions

View File

@@ -11,7 +11,9 @@ interface AuthorMetadata {
name: string
bio: string
ogImage: string
socials?: Record<string, string>
socials?: {
[key: string]: string
}
}
const AuthorCard: React.FC<{ author: AuthorMetadata }> = ({ author }) => {
@@ -21,7 +23,9 @@ const AuthorCard: React.FC<{ author: AuthorMetadata }> = ({ author }) => {
setIsClient(true)
}, [])
const socialsEntries = Object.entries(author.socials ?? {}).filter(([, value]) => !!value)
const socialsEntries = Object.entries(author.socials ?? {}).filter(
([, value]) => !!value,
) as unknown as [string, string][]
return (
<Link href={`/authors/${author.authorid}`}>
@@ -43,7 +47,7 @@ const AuthorCard: React.FC<{ author: AuthorMetadata }> = ({ author }) => {
socialsEntries.map(([key, value]) => (
<a
key={key}
href={value as string}
href={value}
className="btn btn-square relative overflow-hidden"
title={`See ${author.name}'s ${key}`}
target="_blank"
@@ -52,7 +56,7 @@ const AuthorCard: React.FC<{ author: AuthorMetadata }> = ({ author }) => {
onClick={(e) => e.stopPropagation()}
>
<SocialIcon
url={value as string}
url={value}
className="absolute inset-0 w-full h-full transform scale-100 transition-transform opacity-100 hover:scale-90"
bgColor="#9B9B9B80"
fgColor="background"

View File

@@ -3,10 +3,11 @@ import React, { forwardRef } from 'react'
export const HomeSection = forwardRef<
HTMLElement,
{ children: React.ReactNode; className?: string }
{ children: React.ReactNode; className?: string; id?: string }
>((props, ref) => {
return (
<section
id={props.id}
ref={ref}
className={cn(
'py-20 lg:py-32 mx-auto max-w-7xl px-5 sm:px-7 xl:px-10 first:pt-10 last:pb-40 last:lg:pb-52',

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
'use client'
import * as React from 'react'

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
'use client'
import * as React from 'react'

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
'use client'
import * as React from 'react'

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
'use client'
import * as React from 'react'
@@ -22,6 +23,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
inset?: boolean
children: React.ReactNode
}
>(({ className, inset, children, ...props }, ref) => (
<DropdownMenuPrimitive.SubTrigger
@@ -56,7 +58,9 @@ DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayNam
const DropdownMenuContent = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> & {
children?: React.ReactNode
}
>(({ className, sideOffset = 4, ...props }, ref) => (
<DropdownMenuPrimitive.Content
ref={ref}
@@ -75,6 +79,8 @@ const DropdownMenuItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
inset?: boolean
children?: React.ReactNode
onClick?: (event: React.MouseEvent) => void
}
>(({ className, inset, ...props }, ref) => (
<DropdownMenuPrimitive.Item
@@ -91,7 +97,9 @@ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
const DropdownMenuCheckboxItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem> & {
children: React.ReactNode
}
>(({ className, children, checked, ...props }, ref) => (
<DropdownMenuPrimitive.CheckboxItem
ref={ref}
@@ -114,7 +122,9 @@ DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displa
const DropdownMenuRadioItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem> & {
children: React.ReactNode
}
>(({ className, children, value, ...props }, ref) => (
<DropdownMenuPrimitive.RadioItem
ref={ref}

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
import * as React from 'react'
import * as LabelPrimitive from '@radix-ui/react-label'
import { Slot } from '@radix-ui/react-slot'

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
'use client'
import * as React from 'react'

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
'use client'
import * as React from 'react'

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
'use client'
import * as React from 'react'

View File

@@ -682,13 +682,14 @@ see: **[Automated Moderation](/docs/configuration/mod_system)**
### Balance
The following enables user balances for the OpenAI/Plugins endpoints, which you can add manually or you will need to build out a balance accruing system for users.
The following feature allows for the management of user balances within the system's endpoints. You have the option to add balances manually, or you may choose to implement a system that accumulates balances automatically for users. If a specific initial balance is defined in the configuration, tokens will be credited to the user's balance automatically when they register.
see: **[Token Usage](/docs/configuration/token_usage)**
<OptionTable
options={[
['CHECK_BALANCE', 'boolean', 'Enable token credit balances for the OpenAI/Plugins endpoints.','CHECK_BALANCE=false'],
['START_BALANCE', 'integer', 'If the value is set, tokens will be credited to the user\'s balance after registration.', 'START_BALANCE=20000']
]}
/>

View File

@@ -17,6 +17,13 @@ Currently, you can limit user token usage by enabling user balances. To enables
]}
/>
And You can also set the number of tokens a user will receive upon registration:
<OptionTable
options={[
['START_BALANCE', 'integer', 'If the value is set, tokens will be credited to the user\'s balance after registration.','START_BALANCE=20000']
]}
/>
You manually add user balance, or you will need to build out a balance-accruing system for users. This may come as a feature to the app whenever an admin dashboard is introduced.
@@ -101,4 +108,4 @@ There will be more customization for this soon from the `librechat.yaml` file.
![image](https://github.com/danny-avila/LibreChat/assets/110412045/39a1aa5d-f8fc-43bf-81f2-299e57d944bb)
![image](https://github.com/danny-avila/LibreChat/assets/110412045/e1b1cc3f-8981-4c7c-a5f8-e7badbc6f675)
![image](https://github.com/danny-avila/LibreChat/assets/110412045/e1b1cc3f-8981-4c7c-a5f8-e7badbc6f675)