mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-10 19:44:23 +01:00
✨ feat: Refactor Token Rates Configuration and Introduce Custom Overrides
This commit is contained in:
parent
7dfb386f5a
commit
262e6aa4c9
4 changed files with 106 additions and 36 deletions
|
|
@ -505,7 +505,7 @@ export type TStartupConfig = {
|
|||
helpAndFaqURL: string;
|
||||
customFooter?: string;
|
||||
modelSpecs?: TSpecsConfig;
|
||||
tokenRates?: TTokenRates;
|
||||
tokenRates?: TModelTokenRates;
|
||||
sharedLinksEnabled: boolean;
|
||||
publicSharedLinksEnabled: boolean;
|
||||
analyticsGtmId?: string;
|
||||
|
|
@ -523,16 +523,7 @@ export type TTokenCost = {
|
|||
};
|
||||
|
||||
// Endpoint token rates schema type
|
||||
export type TEndpointTokenRates = Record<string, TTokenCost>;
|
||||
|
||||
// Token rates schema type
|
||||
export type TTokenRates = {
|
||||
openAI?: TEndpointTokenRates;
|
||||
google?: TEndpointTokenRates;
|
||||
anthropic?: TEndpointTokenRates;
|
||||
bedrock?: TEndpointTokenRates;
|
||||
custom?: TEndpointTokenRates;
|
||||
};
|
||||
export type TModelTokenRates = Record<string, TTokenCost>;
|
||||
|
||||
const tokenCostSchema = z.object({
|
||||
prompt: z.number().optional(), // e.g. 1.5 => $1.50 / 1M tokens
|
||||
|
|
@ -545,16 +536,6 @@ const tokenCostSchema = z.object({
|
|||
.optional(),
|
||||
});
|
||||
|
||||
const endpointTokenRatesSchema = z.record(z.string(), tokenCostSchema);
|
||||
|
||||
const tokenRatesSchema = z.object({
|
||||
openAI: endpointTokenRatesSchema.optional(),
|
||||
google: endpointTokenRatesSchema.optional(),
|
||||
anthropic: endpointTokenRatesSchema.optional(),
|
||||
bedrock: endpointTokenRatesSchema.optional(),
|
||||
custom: endpointTokenRatesSchema.optional(),
|
||||
});
|
||||
|
||||
export const configSchema = z.object({
|
||||
version: z.string(),
|
||||
cache: z.boolean().default(true),
|
||||
|
|
@ -586,7 +567,7 @@ export const configSchema = z.object({
|
|||
rateLimits: rateLimitSchema.optional(),
|
||||
fileConfig: fileConfigSchema.optional(),
|
||||
modelSpecs: specsConfigSchema.optional(),
|
||||
tokenRates: tokenRatesSchema.optional(),
|
||||
tokenRates: tokenCostSchema.optional(),
|
||||
endpoints: z
|
||||
.object({
|
||||
all: baseEndpointSchema.optional(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue