mirror of
https://github.com/LibreChat-AI/librechat.ai.git
synced 2026-03-27 10:48:32 +07:00
🪙 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:
@@ -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"
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
'use client'
|
||||
|
||||
import * as React from 'react'
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
'use client'
|
||||
|
||||
import * as React from 'react'
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
'use client'
|
||||
|
||||
import * as React from 'react'
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
'use client'
|
||||
|
||||
import * as React from 'react'
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
'use client'
|
||||
|
||||
import * as React from 'react'
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
'use client'
|
||||
|
||||
import * as React from 'react'
|
||||
|
||||
@@ -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']
|
||||
]}
|
||||
/>
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
Reference in New Issue
Block a user