From c1804e7fe780e3694f55930d1a338674d16d96da Mon Sep 17 00:00:00 2001 From: Malte Tammena Date: Tue, 12 Dec 2023 22:15:10 +0100 Subject: [PATCH] feat(user/malte): openai helper tool "heygpt" --- modules/malte.nix | 3 +++ secrets/users/malte/secrets.yaml | 5 +++-- users/malte/shell.nix | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/malte.nix b/modules/malte.nix index 1371e25..17d591a 100644 --- a/modules/malte.nix +++ b/modules/malte.nix @@ -88,6 +88,9 @@ in { radicale-password = { inherit sopsFile owner mode; }; + openai-heygpt-api-key = { + inherit sopsFile owner mode; + }; pw-mail-pm = { inherit sopsFile owner mode; }; diff --git a/secrets/users/malte/secrets.yaml b/secrets/users/malte/secrets.yaml index 2190216..6ce2edc 100644 --- a/secrets/users/malte/secrets.yaml +++ b/secrets/users/malte/secrets.yaml @@ -4,6 +4,7 @@ pw-mail-pm: ENC[AES256_GCM,data:v3EqEZyuy6r8qveDlq7t+UuyK7m2Zg==,iv:96HpxVd8bRub pw-mail-uni: ENC[AES256_GCM,data:CRZn0nNnwZRYETbpiWY=,iv:CAncz9DWCo89ffnLrRqCp6djV24ZFwC7KrdVi9w3p7A=,tag:/mw3lIuUWCeqwbo/15HjOA==,type:str] pw-mail-gmx: ENC[AES256_GCM,data:byvzb3zSVOHLjGzHwx43h0YhMoeDvUR2/g==,iv:tQEg751oi+LIjJ1dzW4Kv/irSgTCIuh2Fl4YQ0Pm6M8=,tag:1Uarz2dCkpTmJIh+/HYeEA==,type:str] pw-mail-schulverwalter: ENC[AES256_GCM,data:jEFDG1EDywlwdrB/5KlrLYxde0CTSaOxtjLgC0lZbl0=,iv:pYhX7cihkK7HfXoFe8lfkZ4G0TVuSKLIDUXZnh6P60Y=,tag:zMh13xBGsnjpvtci7EnFNg==,type:str] +openai-heygpt-api-key: ENC[AES256_GCM,data:iC4NkkbMB2WIN9Z1Nw+KWPKG2NUitpH1EUrBfGFTta6y0XLRDs0o6D01EyF3vXOiEOcd,iv:W47ORUJv3KNTBBlFrBQvMAYvf3aeNFkSGYomirK/2xM=,tag:jBFjAfsk8TSmxBxge9zFeQ==,type:str] sftp-key: ENC[AES256_GCM,data:4DTZnkaLvzeoGQowHqpcZfvvZls8LsOd/4ER5Fzw135nLDogVQWDN2ae8ce2CeCbfl4ZqCZNAlEueg3SIJ8Ew10zVkac4wU7mal1MPvqsDjH+ufiBIs5100DOCkWn376U0eZ/AVuwYY8/CA1ZeZ+LfQU3grpnN/9I4Q8QCZqW4zlPSJtF7V5/fU4Na1gJswKeaFXMdT7O+JWpfqb2jLl3HUO7m69VYlOD9/B8BcOU1PSfJGhat1bzeiNB6h22eEoZtUtLoF9P+O11IrOMiHbK610gSH8TM64Fu1Y8a7rx/UtlYpeDs1FA28Ldrb+YxZHfhJbhp8xNX/22NaDSDwFnZLIaY0KOv3lzICqpAmLB9s2r4kOAw64dopgYdw+XXb8qQ4o2iOwWQ3HCXCqKLxImRubktQu3jD6AOPoCDcDwPqzNfPDoo+OWNAGpLSS9LGN8+uRgtNIkfCEx+cU3gU9HhvBmbXVUFLObpNFo7XZJj3l/mHWKZ/rOKpyX8c6+Hx4zlQfUrChxt65X8f/8rSyB3Nq9SqCELBiaINu,iv:nUp0rBZjCyibnmVV8qIsFXmfqAjWExh5bH50ynVFwj0=,tag:TiaKa+lK0m6JC8tGcrfqIw==,type:str] sops: kms: [] @@ -38,8 +39,8 @@ sops: U05rN3hQTFkxTHFDVnpZWGxNY25maFUKdrn4Jtqc9U9GXyRAPhHE8iyVFL5NvnrZ 0KVOCWycdGVltDjTFVpyLoCiwZcTDDza/vjFcCro1zgcsdVuPl0orA== -----END AGE ENCRYPTED FILE----- - lastmodified: "2023-11-18T10:07:07Z" - mac: ENC[AES256_GCM,data:lJZrTJUBBvdAlcJIXLiy2x+tCDdyFdR1mCsh4Zju6Qzl/GMthghLTTrn9VcHSxD6TBuLb49+SYpy1XNTQUzI8czftcnEaGlF1k1y3TOSE+1PzEiPsMmIafCq+8ke1bJE0d+y0DT1Qsk+pjpbtht5iKJnR2zasd1h2kSJgjOyHR0=,iv:LygZWWT2YNw4opQAvzNgfFkNdyJQcXKkRB48kFgjxpE=,tag:St89/E1Nj2Jl4tFM+iDf6w==,type:str] + lastmodified: "2023-12-12T11:48:30Z" + mac: ENC[AES256_GCM,data:oBTR5BBuAOlNdcdkVI9pl3XKLZkAQMYLzqyI1f81izG7qL/dWO6F0PQqVxZwBcf7BQjlfRIXRjzVW41EFd85I1m2q1o+/2LWZY7a6qtuWe3nyNswrXI2q1uPInASfil9GX0Kht1pgy2WeSsjYOKGcGDTkHaAABfMRSfyT4DJRk4=,iv:j7XwHgPbtpFHzZLHv7L/oMLdIslNdSxcm4qUgse23w8=,tag:r9w1u5L8C7zx+Lq+wWNbvg==,type:str] pgp: - created_at: "2023-11-18T10:06:28Z" enc: |- diff --git a/users/malte/shell.nix b/users/malte/shell.nix index ac85ad4..f80ee1b 100644 --- a/users/malte/shell.nix +++ b/users/malte/shell.nix @@ -17,6 +17,14 @@ in { python39.pkgs.xkcdpass silicon mdcat + (heygpt.overrideAttrs (_: { + src = builtins.trace "REMOVE heygpt override after hash fix lands" (fetchFromGitHub { + owner = "fuyufjh"; + repo = "heygpt"; + rev = "v0.4.1"; + hash = "sha256-oP0yIdYytXSsbZ2pNaZ8Rrak1qJsudTe/oP6dGncGUM="; + }); + })) ]; programs.fish = { @@ -95,6 +103,9 @@ in { wl-paste | silicon -f 'Hack Nerd Font FC Ligatured' --pad-horiz 40 --pad-vert 50 --theme gruvbox --shadow-blur-radius 30 -b '#ebdbb2' --shadow-color '#282828' --no-window-controls --output /tmp/image.png $argv && wl-copy < /tmp/image.png ''; nonix = "sed 's:/nix/store/[^-]\\+-\\([^/ ]*\\):< \\1>:g'"; + c = '' + heygpt --api-key $OPENAI_API_KEY --api-base-url $OPENAI_API_BASE --model gpt-3.5-turbo --system "Imagine you are linux terminal command selector. I will describe task, and you will respond only using linux command, without description, without explanation." $argv + ''; }; shellInit = '' @@ -113,6 +124,9 @@ in { set -g fish_color_autosuggestion brblack set -g fish_color_cancel red --bold set -g fish_color_valid_path normal --bold + + set -g OPENAI_API_KEY (cat /run/secrets/openai-heygpt-api-key) + set -g OPENAI_API_BASE https://api.openai.com/v1 ''; };