feat: llm and q

Signed-off-by: jolheiser <git@jolheiser.com>
main
jolheiser 2024-08-07 19:19:51 -05:00
parent b6b22cba13
commit f00799a7ab
No known key found for this signature in database
7 changed files with 92 additions and 0 deletions

View File

@ -14,6 +14,7 @@
./jj.nix
./jq.nix
./lazygit.nix
./llm.nix
./nushell.nix
./oh-my-posh.nix
./senpai.nix

55
apps/nogui/llm.nix 100644
View File

@ -0,0 +1,55 @@
{ pkgs, lib, ... }:
let
claude =
let
inherit (pkgs) fetchFromGitHub nix-update-script python3Packages;
inherit (python3Packages)
buildPythonPackage
setuptools
anthropic
llm
pytestCheckHook
pytest
pytest-recording
;
in
buildPythonPackage rec {
pname = "llm-claude-3";
version = "0.4";
pyproject = true;
src = fetchFromGitHub {
owner = "simonw";
repo = "llm-claude-3";
rev = "refs/tags/${version}";
hash = "sha256-5qF5BK319PNzB4XsLdYvtyq/SxBDdHJ9IoKWEnvNRp4=";
};
build-system = [ setuptools ];
buildInputs = [ llm ];
dependencies = [ anthropic ];
optional-dependencies = {
test = [
pytest
pytest-recording
];
};
# Test suite requires network access to talk to Claude (duh).
nativeCheckInputs = [ pytestCheckHook ];
doCheck = false;
pythonImportsCheck = [ "llm_claude_3" ];
passthru.updateScript = nix-update-script { };
meta = {
description = "LLM plugin for interacting with the Claude 3 family of models";
homepage = "https://github.com/simonw/llm-claude-3";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ jkachmar ];
};
};
in
{
home.packages = [ (pkgs.llm.withPlugins [ claude ]) ];
}

View File

@ -69,6 +69,22 @@ def gomodsri [] {
echo 'nixpkgs.lib.fileContents ./go.mod.sri'
}
def q [
--debug # Debug mode, only echo query
...args: string
] {
let input = $in
mut query = $args | str join ' '
if ($input | is-not-empty) {
$query = $"($query)\n\n($input)"
}
if ($debug) {
print $query
return
}
^llm -s "Answer in as few words as possible. Use a brief style with short replies." -m claude-3.5-sonnet $"($query)"
}
# Run a command if known, otherwise run it with nix
def , [
cmd: string # The command to run

View File

@ -186,6 +186,10 @@
file = ./secrets/shared/cachix.age;
path = "/home/${username}/.config/cachix/cachix.dhall";
};
llm = {
file = ./secrets/shared/llm.age;
path = "/home/${username}/.config/io.datasette.llm/keys.json";
};
};
};
}

View File

@ -12,6 +12,7 @@ switch *args:
@just rebuild switch {{args}}
hm:
@git add .
@home-manager switch --flake . |& nix run nixpkgs#nix-output-monitor
@systemctl --user start agenix.service

View File

@ -20,6 +20,7 @@ in
"shared/irc-pw.age".publicKeys = all;
"shared/gist-pw.age".publicKeys = all;
"shared/git-send-email.age".publicKeys = all;
"shared/llm.age".publicKeys = all;
"personal/restic-env.age".publicKeys = [
jolheiser
dragonwell

View File

@ -0,0 +1,14 @@
age-encryption.org/v1
-> ssh-ed25519 E8j6/g p21/KPTNTZrRXQUvPtlkHZuiFyNGkJWxF/yfhn643gk
jnN29WaHvFjMIjzVe0hkOEcolovBwjcgc2RfDlgY97E
-> ssh-ed25519 xUMv2w Dvet20WUzCfQeoKrdmCb12ouUNlePgFDdKEUZP82PmA
Prj/pjjj+oDqwKq+Q59aSj80YqICcgvulCBVy8CYx5Q
-> ssh-ed25519 ph+d2g vvjz0afKneI+lpiGGm8JuDTlJDlmoUygm/roW1vQphw
imYWGoW9O4MTbwTqXC5+5bH9sBf6qgkEJ8tNDtx6B0E
-> ssh-ed25519 Cuo7gw zUGiEgCtGzwZOVUl5T3jMBdwYzf657jMAbfJ/G1uGX8
jeoWPVh4+AVyGqdZlG1Do3XHT/bwojZsT14I8E3aF1s
-> ssh-ed25519 f31uNA KmRTboipwSZZyDV1d69x4Apn0IjeboMxhmFVJBm72XI
Rgk4ranEXY0mcyBX7nWnW31yKZ8J3hrfzMV5NeQ3tLk
--- RW/X1U5gc3VSKroi8ZAIHZt4tvNShY/viK2TE2WSY4Q
²™|utÖ<74>¤Ù P¦Î²³ÈØ€ÏÜ^¯Ä<G_èB©fD A“<41>xÒÃhËàÍ|§þß<.ÀHF»¦'šP0YŒ'¡<¢õäŒÅ5“ï¢ÒG†™ý¬å Šuζ9ËCz17Lg†Ó‰p^új§<6A>PtÏ:j¶þ?¯½<Ÿs¢ì Ý®³{c<>9¸®ý˜­ç1Tö¼6T\ßSó¤s^©<10>Na©
0¯weÓ&yðšmd9 íš7|cGwØ~ý,Èv4®k˯;Ò9H0ŽfŒ.2Gø€:þ{™ŒWùE