mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-29 03:16:22 -05:00
ai: list custom GGUF files in the Manage tab
A GGUF copied into ai/models/ by hand could be activated by editing ai.yaml, but never appeared in the Manage tab because the catalog endpoint only returned CDN/bundled models. The Active Model dropdown builds from downloaded models, so a custom file was unselectable. The catalog endpoint now merges any on-disk *.gguf that is not in the catalog as a `custom` tier model with its real size and no URL. It is discovered on every request, so a file appears the next time the page loads; the file refresh is not involved and does not index models. Catalog models are never duplicated and in-progress .tmp downloads are ignored. Custom rows read "On disk" and the hint explains the copy-in path, the tool-calling requirement, and the context_size fallback. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
5441d096ae
commit
49ff97c3ad
4 changed files with 77 additions and 3 deletions
|
|
@ -740,12 +740,26 @@ async def read_content(request: Request, file_group_id: int):
|
|||
async def manage_catalog(_: Request):
|
||||
models, source = await catalog.get_models_catalog()
|
||||
models_directory = catalog.get_models_directory()
|
||||
downloaded = {i.name for i in models_directory.glob('*.gguf')} if models_directory.is_dir() else set()
|
||||
on_disk = {i.name: i for i in models_directory.glob('*.gguf')} if models_directory.is_dir() else dict()
|
||||
disk_usage = sum(i.stat().st_size for i in models_directory.glob('*')) if models_directory.is_dir() else 0
|
||||
|
||||
config = get_ai_config()
|
||||
models = [dict(i, downloaded=i['name'] in downloaded, active=i['name'] == config.active_model)
|
||||
models = [dict(i, downloaded=i['name'] in on_disk, active=i['name'] == config.active_model)
|
||||
for i in models]
|
||||
# Any GGUF the user copied into ai/models themselves is a "custom" model. It is discovered
|
||||
# here on every request (no file refresh) so it appears in the Active Model dropdown.
|
||||
catalog_names = {i['name'] for i in models}
|
||||
for name, path in sorted(on_disk.items()):
|
||||
if name not in catalog_names:
|
||||
models.append(dict(
|
||||
name=name,
|
||||
tier='custom',
|
||||
url=None,
|
||||
size=path.stat().st_size,
|
||||
description='Custom model found in ai/models/. Not from the WROLPi catalog.',
|
||||
downloaded=True,
|
||||
active=name == config.active_model,
|
||||
))
|
||||
|
||||
total_ram = catalog.get_total_ram_bytes()
|
||||
return json_response(dict(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue