Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sammcj committed Sep 17, 2024
1 parent 62706ff commit 82f7018
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 71 deletions.
6 changes: 6 additions & 0 deletions .gitignoreglobal
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ Session.vim

# Trunk linter for vscode (can be included per repo)
.trunk

#AI
.aider*

#vscode
**/.vscode
8 changes: 7 additions & 1 deletion 4-aliases.rc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ alias icloud_drive="cd ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/"
# IDE Projects
#shellcheck disable=SC2139
alias zshconfig="code '${THIS_DIRECTORY}'"
# shellcheck disable=SC2139
alias wezedit="code '${HOME}'/.config/wezterm/wezterm.lua"
#shellcheck disable=SC2139
alias zshconfigd="cd '${THIS_DIRECTORY}'"

Expand Down Expand Up @@ -198,12 +200,16 @@ alias copilot="gh copilot suggest -t shell"
alias copilot-explain="gh copilot explain"
alias '??'='copilot'
alias wtf='copilot'
alias l="gollama -l"
alias l="OLLAMA_HOST=http://localhost:11434 gollama -l"
alias i="ingest"
alias code2prompt="ingest"
alias ln="gollama -l"
alias gl="gollama"
alias ol="mods"
alias idf='. $HOME/git/esp-idf/export.sh'
alias o='tlm explain'
alias hf="hfdownloader -c 10 -t \$HUGGINGFACE_TOKEN -j"
alias imagesearch="sisi search"

# uv
alias venv='uv venv ; source .venv/bin/activate'
Expand Down
8 changes: 4 additions & 4 deletions 5-exports.rc
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ export _FMT_END="\e[0m" # end of line stop formatting
# export COMMANDLINE_ARGS="${COMMANDLINE_ARGS:-$COMMANDLINE_ARGS --skip-torch-cuda-test --upcast-sampling --opt-sub-quad-attention}" # --use-cpu interrogate
export HF_HUB_ENABLE_HF_TRANSFER=1
export CONDA_SUBDIR=osx-arm64
export OLLAMA_NUM_PARALLEL=3
export OLLAMA_MAX_LOADED_MODELS=3
export OLLAMA_KEEP_ALIVE=6h
export OLLAMA_FLASH_ATTENTION=1

# SEE ALSO private exports for Ollama things

# if running on macos
# if [[ "$OSTYPE" == "darwin"* ]]; then
# BLAS_INCLUDE_DIRS=/opt/homebrew/Cellar/clblast/1.6.2/
# export CMAKE_ARGS="${CMAKE_ARGS} -DLLAMA_CUDA=off -DLLAMA_METAL=on -DLLAMA_CLBLAST=1"
# fi

export ENABLE_ANALYTICS=0
90 changes: 25 additions & 65 deletions 9-functions.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1556,72 +1556,32 @@ function pip() {
fi
}

function code2prompt() {
# wrap the code2prompt command in a function that sets a number of default excludes
# https://github.com/mufeedvh/code2prompt/
local arguments excludeFiles excludeFolders templatesFolder excludeExtensions
templatesFolder="${HOME}/git/code2prompt/templates"
excludeFiles=".editorconfig,.eslintignore,.eslintrc,tsconfig.json,.gitignore,.npmrc,LICENSE,LICENSE.md,esbuild.config.mjs,manifest.json,package-lock.json,\
version-bump.mjs,versions.json,yarn.lock,CONTRIBUTING,CONTRIBUTING.md,CHANGELOG,CHANGELOG.md,SECURITY,SECURITY.md,TODO.md,.nvmrc,.env,.env.production,.prettierrc,\
CODEOWNERS,commitlint.config.js,renovate.json,pre-commit-config.yaml,.vimrc,poetry.lock,changelog.md,contributing.md,.pretterignore,.prettierrc.json,\
.prettierrc.yml,.prettierrc.js,.eslintrc.js,.eslintrc.json,.eslintrc.yml,.eslintrc.yaml,.stylelintrc.js,.stylelintrc.json,.stylelintrc.yml,.stylelintrc.yaml\
.prettierignore,.stylelintrc,README.md,readme.md,go.sum,.pyc,.DS_Store,.gitattributes,.gitmodules,.gitpod.yml,.github,.gitlab-ci.yml,.gitignore,.git"
excludeFolders="screenshots,dist,node_modules,.git,.github,.vscode,build,coverage,.venv,venv,pyenv,tmp,out,temp,conda,mamba\
src/complete/completers/ai21,src/complete/completers/chatgpt,src/complete/completers/gooseai"
excludeExtensions="png,jpg,jpeg,gif,svg,mp4,webm,avi,mp3,wav,flac,zip,tar,gz,bz2,7z,iso,bin,exe,app,dmg,deb,rpm,apk,fig,xd,blend,fbx,obj,tmp,swp,pem,crt,key,cert,pub\
lock,DS_Store,sqlite,log,sqlite3,dll,woff,woff2,ttf,eot,otf,ico,icns,csv,doc,docx,ppt,pptx,xls,xlsx,pdf,cmd,bat,dat,baseline,ps1,bin,exe,app,tmp,diff,bmp,ico,diff,heic,hiec"

echo "---"
echo "Available templates:"
ls -1 "$templatesFolder"
echo "---"

echo "Excluding files: $excludeFiles"
echo "Excluding folders: $excludeFolders"
echo "Run with -nn to disable the default excludes"

# array of build arguments
arguments=("--tokens")

# if -t and a template name is provided, append the template flag with the full path to the template to the arguments array
if [[ $1 == "-t" ]]; then
arguments+=("--template" "$templatesFolder/$2")
shift 2
fi

if [[ $1 == "-n" ]]; then
command code2prompt "${arguments[@]}" "${@:2}" # remove the -nn flag
else
command code2prompt "${arguments[@]}" --exclude-files "$excludeFiles" --exclude-folders "$excludeFolders" --exclude "$excludeExtensions" "${*}"
fi
}

