Files
nix/modules/home/programs/terminal/pi/lib.nix
Evan Reichard 1812d2ea03 feat(pi): add vision model support
Extract a shared hasType helper for model filtering and add
vision (text + image) input capability to compatible models.
Also tag two llama-swap models with the vision type.
2026-05-01 15:03:26 -04:00

70 lines
1.5 KiB
Nix

{ lib }:
let
inherit (lib)
mapAttrs
filterAttrs
any
flatten
listToAttrs
nameValuePair
;
in
{
toPiModels =
llamaSwapConfig:
let
hasType = type: model: any (t: t == type) (model.metadata.type or [ ]);
codingModels = filterAttrs (_name: model: hasType "coding" model) (llamaSwapConfig.models or { });
localModels = mapAttrs
(
name: model:
{
id = name;
inherit (model) name;
}
// (
if model.macros.ctx or null != null then
{
contextWindow = lib.toInt model.macros.ctx;
}
else
{ }
)
// (
if hasType "vision" model then
{
input = [
"text"
"image"
];
}
else
{ }
)
)
codingModels;
peerModels = listToAttrs (
flatten (
map
(
peer:
map
(
modelName:
nameValuePair modelName {
id = modelName;
name = modelName;
}
)
peer.models
)
(builtins.attrValues (llamaSwapConfig.peers or { }))
)
);
in
builtins.attrValues (localModels // peerModels);
}