diff --git a/controller/model_meta.go b/controller/model_meta.go
index 3ba09240..24329555 100644
--- a/controller/model_meta.go
+++ b/controller/model_meta.go
@@ -147,5 +147,7 @@ func fillModelExtra(m *model.Model) {
}
// 填充启用分组
m.EnableGroups = model.GetModelEnableGroups(m.ModelName)
+ // 填充计费类型
+ m.QuotaType = model.GetModelQuotaType(m.ModelName)
}
diff --git a/model/model_extra.go b/model/model_extra.go
new file mode 100644
index 00000000..3724346e
--- /dev/null
+++ b/model/model_extra.go
@@ -0,0 +1,24 @@
+package model
+
+// GetModelEnableGroups 返回指定模型名称可用的用户分组列表。
+// 复用缓存的定价映射,避免额外的数据库查询。
+func GetModelEnableGroups(modelName string) []string {
+ for _, p := range GetPricing() {
+ if p.ModelName == modelName {
+ return p.EnableGroup
+ }
+ }
+ return make([]string, 0)
+}
+
+// GetModelQuotaType 返回指定模型的计费类型(quota_type)。
+// 复用缓存的定价映射,避免额外数据库查询。
+// 如果未找到对应模型,默认返回 0。
+func GetModelQuotaType(modelName string) int {
+ for _, p := range GetPricing() {
+ if p.ModelName == modelName {
+ return p.QuotaType
+ }
+ }
+ return 0
+}
diff --git a/model/model_groups.go b/model/model_groups.go
deleted file mode 100644
index 3957b909..00000000
--- a/model/model_groups.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package model
-
-// GetModelEnableGroups 返回指定模型名称可用的用户分组列表。
-// 复用缓存的定价映射,避免额外的数据库查询。
-func GetModelEnableGroups(modelName string) []string {
- for _, p := range GetPricing() {
- if p.ModelName == modelName {
- return p.EnableGroup
- }
- }
- return make([]string, 0)
-}
diff --git a/model/model_meta.go b/model/model_meta.go
index 84742288..3598cb7c 100644
--- a/model/model_meta.go
+++ b/model/model_meta.go
@@ -39,6 +39,7 @@ type Model struct {
BoundChannels []BoundChannel `json:"bound_channels,omitempty" gorm:"-"`
EnableGroups []string `json:"enable_groups,omitempty" gorm:"-"`
+ QuotaType int `json:"quota_type" gorm:"-"`
}
// Insert 创建新的模型元数据记录
diff --git a/web/src/components/table/models/ModelsColumnDefs.js b/web/src/components/table/models/ModelsColumnDefs.js
index a2af1c95..f71686fc 100644
--- a/web/src/components/table/models/ModelsColumnDefs.js
+++ b/web/src/components/table/models/ModelsColumnDefs.js
@@ -98,6 +98,25 @@ const renderEndpoints = (text) => {
});
};
+// Render quota type
+const renderQuotaType = (qt, t) => {
+ if (qt === 1) {
+ return (
+
+ {t('按次计费')}
+
+ );
+ }
+ if (qt === 0) {
+ return (
+
+ {t('按量计费')}
+
+ );
+ }
+ return qt ?? '-';
+};
+
// Render bound channels
const renderBoundChannels = (channels) => {
if (!channels || channels.length === 0) return '-';
@@ -213,6 +232,11 @@ export const getModelsColumns = ({
dataIndex: 'enable_groups',
render: renderGroups,
},
+ {
+ title: t('计费类型'),
+ dataIndex: 'quota_type',
+ render: (qt) => renderQuotaType(qt, t),
+ },
{
title: t('创建时间'),
dataIndex: 'created_time',