fix(model-catalog): refine summary capability filters
This commit is contained in:
@@ -985,31 +985,66 @@ func modelCatalogCapabilityFilters(items []ModelCatalogItem) []ModelCatalogFilte
|
||||
}
|
||||
}
|
||||
options := []ModelCatalogFilterOption{{Value: "all", Label: "全部", Count: len(items)}}
|
||||
for _, option := range []ModelCatalogFilterOption{
|
||||
{Value: "chat", Label: "对话"},
|
||||
{Value: "image", Label: "图像"},
|
||||
{Value: "video", Label: "视频"},
|
||||
{Value: "audio", Label: "音频"},
|
||||
{Value: "embedding", Label: "Embedding"},
|
||||
{Value: "tools", Label: "工具调用"},
|
||||
{Value: "omni", Label: "全模态"},
|
||||
} {
|
||||
known := map[string]bool{}
|
||||
for _, option := range modelCatalogCapabilityDefinitions() {
|
||||
known[option.Value] = true
|
||||
if count := counts[option.Value]; count > 0 {
|
||||
option.Count = count
|
||||
options = append(options, option)
|
||||
}
|
||||
}
|
||||
extraValues := make([]string, 0)
|
||||
for value := range counts {
|
||||
if !known[value] {
|
||||
extraValues = append(extraValues, value)
|
||||
}
|
||||
}
|
||||
sort.Slice(extraValues, func(i, j int) bool {
|
||||
return capabilityLabel(extraValues[i]) < capabilityLabel(extraValues[j])
|
||||
})
|
||||
for _, value := range extraValues {
|
||||
options = append(options, ModelCatalogFilterOption{Value: value, Label: capabilityLabel(value), Count: counts[value]})
|
||||
}
|
||||
return options
|
||||
}
|
||||
|
||||
func modelCatalogCapabilityDefinitions() []ModelCatalogFilterOption {
|
||||
return []ModelCatalogFilterOption{
|
||||
{Value: "text_generate", Label: "文本生成"},
|
||||
{Value: "chat", Label: "对话"},
|
||||
{Value: "responses", Label: "Responses"},
|
||||
{Value: "image_generate", Label: "图像生成"},
|
||||
{Value: "image_edit", Label: "图像编辑"},
|
||||
{Value: "image_analysis", Label: "图像分析"},
|
||||
{Value: "video_generate", Label: "视频生成"},
|
||||
{Value: "image_to_video", Label: "图生视频"},
|
||||
{Value: "text_to_video", Label: "文生视频"},
|
||||
{Value: "video_edit", Label: "视频编辑"},
|
||||
{Value: "video_understanding", Label: "视频理解"},
|
||||
{Value: "audio_generate", Label: "音频生成"},
|
||||
{Value: "text_to_speech", Label: "语音合成"},
|
||||
{Value: "audio_understanding", Label: "音频理解"},
|
||||
{Value: "text_embedding", Label: "Embedding"},
|
||||
{Value: "omni", Label: "全模态"},
|
||||
{Value: "omni_video", Label: "全模态视频"},
|
||||
{Value: "multimodal", Label: "多模态"},
|
||||
{Value: "model_3d", Label: "3D 模型"},
|
||||
{Value: "text_to_model", Label: "文生 3D"},
|
||||
{Value: "image_to_model", Label: "图生 3D"},
|
||||
{Value: "multiview_to_model", Label: "多视角 3D"},
|
||||
{Value: "mesh_edit", Label: "3D 模型编辑"},
|
||||
{Value: "tools_call", Label: "工具调用"},
|
||||
{Value: "structured_output", Label: "结构化输出"},
|
||||
{Value: "reasoning", Label: "推理"},
|
||||
{Value: "digital_human", Label: "数字人"},
|
||||
}
|
||||
}
|
||||
|
||||
func capabilityFilterValuesForItem(item ModelCatalogItem) []string {
|
||||
values := capabilityFilterValues(item.ModelType, nil)
|
||||
for _, tag := range item.CapabilityTags {
|
||||
switch tag {
|
||||
case "工具调用":
|
||||
values = append(values, "tools")
|
||||
case "全模态", "多模态":
|
||||
values = append(values, "omni")
|
||||
if value := capabilityFilterValueForTag(tag); value != "" {
|
||||
values = append(values, value)
|
||||
}
|
||||
}
|
||||
return uniqueStrings(values)
|
||||
@@ -1067,33 +1102,62 @@ func capabilityTagsForGroup(modelTypes []string, capabilities map[string]any) []
|
||||
func capabilityFilterValues(modelTypes []string, capabilities map[string]any) []string {
|
||||
values := []string{}
|
||||
for _, modelType := range modelTypes {
|
||||
normalized := strings.ToLower(strings.TrimSpace(modelType))
|
||||
switch {
|
||||
case normalized == "text_embedding" || normalized == "embedding":
|
||||
values = append(values, "embedding")
|
||||
case normalized == "tools_call":
|
||||
values = append(values, "tools")
|
||||
case normalized == "omni":
|
||||
values = append(values, "omni")
|
||||
case strings.Contains(normalized, "video"):
|
||||
values = append(values, "video")
|
||||
case strings.Contains(normalized, "audio") || strings.Contains(normalized, "speech"):
|
||||
values = append(values, "audio")
|
||||
case strings.Contains(normalized, "image"):
|
||||
values = append(values, "image")
|
||||
case normalized == "text_generate" || normalized == "chat" || normalized == "responses" || strings.Contains(normalized, "text"):
|
||||
values = append(values, "chat")
|
||||
if value := canonicalCapabilityFilterValue(modelType); value != "" {
|
||||
values = append(values, value)
|
||||
}
|
||||
}
|
||||
if boolAnyValue(capabilities["tools_call"]) || boolAnyValue(capabilities["toolCall"]) || boolAnyValue(capabilities["function_call"]) {
|
||||
values = append(values, "tools")
|
||||
values = append(values, "tools_call")
|
||||
}
|
||||
if boolAnyValue(capabilities["multimodal"]) {
|
||||
values = append(values, "omni")
|
||||
values = append(values, "multimodal")
|
||||
}
|
||||
return uniqueStrings(values)
|
||||
}
|
||||
|
||||
func canonicalCapabilityFilterValue(value string) string {
|
||||
normalized := strings.ReplaceAll(strings.ToLower(strings.TrimSpace(value)), "-", "_")
|
||||
switch normalized {
|
||||
case "embedding":
|
||||
return "text_embedding"
|
||||
case "model":
|
||||
return "model_3d"
|
||||
default:
|
||||
return normalized
|
||||
}
|
||||
}
|
||||
|
||||
func capabilityFilterValueForTag(tag string) string {
|
||||
switch tag {
|
||||
case "工具调用":
|
||||
return "tools_call"
|
||||
case "全模态":
|
||||
return "omni"
|
||||
case "全模态视频":
|
||||
return "omni_video"
|
||||
case "多模态":
|
||||
return "multimodal"
|
||||
case "推理":
|
||||
return "reasoning"
|
||||
case "结构化输出":
|
||||
return "structured_output"
|
||||
case "数字人":
|
||||
return "digital_human"
|
||||
case "3D 模型":
|
||||
return "model_3d"
|
||||
case "文生 3D":
|
||||
return "text_to_model"
|
||||
case "图生 3D":
|
||||
return "image_to_model"
|
||||
case "多视角 3D":
|
||||
return "multiview_to_model"
|
||||
case "3D 模型编辑":
|
||||
return "mesh_edit"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func capabilityLabel(value string) string {
|
||||
labels := map[string]string{
|
||||
"text_generate": "文本生成",
|
||||
@@ -1115,9 +1179,16 @@ func capabilityLabel(value string) string {
|
||||
"tools_call": "工具调用",
|
||||
"omni": "全模态",
|
||||
"omni_video": "全模态视频",
|
||||
"multimodal": "多模态",
|
||||
"reasoning": "推理",
|
||||
"structured_output": "结构化输出",
|
||||
"digital_human": "数字人",
|
||||
"model": "3D 模型",
|
||||
"model_3d": "3D 模型",
|
||||
"text_to_model": "文生 3D",
|
||||
"image_to_model": "图生 3D",
|
||||
"multiview_to_model": "多视角 3D",
|
||||
"mesh_edit": "3D 模型编辑",
|
||||
}
|
||||
if label, ok := labels[value]; ok {
|
||||
return label
|
||||
|
||||
Reference in New Issue
Block a user