fix: Improve model ratio and price management
- Update error message for missing model ratio to be more user-friendly - Modify ModelRatioNotSetEditor to filter models without price or ratio - Enhance model data initialization with fallback values
This commit is contained in:
@@ -29,7 +29,7 @@ func ModelPriceHelper(c *gin.Context, info *relaycommon.RelayInfo, promptTokens
|
|||||||
var success bool
|
var success bool
|
||||||
modelRatio, success = common.GetModelRatio(info.OriginModelName)
|
modelRatio, success = common.GetModelRatio(info.OriginModelName)
|
||||||
if !success {
|
if !success {
|
||||||
return PriceData{}, fmt.Errorf("model %s ratio not found", info.OriginModelName)
|
return PriceData{}, fmt.Errorf("model %s ratio or price not found, please contact admin", info.OriginModelName)
|
||||||
}
|
}
|
||||||
ratio := modelRatio * groupRatio
|
ratio := modelRatio * groupRatio
|
||||||
preConsumedQuota = int(float64(preConsumedTokens) * ratio)
|
preConsumedQuota = int(float64(preConsumedTokens) * ratio)
|
||||||
|
|||||||
@@ -55,18 +55,17 @@ export default function ModelRatioNotSetEditor(props) {
|
|||||||
const unsetModels = enabledModels.filter(modelName => {
|
const unsetModels = enabledModels.filter(modelName => {
|
||||||
const hasPrice = modelPrice[modelName] !== undefined;
|
const hasPrice = modelPrice[modelName] !== undefined;
|
||||||
const hasRatio = modelRatio[modelName] !== undefined;
|
const hasRatio = modelRatio[modelName] !== undefined;
|
||||||
const hasCompletionRatio = completionRatio[modelName] !== undefined;
|
|
||||||
|
|
||||||
// 如果模型既没有价格也没有倍率设置,则显示
|
// 如果模型没有价格或者没有倍率设置,则显示
|
||||||
return !(hasPrice || (hasRatio && hasCompletionRatio));
|
return !hasPrice && !hasRatio;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 创建模型数据
|
// 创建模型数据
|
||||||
const modelData = unsetModels.map(name => ({
|
const modelData = unsetModels.map(name => ({
|
||||||
name,
|
name,
|
||||||
price: '',
|
price: modelPrice[name] || '',
|
||||||
ratio: '',
|
ratio: modelRatio[name] || '',
|
||||||
completionRatio: ''
|
completionRatio: completionRatio[name] || ''
|
||||||
}));
|
}));
|
||||||
|
|
||||||
setModels(modelData);
|
setModels(modelData);
|
||||||
|
|||||||
Reference in New Issue
Block a user