+
+ {
+ const newMode = e.target.value;
+ const oldMode = pricingMode;
+ setPricingMode(newMode);
+
+ // Instead of resetting all values, convert between modes
+ if (currentModel) {
+ const updatedModel = { ...currentModel };
+
+ // Update formRef with converted values
+ if (formRef.current) {
+ const formValues = {
+ name: updatedModel.name
+ };
+
+ if (newMode === 'per-request') {
+ formValues.priceInput = updatedModel.price || '';
+ } else if (newMode === 'per-token') {
+ formValues.ratioInput = updatedModel.ratio || '';
+ formValues.completionRatioInput = updatedModel.completionRatio || '';
+ formValues.modelTokenPrice = updatedModel.tokenPrice || '';
+ formValues.completionTokenPrice = updatedModel.completionTokenPrice || '';
+ }
+
+ formRef.current.setValues(formValues);
+ }
+
+ // Update the model state
+ setCurrentModel(updatedModel);
+ }
+ }}>
+ {t('按量计费')}
+ {t('按次计费')}
+
+
+
+
+ {pricingMode === 'per-token' && (
+ <>
+