fix(user/malte): better heygpt integration

This commit is contained in:
Malte Tammena 2023-12-14 10:29:29 +01:00
parent c1804e7fe7
commit a106e6a990
3 changed files with 39 additions and 18 deletions

View file

@ -0,0 +1,13 @@
diff --git a/src/main.rs b/src/main.rs
index 7263c4c..f0ba36d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -31,7 +31,7 @@ struct Options {
/// The model to query (default: gpt-3.5-turbo)
#[default(String::from("gpt-3.5-turbo"))]
- #[arg(long)]
+ #[arg(long, default_value = "gpt-3.5-turbo")]
pub model: String,
/// OpenAI API key

View file

@ -44,6 +44,23 @@
firefox -P "${profile}"
'';
};
heygptRaw = pkgs.heygpt.overrideAttrs (_: {
src = builtins.trace "REMOVE heygpt override after hash fix lands" (pkgs.fetchFromGitHub {
owner = "fuyufjh";
repo = "heygpt";
rev = "v0.4.1";
hash = "sha256-oP0yIdYytXSsbZ2pNaZ8Rrak1qJsudTe/oP6dGncGUM=";
});
patches = [../../patches/heygpt-default-model.patch];
});
heygptWrapper = pkgs.writeShellApplication {
name = "heygpt";
text = ''
OPENAI_API_KEY=$(cat ${nixosConfig.sops.secrets.openai-heygpt-api-key.path}) ${heygptRaw}/bin/heygpt "$@"
'';
};
in {
imports = [
./git.nix
@ -85,22 +102,21 @@ in {
(firefoxWithProfile "ff-work" "Work")
]
++ (with pkgs; [
aseprite
alejandra
aseprite
element-desktop-wayland
signal-desktop # FIXME: Once it works again? (fixElectron "signal-desktop" signal-desktop)
feh
(fixElectron "mattermost-desktop" mattermost-desktop)
(fixGdk "Discord" discord)
(fixGdk "losslesscut" losslesscut-bin)
(fixGdk "skypeforlinux" skypeforlinux)
pkgs."2i-emulator"
(fixElectron "mattermost-desktop" mattermost-desktop)
feh
# geekbench
gimp
gnome3.nautilus
gnome3.sushi
gnome.simple-scan
helvum
heygptWrapper
hledger
inkscape
kbdlight
@ -111,26 +127,29 @@ in {
patchelf
pavucontrol
pdftk
pkgs."2i-emulator"
ponymix
pulseaudio
python3
qt5ct
rtorrent
screenfetch
signal-desktop # FIXME: Once it works again? (fixElectron "signal-desktop" signal-desktop)
sshfs
tdesktop
unar
unison
vlc
vscode
wev
xdg_utils
xournalpp
yt-dlp # youtube-dl alternative that doesn't suck
wev
]);
sessionVariables = {
MOZ_USE_XINPUT2 = "1";
OPENAI_API_BASE = "https://api.openai.com/v1";
};
# Use default US, so that games don't get too confused. But let me

View file

@ -17,14 +17,6 @@ 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 = {
@ -104,7 +96,7 @@ in {
'';
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
heygpt --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
'';
};
@ -124,9 +116,6 @@ 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
'';
};