nix/home/program/bash/module/Ask.nix

28 lines
630 B
Nix
Raw Normal View History

{ ... }:
{
text = ''
# Ask general AI.
# Usage: ask <QUERY>
function ask() {
curl http://localhost:11434/api/generate -d "{
\"model\": \"''${OLLAMA_MODEL}\",
\"prompt\":\"''${*}\"
}" 2> /dev/null | parallel -j1 -- "echo {} | jq -r .response | tr -d '\n'"
echo
}
2024-04-06 03:03:58 +03:00
# Specify ask model.
function ask_model() {
export OLLAMA_MODEL="''${1}"
}
2024-04-06 03:03:58 +03:00
function _complete_ask_model() {
local IFS=$'\n'
local models=($(ollama list | sed -e "1d" | cut -f1))
_autocomplete_first ''${models[@]}
}
2024-04-06 03:03:58 +03:00
complete -F _complete_ask_model ask_model
'';
2024-04-06 03:03:58 +03:00
}