Files
nix/modules/home/programs/terminal/pi/lib.nix
Evan Reichard f2b821b122 feat(home): add pi coding agent configuration
- Add pi module for terminal configuration
- Include pi-coding-agent package in home.packages
- Configure pi with llama-swap provider via models.json
- Enable pi for mac-va-mbp-work profile
2026-02-05 13:57:02 -05:00

61 lines
1.2 KiB
Nix

{ lib }:
let
inherit (lib)
mapAttrs
filterAttrs
any
flatten
listToAttrs
nameValuePair
;
in
{
toPiModels =
llamaSwapConfig:
let
textGenModels = filterAttrs
(
name: model: any (t: t == "text-generation") (model.metadata.type or [ ])
)
(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
{ }
)
)
textGenModels;
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);
}