feat: Conditionally display cost settings based on billing configuration in LlmProviders settings

This commit is contained in:
Nawaz Dhandala
2025-12-16 10:27:21 +00:00
parent 5652298f38
commit cc077aff99

View File

@@ -13,6 +13,7 @@ import LlmProvider from "Common/Models/DatabaseModels/LlmProvider";
import LlmType from "Common/Types/LLM/LlmType";
import React, { FunctionComponent, ReactElement } from "react";
import DropdownUtil from "Common/UI/Utils/Dropdown";
import { BILLING_ENABLED } from "Common/UI/Config";
const Settings: FunctionComponent = (): ReactElement => {
return (
@@ -83,10 +84,14 @@ const Settings: FunctionComponent = (): ReactElement => {
title: "Provider Settings",
id: "provider-settings",
},
{
title: "Cost Settings",
id: "cost-settings",
},
...(BILLING_ENABLED
? [
{
title: "Cost Settings",
id: "cost-settings",
},
]
: []),
]}
formFields={[
{
@@ -160,18 +165,22 @@ const Settings: FunctionComponent = (): ReactElement => {
description:
"Required for Ollama. Optional for others to use custom endpoints.",
},
{
field: {
costPerMillionTokensInUSDCents: true,
},
title: "Cost Per Million Tokens (USD Cents)",
stepId: "cost-settings",
fieldType: FormFieldSchemaType.Number,
required: false,
placeholder: "0",
description:
"Cost per million tokens in USD cents. For example, if the cost is $0.01 per 1M tokens, enter 1.",
},
...(BILLING_ENABLED
? [
{
field: {
costPerMillionTokensInUSDCents: true,
},
title: "Cost Per Million Tokens (USD Cents)",
stepId: "cost-settings",
fieldType: FormFieldSchemaType.Number,
required: false,
placeholder: "0",
description:
"Cost per million tokens in USD cents. For example, if the cost is $0.01 per 1M tokens, enter 1.",
},
]
: []),
]}
selectMoreFields={{
apiKey: true,
@@ -222,14 +231,18 @@ const Settings: FunctionComponent = (): ReactElement => {
type: FieldType.Text,
noValueMessage: "-",
},
{
field: {
costPerMillionTokensInUSDCents: true,
},
title: "Cost (cents/1M)",
type: FieldType.Number,
noValueMessage: "0",
},
...(BILLING_ENABLED
? [
{
field: {
costPerMillionTokensInUSDCents: true,
},
title: "Cost (cents/1M)",
type: FieldType.Number,
noValueMessage: "0",
},
]
: []),
]}
/>
</Page>