From 2a74d2e2733f94e3c7692c64c05cdf61c69e8fd7 Mon Sep 17 00:00:00 2001 From: Ayo Date: Sat, 30 Aug 2025 13:21:23 +0200 Subject: [PATCH] feat(ai): add brainstorm model --- ai-brainstorm.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ ayo.sh | 3 +++ example.conf | 8 +++++-- 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100755 ai-brainstorm.sh diff --git a/ai-brainstorm.sh b/ai-brainstorm.sh new file mode 100755 index 0000000..54dee80 --- /dev/null +++ b/ai-brainstorm.sh @@ -0,0 +1,60 @@ +# Load config +. ${HOME}/ayo.conf + +model=$brainstorm +modelfile=$brainstorm_modelfile + +host=$ollama_remote_host + +# Initialize variables +typora_flag=false +other_args="" + +# Process arguments to handle -t flag and collect other args +while [[ $# -gt 0 ]]; do + case $1 in + -t) + typora_flag=true + shift + ;; + *) + other_args="$other_args $1" + shift + ;; + esac +done + +# Set other_args to the first argument if it exists, otherwise empty string +if [[ -n "$other_args" ]]; then + # Remove leading space + other_args="${other_args# }" + + IFS=' ' read -ra args_array <<< "$other_args" + if [[ ${#args_array[@]} -gt 1 ]]; then + # Remove first element and rejoin remaining elements + other_args="${args_array[*]:1}" + else + # If there's only one argument, set other_args to empty string + other_args="" + fi +fi + +if ! [ "$other_args" = "" ]; then + if [ "$other_args" = "sleep" ]; then + OLLAMA_HOST=$host ollama stop $model + elif [ "$other_args" = "init" ]; then + OLLAMA_HOST=$host ollama create "$model" -f "$modelfile" + else + # If -t flag is set, use typora to display output + if [ "$typora_flag" = true ]; then + tempfile="$(mktemp)" + OLLAMA_HOST=$host ollama run $model "$other_args" --hidethinking > $tempfile + typora $tempfile + else + # If no -t flag, just run the command normally + OLLAMA_HOST=$host ollama run $model "$other_args" --hidethinking + fi + fi +else + OLLAMA_HOST=$host ollama run $model --hidethinking +fi diff --git a/ayo.sh b/ayo.sh index 9af82ad..9b5153e 100755 --- a/ayo.sh +++ b/ayo.sh @@ -75,6 +75,9 @@ case $1 in ai-coder) . ${scripts_dir}/ai-coder.sh "$@" ;; + ai-brainstorm) + . ${scripts_dir}/ai-brainstorm.sh "$@" + ;; ai-helper) . ${scripts_dir}/ai.sh "$@" ;; diff --git a/example.conf b/example.conf index 7ea0af3..c14db97 100644 --- a/example.conf +++ b/example.conf @@ -4,11 +4,15 @@ archive_dir="${HOME}/Notes/Archive" scripts_dir="${HOME}/Projects/scripts" editor="vim" +# TODO: Add a flag for force using local? # Ollama host URL or IP; for fully local, leave empty or comment out -ollama_remote_host="http://remote-ollama-server" +ollama_remote_host="192.168.0.123" coder="coder:latest" -coder_modelfile="${HOME}/Projects/llm-prompts/Modelfile-coder-lite" +coder_modelfile="${HOME}/Projects/llm-prompts/Modelfile-coder" helper="helper:latest" helper_modelfile="${HOME}/Projects/llm-prompts/Modelfile-helper" + +brainstorm="brainstorm:latest" +brainstorm_modelfile="${HOME}/Projects/llm-prompts/Modelfile-brainstorm"