answer
This commit is contained in:
@@ -27,8 +27,9 @@ nnoremap <leader>t :action Terminal.OpenInTerminal<CR>
|
||||
nnoremap <leader>q :action QuickJavaDoc<CR>
|
||||
nnoremap <leader>f :action Find<CR>
|
||||
nnoremap <leader>r :action Replace<CR>
|
||||
map f <Plug>(easymotion-bd-f)
|
||||
map <leader>f <Plug>(easymotion-bd-w)
|
||||
" broken in latest version of idea vim?
|
||||
"map f <Plug>(easymotion-bd-f)
|
||||
"map <leader>f <Plug>(easymotion-bd-w)
|
||||
|
||||
nnoremap J mzJ`z
|
||||
nnoremap S ht lr<cr>k$
|
||||
|
||||
@@ -373,6 +373,7 @@ in
|
||||
path = "/synced/fh/master/ot_fundamentals_and_security/merged";
|
||||
node = "${pkgs.nodejs}/bin/node";
|
||||
set-monitor = "~/.config/hypr/monitor-config.js";
|
||||
answer = "${pkgs.answer}/bin/answer";
|
||||
in
|
||||
''
|
||||
bind = $mainMod, A, submap, notes
|
||||
@@ -392,7 +393,7 @@ in
|
||||
bind = $mainMod, N, exec, ${dunstify} "$(${wl-paste})"
|
||||
bind = $mainMod, D, exec, ${dunstctl} close-all
|
||||
## I win
|
||||
#bind = $mainMod, W, exec, ${wl-paste} | sgpt --model="gpt-4o" "Respond with the correct answer to the following question." | ${wl-copy}
|
||||
bind = $mainMod, W, exec, ${wl-paste} | ${answer} "Respond with the correct answer to the following question." | ${wl-copy} && ${dunstify} -t 150 Done
|
||||
## notes
|
||||
|
||||
#bind = $mainMod, 2, exec, cat ~/Nextcloud/test.txt | ${wl-copy}
|
||||
|
||||
@@ -93,6 +93,7 @@ in {
|
||||
compsize
|
||||
trashy # move files to trash
|
||||
#shell-gpt #openai bitches stole my credits :(
|
||||
answer
|
||||
libheif # convert heic to jpg with `heif-convert something.heic something.jpg`
|
||||
imagemagick # convert images
|
||||
tree
|
||||
|
||||
13
pkgs/answer/default.nix
Normal file
13
pkgs/answer/default.nix
Normal file
@@ -0,0 +1,13 @@
|
||||
{ stdenv, nodejs, ... }:
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "answer";
|
||||
version = "1.0";
|
||||
src = ./src;
|
||||
nativeBuildInputs = [ nodejs ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp $src/answer.js $out/bin/answer
|
||||
chmod +x $out/bin/answer
|
||||
'';
|
||||
}
|
||||
50
pkgs/answer/src/answer.js
Executable file
50
pkgs/answer/src/answer.js
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
async function promptGpt(message) {
|
||||
let body = JSON.stringify({
|
||||
model: "openai",
|
||||
stream: false,
|
||||
temperature: 1,
|
||||
top_p: 1,
|
||||
messages: [
|
||||
{ role: "system", content: "Your are a helpful assistant that provides brief responses unless asked for more details." },
|
||||
{ role: "user", content: message }
|
||||
]
|
||||
})
|
||||
let response = await fetch('https://text.pollinations.ai/openai', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
let data = await response.json();
|
||||
return data.choices[0].message.content;
|
||||
}
|
||||
|
||||
async function trick17(args) {
|
||||
const getStdin = async () => {
|
||||
const chunks = [];
|
||||
for await (const chunk of process.stdin) chunks.push(chunk);
|
||||
return Buffer.concat(chunks).toString();
|
||||
};
|
||||
|
||||
let stdin = await getStdin();
|
||||
//console.log("Received stdin:", stdin);
|
||||
console.log(await promptGpt(`${args.join(' ')}\n${stdin}`));
|
||||
}
|
||||
|
||||
async function main() {
|
||||
let args = process.argv.slice(2);
|
||||
if (args.length === 0) {
|
||||
console.log("No arguments provided. Exiting.");
|
||||
return;
|
||||
}
|
||||
trick17(args);
|
||||
}
|
||||
|
||||
await main();
|
||||
@@ -18,4 +18,5 @@
|
||||
hollow-grub = pkgs.callPackage ./hollow-grub/default.nix { };
|
||||
peframe = pkgs.callPackage ./peframe/default.nix { python3Packages = pkgs.python3Packages; inherit virustotal-api; };
|
||||
virustotal-api = pkgs.callPackage ./virustotal-api/default.nix { python3Packages = pkgs.python3Packages; };
|
||||
answer = pkgs.callPackage ./answer/default.nix { };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user