mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
aichat: add agents option
This commit is contained in:
parent
35329d44f3
commit
e3e15e765d
4 changed files with 77 additions and 12 deletions
|
|
@ -11,7 +11,7 @@ let
|
||||||
|
|
||||||
settingsFormat = pkgs.formats.yaml { };
|
settingsFormat = pkgs.formats.yaml { };
|
||||||
|
|
||||||
inherit (pkgs.stdenv.hostPlatform) isLinux isDarwin;
|
inherit (pkgs.stdenv.hostPlatform) isDarwin;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
meta.maintainers = [
|
meta.maintainers = [
|
||||||
|
|
@ -56,19 +56,53 @@ in
|
||||||
for supported values.
|
for supported values.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
agents = lib.mkOption {
|
||||||
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
type = lib.types.attrsOf settingsFormat.type;
|
||||||
|
default = { };
|
||||||
home.file."Library/Application Support/aichat/config.yaml" =
|
example = {
|
||||||
mkIf (cfg.settings != { } && (isDarwin && !config.xdg.enable))
|
openai = {
|
||||||
{
|
model = "openai:gpt-4o";
|
||||||
source = settingsFormat.generate "aichat-config" cfg.settings;
|
temperature = 0.5;
|
||||||
|
top_p = 0.7;
|
||||||
|
use_tools = "fs,web_search";
|
||||||
|
agent_prelude = "default";
|
||||||
};
|
};
|
||||||
|
|
||||||
xdg.configFile."aichat/config.yaml" = mkIf (cfg.settings != { } && (isLinux || config.xdg.enable)) {
|
llama = {
|
||||||
source = settingsFormat.generate "aichat-config" cfg.settings;
|
model = "llama3.2:latest";
|
||||||
|
temperature = 0.5;
|
||||||
|
use_tools = "web_search";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Agent-specific configurations. See
|
||||||
|
<https://github.com/sigoden/aichat/wiki/Configuration-Guide#agent-specific>
|
||||||
|
for supported values.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
config =
|
||||||
|
let
|
||||||
|
aichatConfigPath =
|
||||||
|
if (isDarwin && !config.xdg.enable) then
|
||||||
|
"Library/Application Support/aichat"
|
||||||
|
else
|
||||||
|
"${lib.removePrefix config.home.homeDirectory config.xdg.configHome}/aichat";
|
||||||
|
in
|
||||||
|
mkIf cfg.enable {
|
||||||
|
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||||
|
home.file = {
|
||||||
|
"${aichatConfigPath}/config.yaml" = mkIf (cfg.settings != { }) {
|
||||||
|
source = settingsFormat.generate "aichat-config" cfg.settings;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// (lib.mapAttrs' (
|
||||||
|
k: v:
|
||||||
|
lib.nameValuePair "${aichatConfigPath}/agents/${k}/config.yaml" {
|
||||||
|
source = settingsFormat.generate "aichat-agent-${k}" v;
|
||||||
|
}
|
||||||
|
) cfg.agents);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
tests/modules/programs/aichat/llama.yaml
Normal file
3
tests/modules/programs/aichat/llama.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
model: llama3.2:latest
|
||||||
|
temperature: 0.5
|
||||||
|
use_tools: web_search
|
||||||
5
tests/modules/programs/aichat/openai.yaml
Normal file
5
tests/modules/programs/aichat/openai.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
agent_prelude: default
|
||||||
|
model: openai:gpt-4o
|
||||||
|
temperature: 0.5
|
||||||
|
top_p: 0.7
|
||||||
|
use_tools: fs,web_search
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
{ ... }:
|
|
||||||
{
|
{
|
||||||
programs.aichat = {
|
programs.aichat = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
@ -18,10 +17,34 @@
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
agents = {
|
||||||
|
openai = {
|
||||||
|
model = "openai:gpt-4o";
|
||||||
|
temperature = 0.5;
|
||||||
|
top_p = 0.7;
|
||||||
|
use_tools = "fs,web_search";
|
||||||
|
agent_prelude = "default";
|
||||||
|
};
|
||||||
|
|
||||||
|
llama = {
|
||||||
|
model = "llama3.2:latest";
|
||||||
|
temperature = 0.5;
|
||||||
|
use_tools = "web_search";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-files/.config/aichat/config.yaml
|
assertFileExists home-files/.config/aichat/config.yaml
|
||||||
assertFileContent home-files/.config/aichat/config.yaml \
|
assertFileContent home-files/.config/aichat/config.yaml \
|
||||||
${./settings.yml}
|
${./settings.yml}
|
||||||
|
|
||||||
|
assertFileExists home-files/.config/aichat/agents/openai/config.yaml
|
||||||
|
assertFileExists home-files/.config/aichat/agents/llama/config.yaml
|
||||||
|
assertFileContent home-files/.config/aichat/agents/openai/config.yaml \
|
||||||
|
${./openai.yaml}
|
||||||
|
assertFileContent home-files/.config/aichat/agents/llama/config.yaml \
|
||||||
|
${./llama.yaml}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue