Home

dotnix @main - refs - log -
-
https://git.jolheiser.com/dotnix.git
My nix dotfiles
tree log patch
feat: llm and q Signed-off-by: jolheiser <git@jolheiser.com>
Signature
-----BEGIN SSH SIGNATURE----- U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5 AAAAQBIepJGRvLUHD2TKJiEX7v0K5hFBL+QV2EPUflFfCF1S6sO5TJFVle+HfsWyH97QuM jg8zYV9srM2Qx8C/Ix+AE= -----END SSH SIGNATURE-----
jolheiser <git@jolheiser.com>
1 month ago
7 changed files, 93 additions(+), 0 deletions(-)
M apps/nogui/default.nix -> apps/nogui/default.nix
diff --git a/apps/nogui/default.nix b/apps/nogui/default.nix
index cfabab80bda9b7788d5847c95dd09ec9a4d76d5b..1d4c04fc2ed25f762af1abb835238f8e1689ff03 100644
--- a/apps/nogui/default.nix
+++ b/apps/nogui/default.nix
@@ -14,6 +14,7 @@     #./helix.nix
     ./jj.nix
     ./jq.nix
     ./lazygit.nix
+    ./llm.nix
     ./nushell.nix
     ./oh-my-posh.nix
     ./senpai.nix
I apps/nogui/llm.nix
diff --git a/apps/nogui/llm.nix b/apps/nogui/llm.nix
new file mode 100644
index 0000000000000000000000000000000000000000..07a62753081e8e6529fc23e0d98a64fc61538246
--- /dev/null
+++ b/apps/nogui/llm.nix
@@ -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 ]) ];
+}
M apps/nogui/nushell/jolheiser.nu -> apps/nogui/nushell/jolheiser.nu
diff --git a/apps/nogui/nushell/jolheiser.nu b/apps/nogui/nushell/jolheiser.nu
index ee508fd02363e70a935f5a4969034cce3327ed69..c9ff05362ca9f56a6690623eab2c898678eb1209 100644
--- a/apps/nogui/nushell/jolheiser.nu
+++ b/apps/nogui/nushell/jolheiser.nu
@@ -69,6 +69,22 @@   rm -rf $tmp
   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
M flake.nix -> flake.nix
diff --git a/flake.nix b/flake.nix
index ffd16417a39b51cae04798bb8be29aa9cd6b7d93..c5edb42a109947ca87d0d5d0690e31847e7f41f6 100644
--- a/flake.nix
+++ b/flake.nix
@@ -187,6 +187,11 @@                 file = ./secrets/shared/cachix.age;
                 path = "/home/${username}/.config/cachix/cachix.dhall";
               };
 {
+          };
+                file = ./secrets/shared/llm.age;
+                path = "/home/${username}/.config/io.datasette.llm/keys.json";
+              };
+{
     resume = {
           };
         }
M justfile -> justfile
diff --git a/justfile b/justfile
index bd211f59f7734b611558c9ad7259c3af98df44ac..24bc25406e22af6b55e8ff1b301b3f339afbfe00 100644
--- a/justfile
+++ b/justfile
@@ -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
 
M secrets/secrets.nix -> secrets/secrets.nix
diff --git a/secrets/secrets.nix b/secrets/secrets.nix
index 58cd8391a538bfef560666fd156376f638dead5c..a2c3d3458ff2528fe3856a139b332da81212d54a 100644
--- a/secrets/secrets.nix
+++ b/secrets/secrets.nix
@@ -20,6 +20,7 @@   "shared/spotify.age".publicKeys = all;
   "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
I secrets/shared/llm.age
diff --git a/secrets/shared/llm.age b/secrets/shared/llm.age
new file mode 100644
index 0000000000000000000000000000000000000000..6ca7f7dca18b325eb5deb7fe34193ae2c5b77436
--- /dev/null
+++ b/secrets/shared/llm.age
@@ -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֐���P���f�������^��<G_�B�fDA��x��h���|���<.�HF��'�P0Y�'�<�����5����G����� �uζ9�Cz17Lg�Ӊp^�j��Pt�:j��?��<�s��	���{c�9����	hӭ�1T��6T\�S��s^��Na�
+0�we�&y��md9
횋7|cGw�~�,�v4�k˯;�9H0�f�.2G��:�{��W�E
\ No newline at end of file