Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): detect PEFT adapter repos by their sibling files

[._.]/ Adam Eivy84925a72b5d3
diff --git a/server/lib/huggingfaceModel.js b/server/lib/huggingfaceModel.js
index ebb3c0559e..5dbc413cc8 100644
--- a/server/lib/huggingfaceModel.js
+++ b/server/lib/huggingfaceModel.js
@@ -167,6 +167,15 @@ const looksLikeLora = ({ repo, model }) => {
if (/\blora\b|\blycoris\b|\blocon\b|\bdora\b/.test(blob)) return true;
const lib = typeof model?.library_name === 'string' ? model.library_name.toLowerCase() : '';
if (lib === 'peft' || lib === 'adapter-transformers') return true;
+ // File-level signal: the standard PEFT adapter layout ships adapter_config.json
+ // + adapter_model.safetensors. A repo carrying these is an adapter even when
+ // its id/tags/library_name don't advertise it — without this check such a repo
+ // (which typically also sets cardData.base_model) would auto-detect as the base
+ // family and register as a base model whose weights from_pretrained() can't load.
+ const files = modelSiblingFilenames(model).map((f) => f.toLowerCase());
+ if (files.some((f) => /(^|\/)adapter_config\.json$/.test(f) || /(^|\/)adapter_model\.(safetensors|bin)$/.test(f))) {
+ return true;
+ }
return false;
};
diff --git a/server/lib/huggingfaceModel.test.js b/server/lib/huggingfaceModel.test.js
index 5997feb7db..1dba94afdf 100644
--- a/server/lib/huggingfaceModel.test.js
+++ b/server/lib/huggingfaceModel.test.js
@@ -84,6 +84,15 @@ describe('classifyHfMediaModel — strict refusal', () => {
})).toThrow(/LoRA adapter/);
});
+ it('refuses a PEFT adapter repo detected by its sibling files (no lora tag)', () => {
+ // adapter_config.json + adapter_model.safetensors is the standard PEFT
+ // layout; the repo advertises no lora tag but is still an adapter.
+ expect(() => classifyHfMediaModel({
+ repo: 'someone/qwen-finetune-adapter',
+ model: hf({ files: ['adapter_config.json', 'adapter_model.safetensors'], base: 'Qwen/Qwen-Image', pipeline: 'text-to-image' }),
+ })).toThrow(/LoRA adapter/);
+ });
+
it('does NOT treat a full base model as a LoRA just because its card sets base_model', () => {
// Full fine-tunes / derived base models legitimately declare base_model but
// ship complete weights — they must remain addable (no lora/peft marker).