2026-07-11 23:48:36 +08:00
< script setup lang = "ts" >
import { computed , onMounted , ref } from "vue"
import { getJson } from "../../../../shared/api/client"
import { endpoints } from "../../../../shared/api/endpoints"
type Assignment = {
key : string
title : string
description : string
recommendation : string
kind : "image" | "vision" | "text"
runtime : "active" | "rules"
}
2026-07-15 23:01:07 +08:00
type AdapterOption = { id : string ; name : string ; route : string ; model : string ; enabled : boolean }
type RuntimeModel = { route : string ; provider _id : string ; name : string ; model : string ; modality : string ; source : string }
type ReviewGroup = {
key : string
primaryKey : string
secondaryKey : string
title : string
description : string
recommendation : string
kind : "image" | "vision"
}
2026-07-11 23:48:36 +08:00
const props = defineProps < {
modelValue : Record < string , unknown >
adapters : AdapterOption [ ]
visionRoute : string
disabled : boolean
} > ( )
const emit = defineEmits < { "update:modelValue" : [ value : Record < string , unknown > ] } > ( )
2026-07-15 23:01:07 +08:00
const runtimeModels = ref < RuntimeModel [ ] > ( [ ] )
2026-07-11 23:48:36 +08:00
const cards : Assignment [ ] = [
{ key : "material_recognition" , title : "素材导入解析" , description : "识别素材类别、描述、标签和生成提示词。" , recommendation : "建议选择支持图片理解与结构化 JSON 输出的视觉模型;优先稳定和低成本,通常不需要最强推理模型。" , kind : "vision" , runtime : "active" } ,
{ key : "profile_parse" , title : "外部角色导入解析" , description : "将外部角色文本拆成结构化角色字段。" , recommendation : "建议选择指令遵循稳定、长文本处理好且支持 JSON 输出的文本模型;角色资料很长时关注上下文长度。" , kind : "text" , runtime : "rules" } ,
{ key : "persona_split" , title : "角色设定拆解" , description : "拆解身份、外观、服装、关系和世界观。" , recommendation : "建议使用语义理解和信息抽取能力较强的文本模型,重点避免遗漏设定或把推测内容当成事实。" , kind : "text" , runtime : "rules" } ,
{ key : "prompt_planning" , title : "提示词规划与扩写" , description : "生成阶段提示词矩阵和负面提示词。" , recommendation : "建议选择熟悉生图提示词、风格词和负面词的文本模型;创意能力优先于纯推理速度。" , kind : "text" , runtime : "rules" } ,
2026-07-15 23:01:07 +08:00
{ key : "quick_generation" , title : "单图 / 快速角色统一生图" , description : "单图生成,以及快速角色的头像、半身像、立绘和设定图。快速角色四个目标会强制使用同一路由。" , recommendation : "建议选择同时擅长近景、全身和参考图跟随的模型;角色一致性优先于单项构图极限。" , kind : "image" , runtime : "active" } ,
{ key : "portrait_generation" , title : "详细工作流头像草稿" , description : "详细角色工作流的头像与面部细节候选生成。" , recommendation : "建议选择人脸、眼睛和发型细节稳定的模型,并具备较好的角色一致性;优先测试近景表现。" , kind : "image" , runtime : "active" } ,
{ key : "halfbody_generation" , title : "详细工作流半身角色图" , description : "详细角色工作流的上半身服装、姿态和轮廓。" , recommendation : "建议选择服装细节、手部和姿态表现均衡的模型,适合中景构图和角色立绘。" , kind : "image" , runtime : "active" } ,
{ key : "fullbody_generation" , title : "详细工作流全身角色图" , description : "详细角色工作流的全套服装、比例和全身设计。" , recommendation : "建议选择人体比例、脚部、复杂服装结构较稳定的模型;优先支持纵向高分辨率。" , kind : "image" , runtime : "active" } ,
{ key : "sheet_generation" , title : "详细工作流设定图与姿势图" , description : "详细角色工作流的表情、动作和角色设定图。" , recommendation : "建议选择多视图排版、角色一致性和动作控制能力强的模型,能稳定生成设定表或姿势组图。" , kind : "image" , runtime : "active" } ,
2026-07-11 23:48:36 +08:00
{ key : "hires_fix" , title : "高清修复" , description : "最终放大、细节修复和风格统一。" , recommendation : "建议选择支持高分辨率、图生图或重绘的模型,重点保留原角色身份与构图,避免放大时改变面部和服装。" , kind : "image" , runtime : "active" } ,
]
2026-07-15 23:01:07 +08:00
const textRoutes = computed ( ( ) => runtimeModels . value . filter ( item => item . modality === "text_generation" ) )
const visionRoutes = computed ( ( ) => runtimeModels . value . filter ( item => item . modality === "vision_recognition" ) )
const imageRoutes = computed ( ( ) => runtimeModels . value . filter ( item => item . modality === "image_generation" ) )
const reviewGroups : ReviewGroup [ ] = [
{
key : "visual_review_routes" ,
primaryKey : "cross_review_primary" ,
secondaryKey : "cross_review_secondary" ,
title : "视觉质量审核" ,
description : "使用视觉模型检查角色一致性、构图、手部、服装和渲染缺陷,不会重新生图。" ,
recommendation : "建议选择支持图片理解和结构化输出的不同视觉模型;这是质检层,与生成式交叉审查分开配置。" ,
kind : "vision" ,
} ,
{
key : "generation_cross_review_routes" ,
primaryKey : "generation_cross_review_primary" ,
secondaryKey : "generation_cross_review_secondary" ,
title : "生成式交叉审查" ,
description : "确认阶段后,用不同生图模型重新生成候选并在同一工作台比较。" ,
recommendation : "必须选择至少两个不同的生图模型;优先不同模型家族或不同厂商,避免同源偏差。" ,
kind : "image" ,
} ,
]
2026-07-11 23:48:36 +08:00
function value ( key : string ) { return String ( props . modelValue [ key ] || "" ) }
function options ( card : Assignment ) {
const adapterRoutes = props . adapters . filter ( item => item . enabled && item . route ) . map ( item => item . route )
2026-07-15 23:01:07 +08:00
if ( card . kind === "image" ) return Array . from ( new Set ( [ ... adapterRoutes , ... imageRoutes . value . map ( item => item . route ) ] . filter ( Boolean ) ) )
const astrbotRoutes = textRoutes . value . map ( item => item . route )
if ( card . kind === "vision" ) return Array . from ( new Set ( [ props . visionRoute , ... visionRoutes . value . map ( item => item . route ) ] . filter ( Boolean ) ) )
return Array . from ( new Set ( astrbotRoutes . filter ( Boolean ) ) )
2026-07-11 23:48:36 +08:00
}
function optionLabel ( route : string ) {
const adapter = props . adapters . find ( item => item . route === route )
2026-07-15 23:01:07 +08:00
const runtime = runtimeModels . value . find ( item => item . route === route )
if ( runtime ) return ` ${ runtime . name } / ${ runtime . model || runtime . provider _id } `
2026-07-11 23:48:36 +08:00
if ( ! adapter ) return route
return ` ${ adapter . name } ${ adapter . model ? ` · ${ adapter . model } ` : "" } ( ${ route } ) `
}
function update ( key : string , next : string ) { emit ( "update:modelValue" , { ... props . modelValue , [ key ] : next } ) }
2026-07-15 23:01:07 +08:00
function reviewRoutes ( group : ReviewGroup ) {
const configured = props . modelValue [ group . key ]
const routes = Array . isArray ( configured ) && configured . length
? configured . map ( String )
: [ String ( props . modelValue [ group . primaryKey ] || "" ) , String ( props . modelValue [ group . secondaryKey ] || "" ) ]
while ( routes . length < 2 ) routes . push ( "" )
return routes
}
function updateReview ( group : ReviewGroup , index : number , route : string ) {
const next = [ ... reviewRoutes ( group ) ]
2026-07-11 23:48:36 +08:00
next [ index ] = route
2026-07-15 23:01:07 +08:00
emit ( "update:modelValue" , { ... props . modelValue , [ group . key ] : next , [ group . primaryKey ] : next [ 0 ] || "" , [ group . secondaryKey ] : next [ 1 ] || "" } )
2026-07-11 23:48:36 +08:00
}
2026-07-15 23:01:07 +08:00
function addReviewRoute ( group : ReviewGroup ) {
emit ( "update:modelValue" , { ... props . modelValue , [ group . key ] : [ ... reviewRoutes ( group ) , "" ] } )
2026-07-11 23:48:36 +08:00
}
2026-07-15 23:01:07 +08:00
function removeReviewRoute ( group : ReviewGroup , index : number ) {
const current = reviewRoutes ( group )
if ( current . length <= 2 ) return
const next = current . filter ( ( _ , itemIndex ) => itemIndex !== index )
emit ( "update:modelValue" , { ... props . modelValue , [ group . key ] : next , [ group . primaryKey ] : next [ 0 ] || "" , [ group . secondaryKey ] : next [ 1 ] || "" } )
2026-07-11 23:48:36 +08:00
}
2026-07-15 23:01:07 +08:00
function reviewOptions ( group : ReviewGroup , index : number ) {
const current = reviewRoutes ( group )
const selected = new Set ( current . filter ( ( route , itemIndex ) => itemIndex !== index && route ) )
const reviewCard : Assignment = { key : "review" , title : "" , description : "" , recommendation : "" , kind : group . kind , runtime : "active" }
return options ( reviewCard ) . filter ( route => ! selected . has ( route ) || route === current [ index ] )
2026-07-11 23:48:36 +08:00
}
onMounted ( async ( ) => {
2026-07-15 23:01:07 +08:00
try { runtimeModels . value = ( await getJson < { items : RuntimeModel [ ] } > ( endpoints . runtimeModels ) ) . items }
catch { runtimeModels . value = [ ] }
2026-07-11 23:48:36 +08:00
} )
< / script >
< template >
< section class = "assignments" >
< header > < div > < span > 模型分工 < / span > < strong > 按功能节点选择模型路由 < / strong > < p > 生图与素材识别配置会立即进入运行链 ; 标记为 “ 规则引擎 ” 的节点当前保留模型路由 , 启用远程 LLM 后无需重新调整界面 。 < / p > < / div > < / header >
< div class = "grid" >
< article v-for = "card in cards" :key="card.key" >
< div class = "card-head" > < span :class = "card.kind" > { { card . kind === 'image' ? '生图' : card . kind === 'vision' ? '视觉' : '文本' } } < / span > < em :class = "card.runtime" > { { card . runtime === 'active' ? '已接入运行时' : '当前规则引擎' } } < / em > < / div >
< strong > { { card . title } } < / strong >
< p > { { card . description } } < / p >
< div class = "recommendation" > < b > 选型建议 < / b > < span > { { card . recommendation } } < / span > < / div >
< label > < span > 模型路由 < / span > < select :value = "value(card.key)" :disabled = "disabled" @ change = "update(card.key, ($event.target as HTMLSelectElement).value)" > < option value = "" > 自动选择默认路由 < / option > < option v-for ="route in options(card)" :key="route" :value ="route" > {{ optionLabel ( route ) }} < / option > < / select > < / label >
< small > { { card . key } } < / small >
< / article >
2026-07-15 23:01:07 +08:00
< article v-for = "group in reviewGroups" :key="group.key" class="review-group" >
< div class = "card-head" > < span :class = "group.kind" > { { group . kind === 'image' ? '生图' : '视觉' } } < / span > < em class = "active" > 已接入运行时 < / em > < / div >
< div > < strong > { { group . title } } < / strong > < p > { { group . description } } < / p > < / div >
< div class = "recommendation" > < b > 选型建议 < / b > < span > { { group . recommendation } } < / span > < / div >
2026-07-11 23:48:36 +08:00
< div class = "review-routes" >
2026-07-15 23:01:07 +08:00
< label v-for ="(route, index) in reviewRoutes(group)" :key ="index" >
2026-07-11 23:48:36 +08:00
< span > { { index === 0 ? '主审核模型' : index === 1 ? '复核模型' : ` 附加审核模型 ${ index } ` } } < / span >
2026-07-15 23:01:07 +08:00
< div class = "review-select" > < select :value = "route" :disabled = "disabled" @ change = "updateReview(group, index, ($event.target as HTMLSelectElement).value)" > < option value = "" > 请选择不同的模型路由 < / option > < option v-for ="option in reviewOptions(group, index)" :key="option" :value ="option" > {{ optionLabel ( option ) }} < / option > < / select > < button v-if = "index > 1" type="button" :disabled="disabled" title="移除此审核路由" @click="removeReviewRoute(group, index)" > × < / button > < / div >
2026-07-11 23:48:36 +08:00
< / label >
< / div >
2026-07-15 23:01:07 +08:00
< button class = "add-review" type = "button" :disabled = "disabled" @click ="addReviewRoute(group)" > + 添加审核路由 < / button >
< small > { { group . key } } < / small >
2026-07-11 23:48:36 +08:00
< / article >
< / div >
< / section >
< / template >
< style scoped >
. assignments { display : grid ; gap : 14 px } . assignments > header { border : 1 px solid var ( -- border ) ; border - radius : 10 px ; padding : 15 px ; background : linear - gradient ( 105 deg , var ( -- primary - soft ) , var ( -- panel - muted ) ) } . assignments header > div { display : grid ; gap : 4 px } . assignments header span { color : var ( -- text - soft ) ; font - size : 11 px ; font - weight : 800 } . assignments header p , . grid p { margin : 0 ; color : var ( -- text - soft ) ; line - height : 1.5 } . grid { display : grid ; grid - template - columns : repeat ( 2 , minmax ( 0 , 1 fr ) ) ; gap : 11 px } . grid article { display : grid ; gap : 9 px ; border : 1 px solid var ( -- border ) ; border - radius : 10 px ; padding : 14 px ; background : var ( -- panel - muted ) } . card - head { display : flex ; justify - content : space - between } . card - head span , . card - head em { border - radius : 5 px ; padding : 3 px 7 px ; font - size : 10 px ; font - style : normal } . card - head span . image { color : # 7757 e8 ; background : var ( -- primary - soft ) } . card - head span . vision { color : # 25845 a ; background : color - mix ( in srgb , # 39 aa72 13 % , var ( -- panel ) ) } . card - head span . text { color : # a06a12 ; background : color - mix ( in srgb , # e1a53a 15 % , var ( -- panel ) ) } . card - head em { color : var ( -- text - soft ) ; background : var ( -- panel ) } . card - head em . active { color : # 25845 a } . recommendation { display : grid ; grid - template - columns : auto 1 fr ; align - items : start ; gap : 8 px ; border - left : 3 px solid var ( -- primary ) ; border - radius : 4 px ; padding : 8 px 10 px ; background : color - mix ( in srgb , var ( -- primary - soft ) 55 % , var ( -- panel ) ) } . recommendation b { white - space : nowrap ; color : var ( -- primary ) ; font - size : 11 px } . recommendation span { color : var ( -- text - soft ) ; font - size : 12 px ; line - height : 1.55 } . grid label { display : grid ; gap : 5 px } . grid label > span , . grid article > small { color : var ( -- text - soft ) ; font - size : 11 px } . grid select { width : 100 % ; min - height : 39 px ; border : 1 px solid var ( -- border ) ; border - radius : 7 px ; padding : 0 34 px 0 10 px ; color : var ( -- text ) ; background : var ( -- panel ) ; font : inherit ; cursor : pointer } . grid select : disabled { cursor : not - allowed ; opacity : .65 } . review - group { grid - column : 1 / - 1 } . review - routes { display : grid ; grid - template - columns : repeat ( 2 , minmax ( 0 , 1 fr ) ) ; gap : 10 px } . review - select { display : flex ; gap : 7 px } . review - select button { flex : 0 0 39 px ; border : 1 px solid var ( -- border ) ; border - radius : 7 px ; color : # c45151 ; background : var ( -- panel ) ; font - size : 20 px } . add - review { justify - self : start ; border : 1 px dashed var ( -- primary ) ; border - radius : 7 px ; padding : 8 px 13 px ; color : var ( -- primary ) ; background : var ( -- panel ) ; cursor : pointer } @ media ( max - width : 760 px ) { . grid , . review - routes { grid - template - columns : 1 fr } . recommendation { grid - template - columns : 1 fr } }
< / style >