mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-02 20:59:56 -05:00
ai: list custom GGUF files in the Manage tab (#720)
* 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> * ai: only list custom GGUFs llama-server can load; reset context on custom select Review found two gaps in the custom-model listing. Any *.gguf basename was listed and accepted, but start_llama_server.sh reads active_model back out of ai.yaml through read_config_value.sh. PyYAML dumps non-ASCII as escapes the reader prints literally, the reader strips " #..." before unquoting, and the start script's traversal guard rejects any ".." run. Those names got a 200 from the API and then "Model file does not exist" at startup. A shared is_loadable_model_name check now filters the catalog loop and rejects the name in manage_settings, so the UI never shows an activation that cannot start. Directories named *.gguf are skipped too. Selecting a custom model after a catalog model kept the previous model's explicit context_size (e.g. 16384 from the 4B) because the adopt branch was skipped when there was no catalog default. The default is now always written on model selection, so a custom model resets to null and the conservative default applies. The hint text says so instead of claiming the default is used unconditionally. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
168f194512
commit
4b3c6510b4
5 changed files with 162 additions and 6 deletions
|
|
@ -26,7 +26,9 @@ export function AiModelRow({model, onDownload}) {
|
|||
<Table.Cell>{humanFileSize(size)}</Table.Cell>
|
||||
<Table.Cell>
|
||||
{downloaded
|
||||
? <Button size='xs' icon='check' disabled role='save'>Downloaded</Button>
|
||||
? <Button size='xs' icon='check' disabled role='save'>
|
||||
{tier === 'custom' ? 'On disk' : 'Downloaded'}
|
||||
</Button>
|
||||
: <APIButton size='xs' icon='download' color='violet' onClick={() => onDownload(model)}>
|
||||
Download
|
||||
</APIButton>}
|
||||
|
|
@ -184,6 +186,11 @@ export function ManageAi() {
|
|||
<p>The AI assistant runs entirely on this WROLPi — no internet is needed after a model
|
||||
is downloaded. Download a model, select it, then enable the assistant. Monitor
|
||||
download progress on the <b>Downloads</b> page.</p>
|
||||
<p>You can also copy your own GGUF file into <b>ai/models/</b>; it will appear here as a
|
||||
<b>custom</b> model the next time this page loads. Use a plain ASCII file name without
|
||||
<b>#</b>, quotes, or <b>..</b>. The model must support tool calling (Qwen3, Llama 3.x,
|
||||
and Mistral instruct models do). Selecting a custom model resets the context size to the
|
||||
default; set <b>context_size</b> in <b>ai.yaml</b> to override it.</p>
|
||||
</InfoMessage>
|
||||
</>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,6 +104,24 @@ describe('ManageAi', () => {
|
|||
await waitFor(() => expect(postAiSettings).toHaveBeenCalledWith({enabled: true}));
|
||||
});
|
||||
|
||||
it('lists a custom GGUF from ai/models in the Active Model dropdown', async () => {
|
||||
const custom = {
|
||||
name: 'My-Custom-Model-Q8_0.gguf', tier: 'custom', size: 3_000_000_000, url: null,
|
||||
description: 'Custom model found in ai/models/. Not from the WROLPi catalog.',
|
||||
downloaded: true, active: false,
|
||||
};
|
||||
const fixture = catalogFixture();
|
||||
getAiCatalog.mockResolvedValue({...fixture, models: [...fixture.models, custom]});
|
||||
render(<ManageAi/>);
|
||||
await waitFor(() => expect(screen.getByText('On disk')).toBeInTheDocument());
|
||||
expect(screen.getByRole('cell', {name: 'custom'})).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole('textbox', {name: 'Active Model'}));
|
||||
const option = await screen.findByRole('option', {name: 'My-Custom-Model-Q8_0.gguf'});
|
||||
fireEvent.click(option);
|
||||
await waitFor(() => expect(postAiSettings).toHaveBeenCalledWith({active_model: 'My-Custom-Model-Q8_0.gguf'}));
|
||||
});
|
||||
|
||||
it('shows the slow-hardware warning on a Pi 4', async () => {
|
||||
getAiCatalog.mockResolvedValue(catalogFixture({slow_hardware: true}));
|
||||
render(<ManageAi/>);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue