mirror of
https://github.com/kmein/niveum
synced 2026-03-29 16:51:07 +02:00
feat(kleim): add gpt, do not remove newlines
This commit is contained in:
@@ -50,6 +50,9 @@
|
|||||||
emojai = pkgs.writers.writeDash "emojai" ''
|
emojai = pkgs.writers.writeDash "emojai" ''
|
||||||
${pkgs.curl}/bin/curl https://www.emojai.app/api/generate -X POST -H 'Content-Type: application/json' --data-raw "$(${pkgs.jq}/bin/jq -sR '{emoji:.}')" | ${pkgs.jq}/bin/jq -r .result
|
${pkgs.curl}/bin/curl https://www.emojai.app/api/generate -X POST -H 'Content-Type: application/json' --data-raw "$(${pkgs.jq}/bin/jq -sR '{emoji:.}')" | ${pkgs.jq}/bin/jq -r .result
|
||||||
'';
|
'';
|
||||||
|
gpt = pkgs.writers.writeDash "gpt" ''
|
||||||
|
${niveumPackages.gpt}/bin/gpt
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -251,6 +251,7 @@
|
|||||||
genius = pkgs.callPackage packages/genius.nix {};
|
genius = pkgs.callPackage packages/genius.nix {};
|
||||||
gfs-fonts = pkgs.callPackage packages/gfs-fonts.nix {};
|
gfs-fonts = pkgs.callPackage packages/gfs-fonts.nix {};
|
||||||
git-preview = pkgs.callPackage packages/git-preview.nix {};
|
git-preview = pkgs.callPackage packages/git-preview.nix {};
|
||||||
|
gpt = pkgs.callPackage packages/gpt.nix {};
|
||||||
hc = pkgs.callPackage packages/hc.nix {};
|
hc = pkgs.callPackage packages/hc.nix {};
|
||||||
heuretes = pkgs.callPackage packages/heuretes.nix {};
|
heuretes = pkgs.callPackage packages/heuretes.nix {};
|
||||||
htgen = pkgs.callPackage packages/htgen.nix {};
|
htgen = pkgs.callPackage packages/htgen.nix {};
|
||||||
|
|||||||
15
packages/gpt.nix
Normal file
15
packages/gpt.nix
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
curl,
|
||||||
|
writers,
|
||||||
|
jq,
|
||||||
|
apiKeyCommand ? "pass api-keys/openai.com",
|
||||||
|
model ? "gpt-3.5-turbo",
|
||||||
|
}:
|
||||||
|
writers.writeDashBin "gpt" ''
|
||||||
|
json=$(jq --slurp --raw-input '{model:"${model}", messages: [{role: "user", content: .}]}')
|
||||||
|
${curl}/bin/curl -sSL https://api.openai.com/v1/chat/completions \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer $(pass api-keys/openai.com)" \
|
||||||
|
-d "$json" \
|
||||||
|
| ${jq}/bin/jq -r '.choices[] | .message.content'
|
||||||
|
''
|
||||||
@@ -49,7 +49,6 @@ in
|
|||||||
${lib.concatStringsSep "\n" (lib.mapAttrsToList scriptCase cfg.scripts)}
|
${lib.concatStringsSep "\n" (lib.mapAttrsToList scriptCase cfg.scripts)}
|
||||||
*) ${pkgs.coreutils}/bin/cat ;;
|
*) ${pkgs.coreutils}/bin/cat ;;
|
||||||
esac \
|
esac \
|
||||||
| tr -d '\r\n' \
|
|
||||||
| ${pkgs.xclip}/bin/xclip -selection ${cfg.selection} -in
|
| ${pkgs.xclip}/bin/xclip -selection ${cfg.selection} -in
|
||||||
|
|
||||||
${pkgs.libnotify}/bin/notify-send --app-name="klem" "Result copied to clipboard."
|
${pkgs.libnotify}/bin/notify-send --app-name="klem" "Result copied to clipboard."
|
||||||
|
|||||||
Reference in New Issue
Block a user