diff --git a/home/common/optional/desktop/dwm/scripts/git-commit-ai.nix b/home/common/optional/desktop/dwm/scripts/git-commit-ai.nix index 9040b17..c837898 100644 --- a/home/common/optional/desktop/dwm/scripts/git-commit-ai.nix +++ b/home/common/optional/desktop/dwm/scripts/git-commit-ai.nix @@ -31,48 +31,24 @@ # Usage: ./git-commit-ai --git-diff-commands --model # # - endpoint="10.0.10.100:11434" - diff=$(git diff "$@" ) [ -z "$diff" ] && echo "No diff provided. Did you stage the changes?" && exit 1 tokens=$(echo "$diff" | tiktoken-cli) echo -e "\n\nEstimated tokens: $tokens\n\n" + choose_model() { - models_response=$(curl http://$endpoint/api/tags) - model=$(echo "$models_response" | jq -r '..|.model? // empty' | fzf | sed 's/:latest$//') + models=$(${pkgs.aichat}/bin/aichat --list-models) + model=$(echo "$models" | fzf) } choose_model - system_message=""" - You are a git commit generator. You will be provided with a git diff file. - Your role is to create a concise commit message that outlines all of the - most relevant and impactful changes in the diff. You only output a commit - message, do not write anything else not related to the commit. Use - imperative mood for you writing style. - - Your message should include a short summary in the first line followed by - more detailed descriptions of the changes on subsequent lines. - - The first line summary should be no more than 70 characters, not end with a - period, and a blank line should separate the summary from the body of the - message. - - There should only be 1 summary line, and 1 body with the description. - The body should include no more than 3 bullet points with more detailed - descriptions of the files and functions that have been modified. - - Do not output any code. - """ - - query=$(jq -n --arg model "$model" --arg system_message "$system_message" --arg prompt "$diff" '{model: $model, system: $system_message, prompt: $prompt, stream: false}') - git config commit.template ".git/gitmessage" redo="" while true do - [ -z "$redo" ] && echo "Using model: $model" && commit_message=$(curl -s http://$endpoint/api/generate -H "Content-Type: application/json" -d "$query" | jq -r '.response') + [ -z "$redo" ] && echo "Using model: $model" && commit_message=$(${pkgs.aichat}/bin/aichat --model "$model" --role "git_commit" "$diff") echo "" echo "Message:"