Record token usage per turn and show daily, weekly and all-time totals by host

This commit is contained in:
Gmer4Lfe
2026-08-04 18:04:46 -04:00
parent 961c57c6f0
commit 969a85f303
8 changed files with 340 additions and 3 deletions
+5 -1
View File
@@ -198,8 +198,12 @@ if [[ "$SEARCH_ONLY" == true ]]; then
"--k=${AI_SEARCH_K:-8}" "--per-file=${AI_SEARCH_PER_FILE:-3}"
else
[[ -z "$GEN_MODEL" ]] && { error "${MY_ID}_OLLAMA_MODEL is empty — needed for generation"; exit 1; }
# Token accounting. Passed in rather than re-read in node, so the conf stays the shell's job
# and cli.js keeps taking everything it needs as arguments. Omitting either flag simply
# skips the row — the CLI must still work when called by hand outside this wrapper.
node --no-warnings "$CLI" ask "${_args[@]}" \
"--model=${GEN_MODEL}" "--embed-model=${EMBED_MODEL}" \
"--k=${AI_SEARCH_K:-8}" "--per-file=${AI_SEARCH_PER_FILE:-3}" \
"--timeout=$(( ${AI_REQUEST_TIMEOUT:-240} * 1000 ))"
"--timeout=$(( ${AI_REQUEST_TIMEOUT:-240} * 1000 ))" \
"--token-db=${AI_TOKEN_DB:-}" "--token-host=$(echo "$MY_ID" | tr '[:upper:]' '[:lower:]')"
fi