Files
Strata/apps/host/server/native-vision.mjs
T
Niko1221 44bca4099f App: DeepSeek-V4.1-Flash is ready to read pictures without the Qwen reader program; the Models screen no longer tells its owner to update an engine that is fine, and a load with Read pictures on no longer asks for a vision section it never has (#4772)
The screen looked for strata-vision in the engine folder for every model; DeepSeek carries its own picture tower (--vision on|off), so the check always failed for it and Read pictures stayed off and locked.
2026-10-31 12:51:29 +01:00

25 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/** Prepared vision files stay in the source config; activation belongs to a loaded instance. */
export function runtimeVision(config,requested){
const mode=requested??(config.ui_vision_enabled===false?'no':config.ui_vision_device);
if(mode!==undefined&&!['yes','no','cpu','gpu'].includes(mode))throw new Error('Choose whether to enable picture reading.');
if(mode==='no')return undefined;
if(mode===undefined)return config.vision;
if(!config.vision)throw new Error('Prepare this model’s vision files before enabling picture reading.');
if(mode==='cpu'&&config.vision.cpu_exe){const {cpu_exe,...rest}=config.vision;return {...rest,exe:cpu_exe,gpu:false};} // AMD: the CPU reader program, not the HIP one with the GPU hidden
return {...config.vision,...(mode==='cpu'?{gpu:false}:mode==='gpu'?{gpu:true}:{})};
}
/**
* The catalog with each picture-capable size marked as ready (`images`) or not (`imagesCapable` stays true either way). The Qwen engines
* read pictures with a separate program (strata-vision) that has to sit in the engine folder; DeepSeek-V4.1-Flash (`multi_file`, its own
* engine) carries its own picture tower, so it is ready whatever that folder holds (#4772: it was told to update an engine that was fine).
*/
export function markPictures(catalog,visionReader){
if(!catalog||!Array.isArray(catalog.families))return catalog;
const ready=(s)=>!!s.images&&(s.multi_file===true||visionReader===true);
return {...catalog,families:catalog.families.map(f=>{
const sizes=(f.sizes??[]).map(s=>({...s,imagesCapable:!!s.images,images:ready(s)}));
return {...f,imagesCapable:!!f.images,images:sizes.length?sizes.some(s=>s.images):!!f.images&&visionReader===true,sizes};
})};
}