Model Library sidebar: allow searching metadata (#1148)

* Model Library sidebar: allow searching metadata

title, description, etc

* don't use vue stuff inside of vue because vue doesn't support vue

very cool

* remove old import

* and that one
This commit is contained in:
Alex "mcmonkey" Goodwin
2024-10-07 11:50:45 -07:00
committed by GitHub
parent 99c948f578
commit ff1ca268a4
2 changed files with 18 additions and 1 deletions

View File

@@ -83,7 +83,7 @@ const root: ComputedRef<TreeNode> = computed(() => {
if (searchQuery.value) {
const search = searchQuery.value.toLocaleLowerCase()
modelList = modelList.filter((model: ComfyModelDef) => {
return model.file_name.toLocaleLowerCase().includes(search)
return model.searchable.includes(search)
})
}
const tree: TreeNode = buildTree(modelList, (model: ComfyModelDef) => {

View File

@@ -48,6 +48,8 @@ export class ComfyModelDef {
is_load_requested: boolean = false
/** If true, this is a fake model object used as a placeholder for something (eg a loading icon) */
is_fake_object: boolean = false
/** A string full of auto-computed lowercase-only searchable text for this model */
searchable: string = ''
constructor(name: string, directory: string) {
this.file_name = name
@@ -60,6 +62,20 @@ export class ComfyModelDef {
}
this.title = this.simplified_file_name
this.directory = directory
this.updateSearchable()
}
updateSearchable() {
this.searchable = [
this.file_name,
this.title,
this.author,
this.description,
this.trigger_phrase,
this.tags.join(', ')
]
.join('\n')
.toLowerCase()
}
/** Loads the model metadata from the server, filling in this object if data is available */
@@ -110,6 +126,7 @@ export class ComfyModelDef {
_findInMetadata(metadata, 'modelspec.tags', 'tags') || ''
this.tags = tagsCommaSeparated.split(',').map((tag) => tag.trim())
this.has_loaded_metadata = true
this.updateSearchable()
} catch (error) {
console.error('Error loading model metadata', this.file_name, this, error)
}