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
This commit is contained in:
@@ -30,6 +30,7 @@ in
|
|||||||
k9s = enabled;
|
k9s = enabled;
|
||||||
nvim = enabled;
|
nvim = enabled;
|
||||||
opencode = enabled;
|
opencode = enabled;
|
||||||
|
pi = enabled;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
46
modules/home/programs/terminal/pi/default.nix
Executable file
46
modules/home/programs/terminal/pi/default.nix
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
{ lib
|
||||||
|
, pkgs
|
||||||
|
, config
|
||||||
|
, namespace
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
|
helpers = import ./lib.nix { inherit lib; };
|
||||||
|
llamaSwapConfig = import ./../../../../nixos/services/llama-swap/config.nix { inherit pkgs; };
|
||||||
|
|
||||||
|
cfg = config.${namespace}.programs.terminal.pi;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.${namespace}.programs.terminal.pi = {
|
||||||
|
enable = lib.mkEnableOption "enable pi";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
# Add Pi Coding Agent to Home Packages
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
reichard.pi-coding-agent
|
||||||
|
];
|
||||||
|
|
||||||
|
# Define Pi Configuration
|
||||||
|
sops = {
|
||||||
|
secrets.context7_apikey = {
|
||||||
|
sopsFile = lib.snowfall.fs.get-file "secrets/common/evanreichard.yaml";
|
||||||
|
};
|
||||||
|
templates."pi.json" = {
|
||||||
|
path = "${config.home.homeDirectory}/.pi/agent/models.json";
|
||||||
|
content = builtins.toJSON {
|
||||||
|
providers = {
|
||||||
|
"llama-swap" = {
|
||||||
|
baseUrl = "https://llm-api.va.reichard.io/v1";
|
||||||
|
api = "openai-completions";
|
||||||
|
apiKey = "none";
|
||||||
|
models = helpers.toPiModels llamaSwapConfig;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
60
modules/home/programs/terminal/pi/lib.nix
Normal file
60
modules/home/programs/terminal/pi/lib.nix
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
{ 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);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user