From e59772adb916c225bd78dca65924e52a3273819f Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Fri, 22 Mar 2024 20:11:15 +0300 Subject: [PATCH] Ask : Add ask_model. --- module/common/bash/module/Ask.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/module/common/bash/module/Ask.sh b/module/common/bash/module/Ask.sh index 0d69473b..90d475c4 100644 --- a/module/common/bash/module/Ask.sh +++ b/module/common/bash/module/Ask.sh @@ -1,9 +1,24 @@ +export _ask_model="mistral" + # Ask general AI. # Usage: ask function ask() { curl http://localhost:11434/api/generate -d "{ - \"model\": \"mistral\", + \"model\": \"${_ask_model}\", \"prompt\":\"${*}\" }" 2> /dev/null | parallel -j1 -- "echo {} | jq -r .response | tr -d '\n'" echo } + +# Specify ask model. +function ask_model() { + export _ask_model="${1}" +} + +function _complete_ask_model() { + local IFS=$'\n' + local models=($(ollama list | sed -e "1d" | cut -f1)) + _autocomplete_first ${models[@]} +} + +complete -F _complete_ask_model ask_model