Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Makefile #209

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

add Makefile #209

wants to merge 1 commit into from

Conversation

bionicles
Copy link

@bionicles bionicles commented Aug 9, 2024

this Makefile enables developers to download and extract three Mistral open source models with a single word: make

Models included:

  • codestral-mamba-7b-v0-1
  • mistral-7b-v0-3
  • mathstral-7b-v0-1

Note: there would still be some additional setup needed, specifically to tell the mistral-chat CLI where to find the models

If it's helpful, I can help update the README to show how to use the makefile
We can also have the makefile install and run the cli
We can even make it idempotently add mistral-models to the $PATH by adding code to their profile (example: https://github.com/bionicles/tree_plus/blob/main/tree_plus_src/scripts/alias_tree_plus.sh)

inlined here and lightly modified to save you a click

#!/bin/bash

# set your RC_FILE to .bashrc if you use bash 
# or set it to .zshrc if you use zsh
RC_FILE=~/.bash_profile # where the aliases will be added

# Function to idempotently add an alias if it doesn't exist in RC_FILE
add_alias() {
    grep -qF "alias $1=\"$2\"" $RC_FILE || echo "alias $1=\"$2\"" >> $RC_FILE
}

# Add alias
add_alias mc mistral-chat 

ah here's another nice script chunk that would enable the one above to automatically add a line to the user's profile which would indicate the path to find the mistral_models

export DEBUG=true

# ensure lines are added to a file only once
function idempotent_add_line_to_file() {
  local line="$1"
  local file="$2"
  # Check if the line already exists in the file
  if grep -Fxq "$line" "$file"; then
    ${DEBUG:=false} && echo "DEBUG(idempotent_add_line_to_file) line '$line' already in '$file'"
  else
    echo "$line" >> "$file"
    echo "DEBUG(idempotent_add_line_to_file) SCRIPT_DIR: $SCRIPT_DIR"
    echo "The line '$line' was added to '$file'"
  fi
}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "DEBUG(idempotent_add_line_to_file) SCRIPT_DIR: $SCRIPT_DIR"
idempotent_add_line_to_file "export MISTRAL_MODELS_PATH=$SCRIPT_DIR/mistral_models" "$HOME/$RC_FILE"
export -f idempotent_add_line_to_file

key idea: it only adds the line once, so it won't keep re-adding it

could enable mistral to install local terminal utilities more easily without needing to tell people to tinker with their path too much

Anyway: TLDR - make it easier to download the models, and this description contains a couple of bash fragments to make it even easier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant