Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
47 lines
1.5 KiB
Nix
47 lines
1.5 KiB
Nix
# The `...` allows this derivation to be overridden with `enable-<llm-plugin>`.
|
|
#
|
|
# Example:
|
|
#
|
|
# ```nix
|
|
# llm.override {
|
|
# enable-llm-anthropic = true;
|
|
# enable-llm-gemini = true;
|
|
# enable-llm-cmd = true;
|
|
# enable-llm-templates-github = true;
|
|
# }
|
|
# ```
|
|
#
|
|
# Whatever names are accepted by `llm.withPlugins` are accepted with an added `enable-` prefix as
|
|
# an override of this derivation. The user can also do `llm.withPlugins { llm-anthropic = true; }`.
|
|
{ lib, python3Packages, ... }@args:
|
|
|
|
let
|
|
inherit (python3Packages) llm;
|
|
|
|
hasEnablePrefix = lib.hasPrefix "enable-";
|
|
addEnablePrefix = name: "enable-${name}";
|
|
removeEnablePrefix = lib.removePrefix "enable-";
|
|
|
|
# Filter to just the attributes which are named "enable-<plugin-name>"
|
|
enableArgs = lib.filterAttrs (name: value: hasEnablePrefix name) args;
|
|
pluginArgs = lib.mapAttrs' (
|
|
name: value: lib.nameValuePair (removeEnablePrefix name) value
|
|
) enableArgs;
|
|
|
|
# Provide some diagnostics for the plugin names
|
|
pluginNames = lib.attrNames (lib.functionArgs llm.withPlugins);
|
|
enableNames = lib.map addEnablePrefix pluginNames;
|
|
unknownPluginNames = lib.removeAttrs pluginArgs pluginNames;
|
|
unknownNames = lib.map addEnablePrefix (lib.attrNames unknownPluginNames);
|
|
unknownNamesDiagnostic = ''
|
|
Unknown plugins specified in override: ${lib.concatStringsSep ", " unknownNames}
|
|
|
|
Valid overrides:
|
|
- ${lib.concatStringsSep "\n - " enableNames}
|
|
'';
|
|
in
|
|
|
|
assert lib.assertMsg (lib.length unknownNames == 0) unknownNamesDiagnostic;
|
|
|
|
llm.withPlugins pluginArgs
|