diff --git a/web/default/src/features/system-settings/models/model-pricing-sheet.tsx b/web/default/src/features/system-settings/models/model-pricing-sheet.tsx index 0ed12a0a..0ff897c4 100644 --- a/web/default/src/features/system-settings/models/model-pricing-sheet.tsx +++ b/web/default/src/features/system-settings/models/model-pricing-sheet.tsx @@ -26,10 +26,11 @@ import { } from 'react' import { useForm } from 'react-hook-form' import { zodResolver } from '@hookform/resolvers/zod' -import { AlertTriangle } from 'lucide-react' +import { AlertTriangle, Save } from 'lucide-react' import { useTranslation } from 'react-i18next' import { cn } from '@/lib/utils' import { Alert, AlertDescription } from '@/components/ui/alert' +import { Button } from '@/components/ui/button' import { Field, FieldDescription, @@ -86,6 +87,8 @@ type ModelPricingSheetProps = { open: boolean onOpenChange: (open: boolean) => void editData?: ModelRatioData | null + onSave?: () => void | Promise + isSaving?: boolean } type ModelPricingEditorPanelProps = Omit< @@ -102,7 +105,10 @@ export type ModelPricingEditorPanelHandle = { export const ModelPricingSheet = forwardRef< ModelPricingEditorPanelHandle, ModelPricingSheetProps ->(function ModelPricingSheet({ open, onOpenChange, editData }, ref) { +>(function ModelPricingSheet( + { open, onOpenChange, editData, onSave, isSaving }, + ref +) { const { t } = useTranslation() const title = editData ? t('Edit model pricing') : t('Add model pricing') const description = editData?.name || t('New model') @@ -120,6 +126,8 @@ export const ModelPricingSheet = forwardRef< @@ -130,7 +138,10 @@ export const ModelPricingSheet = forwardRef< export const ModelPricingEditorPanel = forwardRef< ModelPricingEditorPanelHandle, ModelPricingEditorPanelProps ->(function ModelPricingEditorPanel({ editData, className }, ref) { +>(function ModelPricingEditorPanel( + { editData, className, onSave, isSaving }, + ref +) { const { t } = useTranslation() const [pricingMode, setPricingMode] = useState('per-token') const [promptPrice, setPromptPrice] = useState('') @@ -461,6 +472,7 @@ export const ModelPricingEditorPanel = forwardRef< ) const activeName = watchedValues.name || editData?.name || t('New model') + const showActions = Boolean(onSave) return (
-
+
{warnings.length > 0 && ( @@ -670,6 +682,23 @@ export const ModelPricingEditorPanel = forwardRef<
+ {showActions && ( +
+
+ {onSave && ( + + )} +
+
+ )}
diff --git a/web/default/src/features/system-settings/models/model-ratio-form.tsx b/web/default/src/features/system-settings/models/model-ratio-form.tsx index a1110903..38c3a530 100644 --- a/web/default/src/features/system-settings/models/model-ratio-form.tsx +++ b/web/default/src/features/system-settings/models/model-ratio-form.tsx @@ -18,7 +18,7 @@ For commercial licensing, please contact support@quantumnous.com */ import { memo, useCallback, useRef, useState } from 'react' import { type UseFormReturn } from 'react-hook-form' -import { Code2, Eye } from 'lucide-react' +import { Code2, Eye, RotateCcw, Save } from 'lucide-react' import { useTranslation } from 'react-i18next' import { Button } from '@/components/ui/button' import { @@ -110,16 +110,20 @@ export const ModelRatioForm = memo(function ModelRatioForm({ onClick={onReset} disabled={isResetting} > + {t('Reset prices')} - + {editMode === 'json' && ( + + )}