Skip to content

Commit

Permalink
fix: Improve model ratio and price management
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Calcium-Ion committed Feb 28, 2025
1 parent 18d3706 commit a508501
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion relay/helper/price.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func ModelPriceHelper(c *gin.Context, info *relaycommon.RelayInfo, promptTokens
var success bool
modelRatio, success = common.GetModelRatio(info.OriginModelName)
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
preConsumedQuota = int(float64(preConsumedTokens) * ratio)
Expand Down
11 changes: 5 additions & 6 deletions web/src/pages/Setting/Operation/ModelRationNotSetEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,17 @@ export default function ModelRatioNotSetEditor(props) {
const unsetModels = enabledModels.filter(modelName => {
const hasPrice = modelPrice[modelName] !== undefined;
const hasRatio = modelRatio[modelName] !== undefined;
const hasCompletionRatio = completionRatio[modelName] !== undefined;

// 如果模型既没有价格也没有倍率设置,则显示
return !(hasPrice || (hasRatio && hasCompletionRatio));
// 如果模型没有价格或者没有倍率设置,则显示
return !hasPrice && !hasRatio;
});

// 创建模型数据
const modelData = unsetModels.map(name => ({
name,
price: '',
ratio: '',
completionRatio: ''
price: modelPrice[name] || '',
ratio: modelRatio[name] || '',
completionRatio: completionRatio[name] || ''
}));

setModels(modelData);
Expand Down

0 comments on commit a508501

Please # to comment.