# A function that does an ollama cp of any models that start with sammcj to instead start with registry.domain/ollama/<rest of the tag without sammcj>
function ollama-cp() {
local models
local registry
registry=$(echo "$OLLAMA_REGISTRY" | sed 's/\//\\\//g')
# shellcheck disable=SC2207 # array assignment is intentional
models=($(ollama list | grep sammcj | grep -v grep | awk '{print $1}'))
# sort by smallest to largest (human readable MB/GB)
# calulate the total size of the models
total_size=$(ollama list | grep sammcj | grep -v grep | awk '{print $3}' | paste -sd+ - | bc)
echo "Total size of models to be considered: ${total_size}GB"
# shellcheck disable=SC2207
models=($(echo "${models[@]}" | tr ' ' '\n' | sort -h))
for model in "${models[@]}"; do
echo "Model: $model"
new_model=$(echo "$model" | gsed -e s/sammcj/"$registry"/ | tr '[:upper:]' '[:lower:]')
# if ollama list | grep -q "$new_model"; then
# echo "Model $new_model already exists, skipping"
# continue
# fi
echo "Copying $model to $new_model"
ollama cp "$model" "$new_model" && ollama rm "$model"
echo "Pushing $new_model"
ollama push "$new_model"
done
}
# function ollama-cp() {
# local models
# local registry
# registry=$(echo "$OLLAMA_REGISTRY" | sed 's/\//\\\//g')
# # shellcheck disable=SC2207 # array assignment is intentional
# models=($(ollama list | grep sammcj | grep -v grep | awk '{print $1}'))
# # sort by smallest to largest (human readable MB/GB)
# # calulate the total size of the models
# total_size=$(ollama list | grep sammcj | grep -v grep | awk '{print $3}' | paste -sd+ - | bc)
# echo "Total size of models to be considered: ${total_size}GB"
# # shellcheck disable=SC2207
# models=($(echo "${models[@]}" | tr ' ' '\n' | sort -h))
# for model in "${models[@]}"; do
# echo "Model: $model"
# new_model=$(echo "$model" | gsed -e s/sammcj/"$registry"/ | tr '[:upper:]' '[:lower:]')
# # if ollama list | grep -q "$new_model"; then
# # echo "Model $new_model already exists, skipping"
# # continue
# # fi
# echo "Copying $model to $new_model"
# ollama cp "$model" "$new_model" && ollama rm "$model"
# echo "Pushing $new_model"
# ollama push "$new_model"
# done
# }

function ollama-pull-all() {
local BATCH_SIZE
Expand Down
4 changes: 4 additions & 0 deletions bootstrap_shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ function configureDotfiles() {

link_dotfile "bat-config" "/Users/samm/.config/bat/config"
link_dotfile "rsyncd.conf" "/Users/samm/.rsyncd.conf"

# TODO: clean this up
ln -s /Users/samm/Library/Mobile\ Documents/com~apple~CloudDocs/Dropbox\ Import/dotfiles/aider/.aider.conf.yml $HOME/.aider.conf.yml
ln -s /Users/samm/Library/Mobile\ Documents/com~apple~CloudDocs/Dropbox\ Import/dotfiles/aider/.aider.models.json $HOME/.aider.models.json
}

function main() {
Expand Down
2 changes: 1 addition & 1 deletion zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ export PATH="$PATH:/Users/samm/.cache/lm-studio/bin"
# Uncomment below to enable debug timing
# zprof
#### END PROFILING ######
if [ -f "/Users/samm/.config/fabric/fabric-bootstrap.inc" ]; then . "/Users/samm/.config/fabric/fabric-bootstrap.inc"; fi
if [ -f "/Users/samm/.config/fabric/fabric-bootstrap.inc" ]; then . "/Users/samm/.config/fabric/fabric-bootstrap.inc"; fi

0 comments on commit 82f7018

Please sign in to comment.