From 1dbe809b9e225ee5974e75793dc0a0712883c289 Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Thu, 4 Jul 2024 16:58:54 +0800 Subject: [PATCH 01/36] feat: add `--upgrade` option in installer Signed-off-by: Xin Liu --- install.sh | 158 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 126 insertions(+), 32 deletions(-) diff --git a/install.sh b/install.sh index 4cfced5..8893f83 100644 --- a/install.sh +++ b/install.sh @@ -18,6 +18,8 @@ dashboard_version="v3.1" # 0: do not reinstall, 1: reinstall reinstall=0 +# 0: do not upgrade, 1: upgrade +upgrade=0 # 0: must be root or sudo, 1: regular unprivileged user unprivileged=0 # url to the config file @@ -49,6 +51,7 @@ function print_usage { printf " --config Specify a url to the config file\n" printf " --base Specify a path to the gaianet base directory\n" printf " --reinstall Install and download all required deps\n" + printf " --upgrade Upgrade the gaianet node\n" printf " --tmpdir Specify a path to the temporary directory [default: /tmp]\n" printf " --ggmlcuda [11/12] Install a specific CUDA enabled GGML plugin version [Possible values: 11, 12].\n" # printf " --unprivileged: install the gaianet CLI tool into base directory instead of system directory\n" @@ -74,6 +77,10 @@ while [[ $# -gt 0 ]]; do reinstall=1 shift ;; + --upgrade) + upgrade=1 + shift + ;; --tmpdir) tmp_dir="$2" shift @@ -151,10 +158,32 @@ EOF printf "\n\n" -# if need to reinstall, remove the $gaianet_base_dir directory -if [ "$reinstall" -eq 1 ] && [ -d "$gaianet_base_dir" ]; then - printf "[+] Removing the existing $gaianet_base_dir directory ...\n\n" - rm -rf $gaianet_base_dir +# If need to upgrade, remove the all existing files and subdirectories in the base directory, except for the backup subdirectory and its contents +# If need to reinstall, remove the $gaianet_base_dir directory +if [ -d "$gaianet_base_dir" ]; then + if [ "$upgrade" -eq 1 ]; then + printf "[+] Upgrading the existing $gaianet_base_dir directory ...\n\n" + + if [ ! -d "$gaianet_base_dir/backup" ]; then + mkdir -p "$gaianet_base_dir/backup" + fi + + # backup keystore file + keystore_filename=$(grep '"keystore":' $gaianet_base_dir/nodeid.json | awk -F'"' '{print $4}') + mv $gaianet_base_dir/$keystore_filename $gaianet_base_dir/backup/ + + # backup the existing config.json, nodeid.json and frpc.toml + mv $gaianet_base_dir/config.json $gaianet_base_dir/backup/ + mv $gaianet_base_dir/nodeid.json $gaianet_base_dir/backup/ + mv $gaianet_base_dir/gaianet-domain/frpc.toml $gaianet_base_dir/backup/ + + # remove the all existing files and subdirectories in the base directory, except for the backup subdirectory and its contents + find "$gaianet_base_dir" -mindepth 1 -not -name 'backup' -not -path '*/backup/*' -exec rm -rf {} + + + elif [ "$reinstall" -eq 1 ]; then + printf "[+] Removing the existing $gaianet_base_dir directory ...\n\n" + rm -rf $gaianet_base_dir + fi fi # Check if $gaianet_base_dir directory exists @@ -184,21 +213,50 @@ chmod u+x $bin_dir/gaianet info " * gaianet CLI tool is installed in $bin_dir" # 2. Download default `config.json` -printf "[+] Downloading default config file ...\n" -if [ ! -f "$gaianet_base_dir/config.json" ]; then - check_curl https://github.com/GaiaNet-AI/gaianet-node/releases/download/$version/config.json $gaianet_base_dir/config.json +if [ "$upgrade" -eq 1 ]; then + printf "[+] Recovering config.json ...\n" + + if [ -f "$gaianet_base_dir/backup/config.json" ]; then + cp $gaianet_base_dir/backup/config.json $gaianet_base_dir/config.json + + if ! grep -q '"chat_batch_size":' $gaianet_base_dir/config.json; then + # Prepend the field to the beginning of the JSON object + sed -i '' '2i\ + "chat_batch_size": "512", + ' $gaianet_base_dir/config.json + fi + + if ! grep -q '"embedding_batch_size":' $gaianet_base_dir/config.json; then + # Prepend the field to the beginning of the JSON object + sed -i '' '2i\ + "embedding_batch_size": "512", + ' $gaianet_base_dir/config.json + fi + + info " * The config.json is recovered in $gaianet_base_dir" + else + error " * Failed to recover the config.json. Reason: the config.json does not exist in $gaianet_base_dir/backup/." + exit 1 + fi - info " * The default config file is downloaded in $gaianet_base_dir" else - warning " * Use the cached config file in $gaianet_base_dir" -fi + printf "[+] Downloading default config.json ...\n" + + if [ ! -f "$gaianet_base_dir/config.json" ]; then + check_curl https://github.com/GaiaNet-AI/gaianet-node/releases/download/$version/config.json $gaianet_base_dir/config.json + + info " * The default config file is downloaded in $gaianet_base_dir" + else + warning " * Use the cached config file in $gaianet_base_dir" + fi -# 3. download nodeid.json -if [ ! -f "$gaianet_base_dir/nodeid.json" ]; then - printf "[+] Downloading nodeid.json ...\n" - check_curl https://github.com/GaiaNet-AI/gaianet-node/releases/download/$version/nodeid.json $gaianet_base_dir/nodeid.json + # 3. download nodeid.json + if [ ! -f "$gaianet_base_dir/nodeid.json" ]; then + printf "[+] Downloading nodeid.json ...\n" + check_curl https://github.com/GaiaNet-AI/gaianet-node/releases/download/$version/nodeid.json $gaianet_base_dir/nodeid.json - info " * The nodeid.json is downloaded in $gaianet_base_dir" + info " * The nodeid.json is downloaded in $gaianet_base_dir" + fi fi # 4. Install vector and download vector config file @@ -380,21 +438,47 @@ else warning " * Use the cached dashboard in $gaianet_base_dir" fi -# 9. Generate node ID and copy config to dashboard -printf "[+] Generating node ID ...\n" +# 9. Download registry.wasm if [ ! -f "$gaianet_base_dir/registry.wasm" ] || [ "$reinstall" -eq 1 ]; then - printf " * Download registry.wasm\n" + printf "[+] Downloading registry.wasm ...\n" check_curl https://github.com/GaiaNet-AI/gaianet-node/raw/main/utils/registry/registry.wasm $gaianet_base_dir/registry.wasm - info " The registry.wasm is downloaded in $gaianet_base_dir" + info " * The registry.wasm is downloaded in $gaianet_base_dir" else warning " * Use the cached registry.wasm in $gaianet_base_dir" fi -printf " * Generate node ID\n" -cd $gaianet_base_dir -wasmedge --dir .:. registry.wasm -printf "\n" -# 10. Install gaianet-domain +# 10. Generate node ID +if [ "$upgrade" -eq 1 ]; then + printf "[+] Recovering node ID ...\n" + + # recover the keystore file + if [ -f "$gaianet_base_dir/backup/$keystore_filename" ]; then + cp $gaianet_base_dir/backup/$keystore_filename $gaianet_base_dir/ + info " * The keystore file is recovered in $gaianet_base_dir" + else + error "Failed to recover the keystore file. Reason: the keystore file does not exist in $gaianet_base_dir/backup/." + exit 1 + fi + + # recover the nodeid.json + if [ -f "$gaianet_base_dir/backup/nodeid.json" ]; then + cp $gaianet_base_dir/backup/nodeid.json $gaianet_base_dir/nodeid.json + info " * The node ID is recovered in $gaianet_base_dir" + else + error "Failed to recover the node ID. Reason: the nodeid.json does not exist in $gaianet_base_dir/backup/." + exit 1 + fi + +else + printf "[+] Generating node ID ...\n" + cd $gaianet_base_dir + wasmedge --dir .:. registry.wasm + printf "\n" +fi + +# * todo: recover the nodeid.json and config.json + +# 11. Install gaianet-domain printf "[+] Installing gaianet-domain...\n" # Check if the directory exists, if not, create it if [ ! -d "$gaianet_base_dir/gaianet-domain" ]; then @@ -452,17 +536,27 @@ else exit 1 fi -# Copy frpc from $gaianet_base_dir/gaianet-domain to $gaianet_base_dir/bin +# Copy frpc binary from $gaianet_base_dir/gaianet-domain to $gaianet_base_dir/bin printf " * Install frpc binary\n" -cp $gaianet_base_dir/gaianet-domain/frpc $gaianet_base_dir/bin/ +mv $gaianet_base_dir/gaianet-domain/frpc $gaianet_base_dir/bin/ info " frpc binary is installed in $gaianet_base_dir/bin" -# 11. Download frpc.toml, generate a subdomain and print it -printf " * Download frpc.toml\n" - -check_curl_silent https://github.com/GaiaNet-AI/gaianet-node/releases/download/$version/frpc.toml $gaianet_base_dir/gaianet-domain/frpc.toml - -info " frpc.toml is downloaded in $gaianet_base_dir/gaianet-domain" +# 12. Download frpc.toml, generate a subdomain and print it +if [ "$upgrade" -eq 1 ]; then + # recover the frpc.toml + if [ -f "$gaianet_base_dir/backup/frpc.toml" ]; then + printf " * Recover frpc.toml\n" + cp $gaianet_base_dir/backup/frpc.toml $gaianet_base_dir/gaianet-domain/frpc.toml + info " frpc.toml is recovered in $gaianet_base_dir/gaianet-domain" + else + error "Failed to recover the frpc.toml. Reason: the frpc.toml does not exist in $gaianet_base_dir/backup/." + exit 1 + fi +else + printf " * Download frpc.toml\n" + check_curl_silent https://github.com/GaiaNet-AI/gaianet-node/releases/download/$version/frpc.toml $gaianet_base_dir/gaianet-domain/frpc.toml + info " frpc.toml is downloaded in $gaianet_base_dir/gaianet-domain" +fi # Read address from config.json as node subdomain subdomain=$(awk -F'"' '/"address":/ {print $4}' $gaianet_base_dir/config.json) From 1ed73557d5caf85ebcdef0b7dae9f5f91129e29b Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Thu, 4 Jul 2024 17:02:01 +0800 Subject: [PATCH 02/36] version: bump to `0.2.0` Signed-off-by: Xin Liu --- gaianet | 5 +++-- install.sh | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gaianet b/gaianet index df5b143..a860e27 100755 --- a/gaianet +++ b/gaianet @@ -3,11 +3,12 @@ set -e # version of CLI tool -version="0.1.3" +# Note that the version should kept same as the version of installer +version="0.2.0" # version of the GaiaNet node # Note that the version should kept same as the version of installer -installer_version="0.1.3" +installer_version="0.2.0" # path to the default gaianet base directory. It could be changed by the --base option gaianet_base_dir="$HOME/gaianet" diff --git a/install.sh b/install.sh index 8893f83..6a2e3a4 100644 --- a/install.sh +++ b/install.sh @@ -9,9 +9,9 @@ target=$(uname -m) cwd=$(pwd) repo_branch="main" -version="0.1.3" -rag_api_server_version="0.7.1" -llama_api_server_version="0.12.1" +version="0.2.0" +rag_api_server_version="0.7.2" +llama_api_server_version="0.12.2" ggml_bn="b3259" vector_version="0.38.0" dashboard_version="v3.1" From 7b2cf4cb34a665a8c00fcffc0f586ae5283f686f Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Thu, 4 Jul 2024 21:34:18 +0800 Subject: [PATCH 03/36] chore: improve installer upgrade Signed-off-by: Xin Liu --- install.sh | 139 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 97 insertions(+), 42 deletions(-) diff --git a/install.sh b/install.sh index 6a2e3a4..4791594 100644 --- a/install.sh +++ b/install.sh @@ -162,23 +162,72 @@ printf "\n\n" # If need to reinstall, remove the $gaianet_base_dir directory if [ -d "$gaianet_base_dir" ]; then if [ "$upgrade" -eq 1 ]; then - printf "[+] Upgrading the existing $gaianet_base_dir directory ...\n\n" + + # check version + current_version=$(gaianet --version) + if [ "GaiaNet CLI Tool v$version" = "$current_version" ]; then + info "The current version ($current_version) is the same as the target version (GaiaNet CLI Tool v$version). Skip the upgrade process." + exit 0 + + else + read -p "The gaianet node will be upgraded to v$version. It is stongly recommended to (1) STOP the running node and (2) backup $gaianet_base_dir directory before continue the upgrade process. Continue? (y/n): " answer + case $answer in + [Yy]* ) printf "\n";; + [Nn]* ) printf "Exiting upgrade process.\n"; exit;; + * ) printf "Please answer y or n.\n"; exit;; + esac + fi + + printf "[+] Performing backup before upgrading to v$version ...\n\n" if [ ! -d "$gaianet_base_dir/backup" ]; then + printf " * Create $gaianet_base_dir/backup\n" mkdir -p "$gaianet_base_dir/backup" fi # backup keystore file keystore_filename=$(grep '"keystore":' $gaianet_base_dir/nodeid.json | awk -F'"' '{print $4}') - mv $gaianet_base_dir/$keystore_filename $gaianet_base_dir/backup/ - - # backup the existing config.json, nodeid.json and frpc.toml - mv $gaianet_base_dir/config.json $gaianet_base_dir/backup/ - mv $gaianet_base_dir/nodeid.json $gaianet_base_dir/backup/ - mv $gaianet_base_dir/gaianet-domain/frpc.toml $gaianet_base_dir/backup/ + if [ -z "$keystore_filename" ]; then + error "Failed to read the 'keystore' field from $gaianet_base_dir/nodeid.json." + exit 1 + else + if [ -f "$gaianet_base_dir/$keystore_filename" ]; then + printf " * Copy $keystore_filename to $gaianet_base_dir/backup/\n" + cp $gaianet_base_dir/$keystore_filename $gaianet_base_dir/backup/ + else + error "Failed to copy the keystore file. Reason: the keystore file does not exist in $gaianet_base_dir." + exit 1 + fi + fi + # backup config.json + if [ -f "$gaianet_base_dir/config.json" ]; then + printf " * Copy config.json to $gaianet_base_dir/backup/\n" + cp $gaianet_base_dir/config.json $gaianet_base_dir/backup/ + else + error "Failed to copy the config.json. Reason: the config.json does not exist in $gaianet_base_dir." + exit 1 + fi + # backup nodeid.json + if [ -f "$gaianet_base_dir/nodeid.json" ]; then + printf " * Copy nodeid.json to $gaianet_base_dir/backup/\n" + cp $gaianet_base_dir/nodeid.json $gaianet_base_dir/backup/ + else + error "Failed to copy the nodeid.json. Reason: the nodeid.json does not exist in $gaianet_base_dir." + exit 1 + fi + # backup frpc.toml + if [ -f "$gaianet_base_dir/gaianet-domain/frpc.toml" ]; then + printf " * Copy frpc.toml to $gaianet_base_dir/backup/\n" + cp $gaianet_base_dir/gaianet-domain/frpc.toml $gaianet_base_dir/backup/ + else + error "Failed to copy the frpc.toml. Reason: the frpc.toml does not exist in $gaianet_base_dir/gaianet-domain." + exit 1 + fi # remove the all existing files and subdirectories in the base directory, except for the backup subdirectory and its contents - find "$gaianet_base_dir" -mindepth 1 -not -name 'backup' -not -path '*/backup/*' -exec rm -rf {} + + find "$gaianet_base_dir" -mindepth 1 -not -name 'backup' -not -path '*/backup/*' -not -name '*.gguf' -exec rm -rf {} + + + printf "\n" elif [ "$reinstall" -eq 1 ]; then printf "[+] Removing the existing $gaianet_base_dir directory ...\n\n" @@ -476,8 +525,6 @@ else printf "\n" fi -# * todo: recover the nodeid.json and config.json - # 11. Install gaianet-domain printf "[+] Installing gaianet-domain...\n" # Check if the directory exists, if not, create it @@ -538,7 +585,7 @@ fi # Copy frpc binary from $gaianet_base_dir/gaianet-domain to $gaianet_base_dir/bin printf " * Install frpc binary\n" -mv $gaianet_base_dir/gaianet-domain/frpc $gaianet_base_dir/bin/ +cp $gaianet_base_dir/gaianet-domain/frpc $gaianet_base_dir/bin/ info " frpc binary is installed in $gaianet_base_dir/bin" # 12. Download frpc.toml, generate a subdomain and print it @@ -589,48 +636,56 @@ $sed_i_cmd "s/name = \".*\"/name = \"$subdomain.$gaianet_domain\"/g" $gaianet_ba $sed_i_cmd "s/metadatas.deviceId = \".*\"/metadatas.deviceId = \"$device_id\"/g" $gaianet_base_dir/gaianet-domain/frpc.toml # Remove all files in the directory except for frpc and frpc.toml -find $gaianet_base_dir/gaianet-domain -type f -not -name 'frpc' -not -name 'frpc.toml' -exec rm -f {} \; +find $gaianet_base_dir/gaianet-domain -type f -not -name 'frpc.toml' -exec rm -f {} \; -printf "[+] COMPLETED! The gaianet node has been installed successfully.\n\n" +if [ "$upgrade" -eq 1 ]; then -info "Your node ID is $subdomain. Please register it in your portal account to receive awards!" + printf "[+] COMPLETED! The gaianet node has been upgraded to v$version.\n\n" -# Command to append -cmd="export PATH=\"$bin_dir:\$PATH\"" + info ">>> Next, you should run the command 'gaianet init' to initialize the GaiaNet node." -shell="${SHELL#${SHELL%/*}/}" -shell_rc=".""$shell""rc" +else + printf "[+] COMPLETED! The gaianet node has been installed successfully.\n\n" -# Check if the shell is zsh or bash -if [[ $shell == *'zsh'* ]]; then - # If zsh, append to .zprofile - if ! grep -Fxq "$cmd" $HOME/.zprofile - then - echo "$cmd" >> $HOME/.zprofile - fi + info "Your node ID is $subdomain. Please register it in your portal account to receive awards!" - # If zsh, append to .zshrc - if ! grep -Fxq "$cmd" $HOME/.zshrc - then - echo "$cmd" >> $HOME/.zshrc - fi + # Command to append + cmd="export PATH=\"$bin_dir:\$PATH\"" -elif [[ $shell == *'bash'* ]]; then + shell="${SHELL#${SHELL%/*}/}" + shell_rc=".""$shell""rc" - # If bash, append to .bash_profile - if ! grep -Fxq "$cmd" $HOME/.bash_profile - then - echo "$cmd" >> $HOME/.bash_profile - fi + # Check if the shell is zsh or bash + if [[ $shell == *'zsh'* ]]; then + # If zsh, append to .zprofile + if ! grep -Fxq "$cmd" $HOME/.zprofile + then + echo "$cmd" >> $HOME/.zprofile + fi - # If bash, append to .bashrc - if ! grep -Fxq "$cmd" $HOME/.bashrc - then - echo "$cmd" >> $HOME/.bashrc + # If zsh, append to .zshrc + if ! grep -Fxq "$cmd" $HOME/.zshrc + then + echo "$cmd" >> $HOME/.zshrc + fi + + elif [[ $shell == *'bash'* ]]; then + + # If bash, append to .bash_profile + if ! grep -Fxq "$cmd" $HOME/.bash_profile + then + echo "$cmd" >> $HOME/.bash_profile + fi + + # If bash, append to .bashrc + if ! grep -Fxq "$cmd" $HOME/.bashrc + then + echo "$cmd" >> $HOME/.bashrc + fi fi -fi -info ">>> Next, you should initialize the GaiaNet node with the LLM and knowledge base. To initialize the GaiaNet node, you need to\n>>> * Run the command 'source $HOME/$shell_rc' to make the gaianet CLI tool available in the current shell;\n>>> * Run the command 'gaianet init' to initialize the GaiaNet node." + info ">>> Next, you should initialize the GaiaNet node with the LLM and knowledge base. To initialize the GaiaNet node, you need to\n>>> * Run the command 'source $HOME/$shell_rc' to make the gaianet CLI tool available in the current shell;\n>>> * Run the command 'gaianet init' to initialize the GaiaNet node." +fi exit 0 From d9a85622cbc0106dbafdb9cffc1d2067c78f4cca Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Thu, 4 Jul 2024 21:41:40 +0800 Subject: [PATCH 04/36] version: cancel the version bump for ci check Signed-off-by: Xin Liu --- gaianet | 4 ++-- install.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gaianet b/gaianet index a860e27..e73a60b 100755 --- a/gaianet +++ b/gaianet @@ -4,11 +4,11 @@ set -e # version of CLI tool # Note that the version should kept same as the version of installer -version="0.2.0" +version="0.1.3" # version of the GaiaNet node # Note that the version should kept same as the version of installer -installer_version="0.2.0" +installer_version="0.1.3" # path to the default gaianet base directory. It could be changed by the --base option gaianet_base_dir="$HOME/gaianet" diff --git a/install.sh b/install.sh index 4791594..4404f99 100644 --- a/install.sh +++ b/install.sh @@ -9,9 +9,9 @@ target=$(uname -m) cwd=$(pwd) repo_branch="main" -version="0.2.0" -rag_api_server_version="0.7.2" -llama_api_server_version="0.12.2" +version="0.1.3" +rag_api_server_version="0.7.1" +llama_api_server_version="0.12.1" ggml_bn="b3259" vector_version="0.38.0" dashboard_version="v3.1" From a35c6eb5ebdd3805f15664fe722512373527393f Mon Sep 17 00:00:00 2001 From: dragon Date: Fri, 5 Jul 2024 14:49:24 +0800 Subject: [PATCH 05/36] feat: Remove unnecessary files in gaianet-domain directory --- gaianet | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gaianet b/gaianet index df5b143..8082420 100755 --- a/gaianet +++ b/gaianet @@ -533,6 +533,10 @@ init() { $sed_i_cmd "s/name = \".*\"/name = \"$address.$domain\"/g" $gaianet_base_dir/gaianet-domain/frpc.toml $sed_i_cmd "s/localPort = \".*\"/localPort = \"$llamaedge_port\"/g" $gaianet_base_dir/gaianet-domain/frpc.toml $sed_i_cmd "s/serverAddr = \".*\"/serverAddr = \"$domain\"/g" $gaianet_base_dir/gaianet-domain/frpc.toml + + # Remove all files in the directory except for frpc and frpc.toml + find $gaianet_base_dir/gaianet-domain -type f -not -name 'frpc' -not -name 'frpc.toml' -exec rm -f {} \; + printf "\n" printf "[+] COMPLETED! GaiaNet node is initialized successfully.\n\n" From 669e38b08570832765b6d088a7be51c9723f46ff Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Fri, 5 Jul 2024 07:55:35 +0000 Subject: [PATCH 06/36] chore: improve installer upgrade Signed-off-by: Xin Liu --- install.sh | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index 4404f99..736558d 100644 --- a/install.sh +++ b/install.sh @@ -164,8 +164,13 @@ if [ -d "$gaianet_base_dir" ]; then if [ "$upgrade" -eq 1 ]; then # check version - current_version=$(gaianet --version) - if [ "GaiaNet CLI Tool v$version" = "$current_version" ]; then + if ! command -v gaianet &> /dev/null; then + current_version="" + else + current_version=$(gaianet --version) + fi + + if [ -n "$current_version" ] && [ "GaiaNet CLI Tool v$version" = "$current_version" ]; then info "The current version ($current_version) is the same as the target version (GaiaNet CLI Tool v$version). Skip the upgrade process." exit 0 @@ -270,16 +275,44 @@ if [ "$upgrade" -eq 1 ]; then if ! grep -q '"chat_batch_size":' $gaianet_base_dir/config.json; then # Prepend the field to the beginning of the JSON object - sed -i '' '2i\ - "chat_batch_size": "512", - ' $gaianet_base_dir/config.json + if [ "$(uname)" == "Darwin" ]; then + sed -i '' '2i\ + "chat_batch_size": "512", + ' "$gaianet_base_dir/config.json" + + elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + sed -i '2i\ + "chat_batch_size": "512", + ' "$gaianet_base_dir/config.json" + + elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then + error " * For Windows users, please run this script in WSL." + exit 1 + else + error " * Only support Linux, MacOS and Windows." + exit 1 + fi fi if ! grep -q '"embedding_batch_size":' $gaianet_base_dir/config.json; then # Prepend the field to the beginning of the JSON object - sed -i '' '2i\ - "embedding_batch_size": "512", - ' $gaianet_base_dir/config.json + if [ "$(uname)" == "Darwin" ]; then + sed -i '' '2i\ + "embedding_batch_size": "512", + ' "$gaianet_base_dir/config.json" + + elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + sed -i '2i\ + "embedding_batch_size": "512", + ' "$gaianet_base_dir/config.json" + + elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then + error " * For Windows users, please run this script in WSL." + exit 1 + else + error " * Only support Linux, MacOS and Windows." + exit 1 + fi fi info " * The config.json is recovered in $gaianet_base_dir" From 4fa42e2e94cdf06c9f27d6d9b8152280fa0445ba Mon Sep 17 00:00:00 2001 From: Michael Yuan Date: Sat, 6 Jul 2024 17:18:32 -0500 Subject: [PATCH 07/36] Update the default ctx and batch size for the chat model Signed-off-by: Michael Yuan The batch size could be much smaller to conserve memory use --- config.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.json b/config.json index 1606c01..4b93782 100644 --- a/config.json +++ b/config.json @@ -5,8 +5,8 @@ "chat_name": "Phi-3-mini-4k-instruct", "prompt_template": "phi-3-chat", "reverse_prompt": "", - "chat_ctx_size": "2048", - "chat_batch_size": "512", + "chat_ctx_size": "4096", + "chat_batch_size": "16", "embedding": "https://huggingface.co/gaianet/Nomic-embed-text-v1.5-Embedding-GGUF/resolve/main/nomic-embed-text-v1.5.f16.gguf", "embedding_name": "Nomic-embed-text-v1.5", "embedding_ctx_size": "512", @@ -20,4 +20,4 @@ "rag_policy": "system-message", "domain": "us.gaianet.network", "llamaedge_port": "8080" -} \ No newline at end of file +} From d909b9d617e1164605c4f74c7a9b1a71aa1c0631 Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Sun, 7 Jul 2024 14:23:42 +0800 Subject: [PATCH 08/36] version: bump to `0.2.0` Signed-off-by: Xin Liu --- gaianet | 4 ++-- install.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gaianet b/gaianet index e73a60b..a860e27 100755 --- a/gaianet +++ b/gaianet @@ -4,11 +4,11 @@ set -e # version of CLI tool # Note that the version should kept same as the version of installer -version="0.1.3" +version="0.2.0" # version of the GaiaNet node # Note that the version should kept same as the version of installer -installer_version="0.1.3" +installer_version="0.2.0" # path to the default gaianet base directory. It could be changed by the --base option gaianet_base_dir="$HOME/gaianet" diff --git a/install.sh b/install.sh index 736558d..e377f04 100644 --- a/install.sh +++ b/install.sh @@ -9,9 +9,9 @@ target=$(uname -m) cwd=$(pwd) repo_branch="main" -version="0.1.3" -rag_api_server_version="0.7.1" -llama_api_server_version="0.12.1" +version="0.2.0" +rag_api_server_version="0.7.2" +llama_api_server_version="0.12.2" ggml_bn="b3259" vector_version="0.38.0" dashboard_version="v3.1" From 7f73aa914e6bb1922e569d157d384b62b79a390a Mon Sep 17 00:00:00 2001 From: Ahmad-Mtr Date: Sun, 7 Jul 2024 11:44:01 +0300 Subject: [PATCH 09/36] add README-ar.md --- README-ar.md | 265 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 265 insertions(+) create mode 100644 README-ar.md diff --git a/README-ar.md b/README-ar.md new file mode 100644 index 0000000..b44feae --- /dev/null +++ b/README-ar.md @@ -0,0 +1,265 @@ +# قم بتشغيل عقدة Gaianet الخاصة بك + + +

+ + GaiaNet Discord + + + GaiaNet Twitter + + + Gaianet website + +

+ + + +[اليابانية(日本語)](README-ja.md) | [الصينية(中文)](README-cn.md) | [التركية (Türkçe)](README-tr.md) | [العربية (العَرَبية)](README-ar.md) | نحتاجُ الى مساعدتك في ترجمة هذا الملف الى لغتك الأم. + + +أعجَبَك عَمَلُنا؟ ⭐ قَيْمِنّا بنجمة! +--- + +## بداية سريعة + +قم بتثبيت حزمة برامج العقدة الافتراضية باستخدام أمر واحد على نظام التشغيل Mac أو Linux أو Windows WSL. + +```bash +curl -sSfL 'https://github.com/GaiaNet-AI/gaianet-node/releases/latest/download/install.sh' | bash +``` + +ثم اتبع التعليمات على شاشتك لإعداد مسار البيئة, سيبدأ سطر الأوامر بالأمر `source`. + +قم بتهيئة العقدة. ستقوم بتنزيل ملفات النماذج وقواعد بيانات المتجهات المحددة في ملف `$HOME/gaianet/config.json`، وقد يستغرق ذلك بضع دقائق نظرًا لحجم الملفات الكبير. + +```bash +gaianet init +``` + +ابدأ العقدة. + +```bash +gaianet start +``` +سيقوم النص بطباعة عنوان العقدة الرسمي على الكونسول كما يلي. +يمكنك فتح المتصفح على ذلك العنوان لرؤية معلومات العقدة ثم التحدث مع وكيل الذكاء الاصطناعي على العقدة. + +``` +... ... https://0xf63939431ee11267f4855a166e11cc44d24960c0.us.gaianet.network +``` + +لإيقاف العقدة, يمكنك تشغيل الأمر الآتي: + +```bash +gaianet stop +``` + +## دليل التثبيت + +```bash +curl -sSfL 'https://raw.githubusercontent.com/GaiaNet-AI/gaianet-node/main/install.sh' | bash +``` + +
يجب أن تبدو النتائج كما يلي: + +```console +[+] Downloading default config file ... + +[+] Downloading nodeid.json ... + +[+] Installing WasmEdge with wasi-nn_ggml plugin ... + +Info: Detected Linux-x86_64 + +Info: WasmEdge Installation at /home/azureuser/.wasmedge + +Info: Fetching WasmEdge-0.13.5 + +/tmp/wasmedge.2884467 ~/gaianet +######################################################################## 100.0% +~/gaianet +Info: Fetching WasmEdge-GGML-Plugin + +Info: Detected CUDA version: + +/tmp/wasmedge.2884467 ~/gaianet +######################################################################## 100.0% +~/gaianet +Installation of wasmedge-0.13.5 successful +WasmEdge binaries accessible + + The WasmEdge Runtime wasmedge version 0.13.5 is installed in /home/azureuser/.wasmedge/bin/wasmedge. + + +[+] Installing Qdrant binary... + * Download Qdrant binary +################################################################################################## 100.0% + + * Initialize Qdrant directory + +[+] Downloading the rag-api-server.wasm ... +################################################################################################## 100.0% + +[+] Downloading dashboard ... +################################################################################################## 100.0% +``` + +
+ +بشكل افتراضي, يتم التثبيت ب `$HOME/gaianet`, يمكنك أيضًا أن تختارَ عنوانًا بديلاً. + +```bash +curl -sSfL 'https://raw.githubusercontent.com/GaiaNet-AI/gaianet-node/main/install.sh' | bash -s -- --base $HOME/gaianet.alt +``` + +## تهيئة العقدة + +``` +gaianet init +``` + +
يجب أن تبدو النتيجة كما يلي: + +```bash +[+] Downloading Llama-2-7b-chat-hf-Q5_K_M.gguf ... +############################################################################################################################## 100.0%############################################################################################################################## 100.0% + +[+] Downloading all-MiniLM-L6-v2-ggml-model-f16.gguf ... + +############################################################################################################################## 100.0%############################################################################################################################## 100.0% + +[+] Creating 'default' collection in the Qdrant instance ... + + * Start a Qdrant instance ... + + * Remove the existed 'default' Qdrant collection ... + + * Download Qdrant collection snapshot ... +############################################################################################################################## 100.0%############################################################################################################################## 100.0% + + * Import the Qdrant collection snapshot ... + + * Recovery is done successfully +``` + +
+ +يعمل أمر `init` على تهيئة العقدة وفقًا لملف `$HOME/gaianet/config.json`. يمكنك استخدام بعض التكوينات المعدة مسبقًا. على سبيل المثال، الأمر أدناه يقوم بتهيئة عقدة باستخدام نموذج llama-3 8B مع دليل لندن كقاعدة معرفية. + +```bash +gaianet init --config https://raw.githubusercontent.com/GaiaNet-AI/node-configs/main/llama-3-8b-instruct_london/config.json +``` + +لرؤية قائمة تكوينات معدة مسبقًا, بإمكانك تشغيل `gaianet init --help`. +بالإضافة إلى التكوينات المعدة مسبقًا مثل `gaianet_docs`، يمكنك أيضًا تمرير عنوان URL إلى ملف `config.json` الخاص بك ليتم تهيئة العقدة بالحالة التي ترغب فيها. + + +إذا كنت بحاجة إلى تهيئة-`init`- عقدة مثبتة في دليل بديل، قم بذلك على النحو التالي. + +```bash +gaianet init --base $HOME/gaianet.alt +``` + +## إبدأ العقدة + +``` +gaianet start +``` + +
النتيجة يجب أن تكون كما يلي: + +```bash +[+] Starting Qdrant instance ... + + Qdrant instance started with pid: 39762 + +[+] Starting LlamaEdge API Server ... + + Run the following command to start the LlamaEdge API Server: + +wasmedge --dir .:./dashboard --nn-preload default:GGML:AUTO:Llama-2-7b-chat-hf-Q5_K_M.gguf --nn-preload embedding:GGML:AUTO:all-MiniLM-L6-v2-ggml-model-f16.gguf rag-api-server.wasm --model-name Llama-2-7b-chat-hf-Q5_K_M,all-MiniLM-L6-v2-ggml-model-f16 --ctx-size 4096,384 --prompt-template llama-2-chat --qdrant-collection-name default --web-ui ./ --socket-addr 0.0.0.0:8080 --log-prompts --log-stat --rag-prompt "Use the following pieces of context to answer the user's question.\nIf you don't know the answer, just say that you don't know, don't try to make up an answer.\n----------------\n" + + + LlamaEdge API Server started with pid: 39796 +``` + +
+ +يمكنك بدء العقدة للاستخدام المحلي. ستكون متاحة فقط عبر `localhost` ولن تكون متاحة على أي من عناوين URL العامة لنطاقات GaiaNet. + +```bash +gaianet start --local-only +``` + +يمكنك أيضًا بدء عقدة مثبتة في دليل أساسي بديل. + +```bash +gaianet start --base $HOME/gaianet.alt +``` + +### أوقف العقدة + +```bash +gaianet stop +``` + +
النتيجة يجب أن تبدو كما يلي: + +```bash +[+] Stopping WasmEdge, Qdrant and frpc ... +``` + +
+ +إيقاف عقدة مثبتة في دليل أساسي بديل. + +```bash +gaianet stop --base $HOME/gaianet.alt +``` + +### تحديث التكوين + +باستخدام الأمر الفرعي `gaianet config` يمكنك تحديث الحقول الأساسية المحددة في ملف `config.json`. **يجب** عليك تشغيل `gaianet init` مرة أخرى بعد تحديث التكوين. + + + +لتحديث حقل `chat`، على سبيل المثال، استخدم الأمر التالي: + +```bash +gaianet config --chat-url "https://huggingface.co/second-state/Llama-2-13B-Chat-GGUF/resolve/main/Llama-2-13b-chat-hf-Q5_K_M.gguf" +``` + +لتحديث حقل `chat_ctx_size`، على سبيل المثال، استخدم الأمر التالي: + +```bash +gaianet config --chat-ctx-size 5120 +``` + +فيما يلي جميع خيارات الأمر الفرعي `config`: + +```console +$ gaianet config --help + +Usage: gaianet config [OPTIONS] + +Options: + --chat-url Update the url of chat model. + --chat-ctx-size Update the context size of chat model. + --embedding-url Update the url of embedding model. + --embedding-ctx-size Update the context size of embedding model. + --prompt-template Update the prompt template of chat model. + --port Update the port of LlamaEdge API Server. + --system-prompt Update the system prompt. + --rag-prompt Update the rag prompt. + --rag-policy Update the rag policy [Possible values: system-message, last-user-message]. + --reverse-prompt Update the reverse prompt. + --domain Update the domain of GaiaNet node. + --snapshot Update the Qdrant snapshot. + --qdrant-limit Update the max number of result to return. + --qdrant-score-threshold Update the minimal score threshold for the result. + --base The base directory of GaiaNet node. + --help Show this help message +``` + +استمتع! From 7358c8172adcbb79ddcd9f8ff914150e5dfa8058 Mon Sep 17 00:00:00 2001 From: Ahmad-Mtr Date: Sun, 7 Jul 2024 11:47:22 +0300 Subject: [PATCH 10/36] link README-ar.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 68bae15..ac8a961 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ -[Japanese(日本語)](README-ja.md) | [Chinese(中文)](README-cn.md) | [Turkish (Türkçe)](README-tr.md) | We need your help to translate this README into your native language. +[Japanese(日本語)](README-ja.md) | [Chinese(中文)](README-cn.md) | [Turkish (Türkçe)](README-tr.md) | [Arabic (العربية)](README-ar.md) | We need your help to translate this README into your native language. Like our work? ⭐ Star us! From 230c1a55e9ad2caf658d5a0caa28c782cb3823c1 Mon Sep 17 00:00:00 2001 From: Ikko Eltociear Ashimine Date: Sun, 7 Jul 2024 20:54:43 +0900 Subject: [PATCH 11/36] docs: update docker/README.md peform -> perform --- docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index c429536..4114ee6 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,7 +1,7 @@ # Docker support You can run all the commands in this document without any change on any machine with the latest Docker and at least 8GB of RAM available to the container. -By default, the container uses the CPU to peform computations, which could be slow for large LLMs. For GPUs, +By default, the container uses the CPU to perform computations, which could be slow for large LLMs. For GPUs, * Mac: Everything here works on [Docker Desktop for Mac](https://docs.docker.com/desktop/install/mac-install/). However, the Apple GPU cores will not be available inside Docker containers until [WebGPU is supported by Docker](https://github.com/LlamaEdge/LlamaEdge/blob/main/docker/webgpu.md) later in 2024. * Windows and Linux with Nvidia GPU: You will need to install [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#installation) for Docker. In the instructions below, replace the `latest` tag with `cuda12` or `cuda11` to use take advantage of the GPU, and add the `--device nvidia.com/gpu=all` flag. If you need to build the images yourself, replace `Dockerfile` with `Dockerfile.cuda12` or `Dockerfile.cuda11`. From a838a9b0ff43db79690302abc9bc7c9571637ddb Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Mon, 8 Jul 2024 22:10:00 +0800 Subject: [PATCH 12/36] version(uninstaller): bump to `0.2.0` Signed-off-by: Xin Liu --- uninstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uninstall.sh b/uninstall.sh index 4b7e6eb..cf547ef 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -5,7 +5,7 @@ set -e # path to the default gaianet base directory. It could be changed by the --base option gaianet_base_dir="$HOME/gaianet" -version="v0.1.3" +version="v0.2.0" # print in red color RED=$'\e[0;31m' From 02116493ce086a603a6bf674b87c93f7bbef328c Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Tue, 9 Jul 2024 17:36:02 +0800 Subject: [PATCH 13/36] fix: improve the interaction of upgrade process Signed-off-by: Xin Liu --- install.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index e377f04..ebb0a86 100644 --- a/install.sh +++ b/install.sh @@ -175,12 +175,14 @@ if [ -d "$gaianet_base_dir" ]; then exit 0 else - read -p "The gaianet node will be upgraded to v$version. It is stongly recommended to (1) STOP the running node and (2) backup $gaianet_base_dir directory before continue the upgrade process. Continue? (y/n): " answer - case $answer in - [Yy]* ) printf "\n";; - [Nn]* ) printf "Exiting upgrade process.\n"; exit;; - * ) printf "Please answer y or n.\n"; exit;; - esac + while true; do + read -p "The gaianet node will be upgraded to v$version. It is strongly recommended to (1) STOP the running node and (2) backup $gaianet_base_dir directory before continuing the upgrade process. Continue? (y/n): " answer + case $answer in + [Yy]* ) break;; + [Nn]* ) echo "Upgrade cancelled."; exit;; + * ) echo "Please answer y or n.";; + esac + done fi printf "[+] Performing backup before upgrading to v$version ...\n\n" From 2bf396a2f9ac0c647c1db03d5f7a3ac1cc4fe4cc Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Tue, 9 Jul 2024 17:40:02 +0800 Subject: [PATCH 14/36] version: bump to `0.2.1` Signed-off-by: Xin Liu --- gaianet | 6 +++--- install.sh | 2 +- uninstall.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gaianet b/gaianet index b80db74..4825a0a 100755 --- a/gaianet +++ b/gaianet @@ -4,11 +4,11 @@ set -e # version of CLI tool # Note that the version should kept same as the version of installer -version="0.2.0" +version="0.2.1" # version of the GaiaNet node # Note that the version should kept same as the version of installer -installer_version="0.2.0" +installer_version="0.2.1" # path to the default gaianet base directory. It could be changed by the --base option gaianet_base_dir="$HOME/gaianet" @@ -534,7 +534,7 @@ init() { $sed_i_cmd "s/name = \".*\"/name = \"$address.$domain\"/g" $gaianet_base_dir/gaianet-domain/frpc.toml $sed_i_cmd "s/localPort = \".*\"/localPort = \"$llamaedge_port\"/g" $gaianet_base_dir/gaianet-domain/frpc.toml $sed_i_cmd "s/serverAddr = \".*\"/serverAddr = \"$domain\"/g" $gaianet_base_dir/gaianet-domain/frpc.toml - + # Remove all files in the directory except for frpc and frpc.toml find $gaianet_base_dir/gaianet-domain -type f -not -name 'frpc' -not -name 'frpc.toml' -exec rm -f {} \; diff --git a/install.sh b/install.sh index ebb0a86..c9fc7fd 100644 --- a/install.sh +++ b/install.sh @@ -9,7 +9,7 @@ target=$(uname -m) cwd=$(pwd) repo_branch="main" -version="0.2.0" +version="0.2.1" rag_api_server_version="0.7.2" llama_api_server_version="0.12.2" ggml_bn="b3259" diff --git a/uninstall.sh b/uninstall.sh index cf547ef..9b46d97 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -5,7 +5,7 @@ set -e # path to the default gaianet base directory. It could be changed by the --base option gaianet_base_dir="$HOME/gaianet" -version="v0.2.0" +version="v0.2.1" # print in red color RED=$'\e[0;31m' From 334c48e29f7444baa6bbba8f9882888b8521acad Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Tue, 9 Jul 2024 19:58:07 +0800 Subject: [PATCH 15/36] chore: update installer Signed-off-by: Xin Liu --- install.sh | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index c9fc7fd..e74c9e8 100644 --- a/install.sh +++ b/install.sh @@ -175,14 +175,28 @@ if [ -d "$gaianet_base_dir" ]; then exit 0 else - while true; do - read -p "The gaianet node will be upgraded to v$version. It is strongly recommended to (1) STOP the running node and (2) backup $gaianet_base_dir directory before continuing the upgrade process. Continue? (y/n): " answer - case $answer in - [Yy]* ) break;; - [Nn]* ) echo "Upgrade cancelled."; exit;; - * ) echo "Please answer y or n.";; - esac - done + if [ -t 0 ]; then + # Terminal is attached, proceed as normal + while true; do + read -p "The gaianet node will be upgraded to v$version. It is strongly recommended to (1) STOP the running node and (2) backup $gaianet_base_dir directory before continuing the upgrade process. Continue? (y/n): " answer + case $answer in + [Yy]* ) break;; + [Nn]* ) echo "Upgrade cancelled."; exit;; + * ) echo "Please answer y or n.";; + esac + done + else + # Script is being piped, re-attach terminal input for the read command + exec < /dev/tty + while true; do + read -p "The gaianet node will be upgraded to v$version. It is strongly recommended to (1) STOP the running node and (2) backup $gaianet_base_dir directory before continuing the upgrade process. Continue? (y/n): " answer + case $answer in + [Yy]* ) break;; + [Nn]* ) echo "Upgrade cancelled."; exit;; + * ) echo "Please answer y or n.";; + esac + done + fi fi printf "[+] Performing backup before upgrading to v$version ...\n\n" From b57f426ae85934fd7c01271f9b2be386ce671c5e Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Tue, 9 Jul 2024 20:11:38 +0800 Subject: [PATCH 16/36] chore: update installer Signed-off-by: Xin Liu --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e74c9e8..aabea43 100644 --- a/install.sh +++ b/install.sh @@ -248,7 +248,7 @@ if [ -d "$gaianet_base_dir" ]; then # remove the all existing files and subdirectories in the base directory, except for the backup subdirectory and its contents find "$gaianet_base_dir" -mindepth 1 -not -name 'backup' -not -path '*/backup/*' -not -name '*.gguf' -exec rm -rf {} + - printf "\n" + printf " * Backup done\n\n" elif [ "$reinstall" -eq 1 ]; then printf "[+] Removing the existing $gaianet_base_dir directory ...\n\n" From 8b01b322c0b5ca0cde9c5caa9efef0360f1052a9 Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Tue, 9 Jul 2024 21:30:31 +0800 Subject: [PATCH 17/36] chore: update installer Signed-off-by: Xin Liu --- install.sh | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/install.sh b/install.sh index aabea43..7bd6d01 100644 --- a/install.sh +++ b/install.sh @@ -175,28 +175,7 @@ if [ -d "$gaianet_base_dir" ]; then exit 0 else - if [ -t 0 ]; then - # Terminal is attached, proceed as normal - while true; do - read -p "The gaianet node will be upgraded to v$version. It is strongly recommended to (1) STOP the running node and (2) backup $gaianet_base_dir directory before continuing the upgrade process. Continue? (y/n): " answer - case $answer in - [Yy]* ) break;; - [Nn]* ) echo "Upgrade cancelled."; exit;; - * ) echo "Please answer y or n.";; - esac - done - else - # Script is being piped, re-attach terminal input for the read command - exec < /dev/tty - while true; do - read -p "The gaianet node will be upgraded to v$version. It is strongly recommended to (1) STOP the running node and (2) backup $gaianet_base_dir directory before continuing the upgrade process. Continue? (y/n): " answer - case $answer in - [Yy]* ) break;; - [Nn]* ) echo "Upgrade cancelled."; exit;; - * ) echo "Please answer y or n.";; - esac - done - fi + info "The gaianet node will be upgraded to v$version." fi printf "[+] Performing backup before upgrading to v$version ...\n\n" From 3cebfca512dca73632a6b836513df737308b383f Mon Sep 17 00:00:00 2001 From: dragon Date: Thu, 11 Jul 2024 12:06:31 +0800 Subject: [PATCH 18/36] chore: Generate and save device ID if it doesn't exist --- install.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 7bd6d01..2bb652b 100644 --- a/install.sh +++ b/install.sh @@ -655,8 +655,23 @@ else exit 1 fi -# Generate a random string as Device ID -device_id="device-$(openssl rand -hex 12)" +device_id_file="$gaianet_base_dir/deviceid.txt" + +# Check if the device_id file exists +if [ -f "$device_id_file" ]; then + # The file exists, read device_id from the file + device_id=$(cat "$device_id_file") + # Check if the device_id is empty + if [ -z "$device_id" ]; then + # device_id is empty, generate a new one + device_id="device-$(openssl rand -hex 12)" + echo "$device_id" > "$device_id_file" + fi +else + # The file does not exist, generate a new device_id and save it to the file + device_id="device-$(openssl rand -hex 12)" + echo "$device_id" > "$device_id_file" +fi $sed_i_cmd "s/subdomain = \".*\"/subdomain = \"$subdomain\"/g" $gaianet_base_dir/gaianet-domain/frpc.toml $sed_i_cmd "s/serverAddr = \".*\"/serverAddr = \"$gaianet_domain\"/g" $gaianet_base_dir/gaianet-domain/frpc.toml From a4126b440ae2d1d18befd0d5d29384fc1219d1bf Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Thu, 11 Jul 2024 15:12:07 +0800 Subject: [PATCH 19/36] chore: backup `deviceid.txt` in upgrade process Signed-off-by: Xin Liu --- install.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/install.sh b/install.sh index 2bb652b..445586f 100644 --- a/install.sh +++ b/install.sh @@ -223,6 +223,13 @@ if [ -d "$gaianet_base_dir" ]; then error "Failed to copy the frpc.toml. Reason: the frpc.toml does not exist in $gaianet_base_dir/gaianet-domain." exit 1 fi + # backup deviceid.txt + if [ -f "$gaianet_base_dir/deviceid.txt" ]; then + printf " * Copy deviceid.txt to $gaianet_base_dir/backup/\n" + cp $gaianet_base_dir/deviceid.txt $gaianet_base_dir/backup/ + else + warning " * The deviceid.txt does not exist in $gaianet_base_dir." + fi # remove the all existing files and subdirectories in the base directory, except for the backup subdirectory and its contents find "$gaianet_base_dir" -mindepth 1 -not -name 'backup' -not -path '*/backup/*' -not -name '*.gguf' -exec rm -rf {} + @@ -265,6 +272,7 @@ info " * gaianet CLI tool is installed in $bin_dir" if [ "$upgrade" -eq 1 ]; then printf "[+] Recovering config.json ...\n" + # recover config.json if [ -f "$gaianet_base_dir/backup/config.json" ]; then cp $gaianet_base_dir/backup/config.json $gaianet_base_dir/config.json @@ -655,6 +663,17 @@ else exit 1 fi +if [ "$upgrade" -eq 1 ]; then + # recover deviceid.txt + if [ -f "$gaianet_base_dir/backup/deviceid.txt" ]; then + cp $gaianet_base_dir/backup/deviceid.txt $gaianet_base_dir/deviceid.txt + + info " * The deviceid.txt is recovered in $gaianet_base_dir" + else + warning " * The deviceid.txt does not exist in $gaianet_base_dir/backup/." + fi +fi + device_id_file="$gaianet_base_dir/deviceid.txt" # Check if the device_id file exists From aaa26d7376f29cc6e9fdd0392a424813075ae99a Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Thu, 11 Jul 2024 14:42:04 +0800 Subject: [PATCH 20/36] refactor: check server before test request Signed-off-by: Xin Liu --- gaianet | 86 +++++++++++++++++++++++++++++++++++++++++++++--------- install.sh | 2 +- 2 files changed, 73 insertions(+), 15 deletions(-) diff --git a/gaianet b/gaianet index 4825a0a..6e47195 100755 --- a/gaianet +++ b/gaianet @@ -794,6 +794,7 @@ start() { # start api-server retry_count=0 + start_retry_cout=0 max_retries=3 while true; do @@ -834,20 +835,77 @@ start() { sleep 10 - info " Verify the LlamaEdge API Server. Please wait seconds ..." - status_code=$(curl -o /dev/null -s -w "%{http_code}\n" \ - -X POST http://localhost:$llamaedge_port/v1/chat/completions \ - -H 'accept:application/json' \ - -H 'Content-Type: application/json' \ - -d "{\"messages\":[{\"role\":\"user\", \"content\": \"What is your name?\"}], \"model\":\"$chat_model_stem\"}") + # check if http://localhost:$llamaedge_port/echo is available + # The URL to check + url="http://localhost:$llamaedge_port/echo" + + # Use curl to send a request to the URL + # -s --silent: Silent mode. Don't show progress meter or error messages + # -o /dev/null: Redirect output to /dev/null (no output) + # -w '%{http_code}': Output the HTTP status code + http_status=$(curl -s -o /dev/null -w '%{http_code}' "$url") + + # Check if the HTTP status code is 200 (OK) + if [ "$http_status" -eq 200 ]; then + info " LlamaEdge API Server is ready!" + info " Verify the LlamaEdge API Server. Please wait seconds ..." + status_code=$(curl -o /dev/null -s -w "%{http_code}\n" \ + -X POST http://localhost:$llamaedge_port/v1/chat/completions \ + -H 'accept:application/json' \ + -H 'Content-Type: application/json' \ + -d "{\"messages\":[{\"role\":\"user\", \"content\": \"What is your name?\"}], \"model\":\"$chat_model_stem\"}") + + curl_exit_status=$? + + if [ $curl_exit_status -eq 0 ] && [ "$status_code" -eq 200 ]; then + break + else + tail -2 $log_dir/start-llamaedge.log + + # stop the api-server + pkill -9 wasmedge || true + + # stop supervise if it is running + if svok $gaianet_base_dir > /dev/null 2>&1; then + svc -d $gaianet_base_dir + svc -k $gaianet_base_dir + svc -x $gaianet_base_dir + supervise_pid=$gaianet_base_dir/supervise.pid + if [ -f $supervise_pid ]; then + rm $supervise_pid + fi + rm $gaianet_base_dir/run + rm -rf $gaianet_base_dir/supervise + fi - curl_exit_status=$? + # remove the pid file + llamaedge_pid=$gaianet_base_dir/llamaedge.pid + if [ -f $llamaedge_pid ]; then + rm $llamaedge_pid + fi - if [ $curl_exit_status -eq 0 ] && [ "$status_code" -eq 200 ]; then - break - else - tail -2 $log_dir/start-llamaedge.log + sleep 10 # wait for 10 seconds before retrying + + ((retry_count++)) + if [ $retry_count -ge $((max_retries + 1)) ]; then + error " * Failed to start LlamaEdge API Server after $max_retries retries. Exiting ..." + # stop the Qdrant instance + pkill -9 qdrant || true + qdrant_pid=$gaianet_base_dir/qdrant.pid + if [ -f $qdrant_pid ]; then + rm $qdrant_pid + fi + + # wait for 3 seconds before exiting + sleep 3 + + exit 1 + else + error " * Failed to start LlamaEdge API Server. Retrying ($retry_count)..." + fi + fi + else # stop the api-server pkill -9 wasmedge || true @@ -872,8 +930,8 @@ start() { sleep 10 # wait for 10 seconds before retrying - ((retry_count++)) - if [ $retry_count -ge $((max_retries + 1)) ]; then + ((start_retry_cout++)) + if [ $start_retry_cout -ge $((max_retries + 1)) ]; then error " * Failed to start LlamaEdge API Server after $max_retries retries. Exiting ..." # stop the Qdrant instance @@ -888,7 +946,7 @@ start() { exit 1 else - error " * Failed to start LlamaEdge API Server. Retrying ($retry_count)..." + error " * LlamaEdge API Server is not ready. Retrying ($start_retry_cout)..." fi fi diff --git a/install.sh b/install.sh index 445586f..55ac188 100644 --- a/install.sh +++ b/install.sh @@ -670,7 +670,7 @@ if [ "$upgrade" -eq 1 ]; then info " * The deviceid.txt is recovered in $gaianet_base_dir" else - warning " * The deviceid.txt does not exist in $gaianet_base_dir/backup/." + warning " * The deviceid.txt does not exist in $gaianet_base_dir/backup/. Will generate a new one." fi fi From f7c03870a9460aaf8591073131b50905f74092dd Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Thu, 11 Jul 2024 15:46:33 +0800 Subject: [PATCH 21/36] version: bump to `0.2.2` Signed-off-by: Xin Liu --- gaianet | 4 ++-- install.sh | 8 ++++---- uninstall.sh | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gaianet b/gaianet index 6e47195..8acf061 100755 --- a/gaianet +++ b/gaianet @@ -4,11 +4,11 @@ set -e # version of CLI tool # Note that the version should kept same as the version of installer -version="0.2.1" +version="0.2.2" # version of the GaiaNet node # Note that the version should kept same as the version of installer -installer_version="0.2.1" +installer_version="0.2.2" # path to the default gaianet base directory. It could be changed by the --base option gaianet_base_dir="$HOME/gaianet" diff --git a/install.sh b/install.sh index 55ac188..d32a5a4 100644 --- a/install.sh +++ b/install.sh @@ -9,10 +9,10 @@ target=$(uname -m) cwd=$(pwd) repo_branch="main" -version="0.2.1" -rag_api_server_version="0.7.2" -llama_api_server_version="0.12.2" -ggml_bn="b3259" +version="0.2.2" +rag_api_server_version="0.7.3" +llama_api_server_version="0.12.3" +ggml_bn="b3358" vector_version="0.38.0" dashboard_version="v3.1" diff --git a/uninstall.sh b/uninstall.sh index 9b46d97..724631f 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -5,7 +5,7 @@ set -e # path to the default gaianet base directory. It could be changed by the --base option gaianet_base_dir="$HOME/gaianet" -version="v0.2.1" +version="v0.2.2" # print in red color RED=$'\e[0;31m' From 2f7b3247e4d01e34415e79ba06b0f9129ec7184d Mon Sep 17 00:00:00 2001 From: MileyFu Date: Thu, 11 Jul 2024 22:29:36 +0100 Subject: [PATCH 22/36] Update README-ar.md --- README-ar.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README-ar.md b/README-ar.md index b44feae..8328c68 100644 --- a/README-ar.md +++ b/README-ar.md @@ -25,8 +25,7 @@ قم بتثبيت حزمة برامج العقدة الافتراضية باستخدام أمر واحد على نظام التشغيل Mac أو Linux أو Windows WSL. -```bash -curl -sSfL 'https://github.com/GaiaNet-AI/gaianet-node/releases/latest/download/install.sh' | bash +```curl -sSfL 'https://github.com/GaiaNet-AI/gaianet-node/releases/latest/download/install.sh' | bash ``` ثم اتبع التعليمات على شاشتك لإعداد مسار البيئة, سيبدأ سطر الأوامر بالأمر `source`. From 97eadea8ddab14f224e698752d03e7a230f6c6f6 Mon Sep 17 00:00:00 2001 From: MileyFu Date: Thu, 11 Jul 2024 22:33:32 +0100 Subject: [PATCH 23/36] Update README-ar.md --- README-ar.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README-ar.md b/README-ar.md index 8328c68..b44feae 100644 --- a/README-ar.md +++ b/README-ar.md @@ -25,7 +25,8 @@ قم بتثبيت حزمة برامج العقدة الافتراضية باستخدام أمر واحد على نظام التشغيل Mac أو Linux أو Windows WSL. -```curl -sSfL 'https://github.com/GaiaNet-AI/gaianet-node/releases/latest/download/install.sh' | bash +```bash +curl -sSfL 'https://github.com/GaiaNet-AI/gaianet-node/releases/latest/download/install.sh' | bash ``` ثم اتبع التعليمات على شاشتك لإعداد مسار البيئة, سيبدأ سطر الأوامر بالأمر `source`. From 771245f4d6d9eb499e8da5cd8f15b6382f4f24bf Mon Sep 17 00:00:00 2001 From: MileyFu Date: Thu, 11 Jul 2024 22:42:26 +0100 Subject: [PATCH 24/36] Update README-ar.md --- README-ar.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-ar.md b/README-ar.md index b44feae..2625ab1 100644 --- a/README-ar.md +++ b/README-ar.md @@ -15,7 +15,7 @@ -[اليابانية(日本語)](README-ja.md) | [الصينية(中文)](README-cn.md) | [التركية (Türkçe)](README-tr.md) | [العربية (العَرَبية)](README-ar.md) | نحتاجُ الى مساعدتك في ترجمة هذا الملف الى لغتك الأم. +[إنجليزي(English)](README.md) | [اليابانية(日本語)](README-ja.md) | [الصينية(中文)](README-cn.md) | [التركية (Türkçe)](README-tr.md) | [العربية (العَرَبية)](README-ar.md) | نحتاجُ الى مساعدتك في ترجمة هذا الملف الى لغتك الأم. أعجَبَك عَمَلُنا؟ ⭐ قَيْمِنّا بنجمة! From aad57f539f666194fb37183c063e578577e5a6c8 Mon Sep 17 00:00:00 2001 From: MileyFu Date: Fri, 12 Jul 2024 18:32:15 +0100 Subject: [PATCH 25/36] Update README-cn.md --- README-cn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-cn.md b/README-cn.md index 0bfca00..7a5be47 100644 --- a/README-cn.md +++ b/README-cn.md @@ -19,7 +19,7 @@ 在 Mac、Linux 或 Windows WSL 上只需一行命令即可安装默认节点软件栈。 ```bash -curl -sSfL 'https://raw.githubusercontent.com/GaiaNet-AI/gaianet-node/main/install.sh' | bash +curl -sSfL 'https://github.com/GaiaNet-AI/gaianet-node/releases/latest/download/install.sh' | bash ``` 初始化节点。这将下载 `$HOME/gaianet/config.json` 文件中指定的模型文件和矢量数据库文件,由于文件较大,可能需要几分钟时间。 From ca89140aca10f7ae802cb979ff77467086bdb8a1 Mon Sep 17 00:00:00 2001 From: MileyFu Date: Fri, 12 Jul 2024 19:55:54 +0100 Subject: [PATCH 26/36] Update README-ja.md --- README-ja.md | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/README-ja.md b/README-ja.md index 26cc7e0..afe746c 100644 --- a/README-ja.md +++ b/README-ja.md @@ -17,15 +17,15 @@ Mac、Linux、またはWindows WSLで、一行のコマンドでデフォルトのノードソフトウェアスタックをインストールします。 -``` -curl -sSfL 'https://raw.githubusercontent.com/GaiaNet-AI/gaianet-node/main/install.sh' | bash +```bash +curl -sSfL 'https://github.com/GaiaNet-AI/gaianet-node/releases/latest/download/install.sh' | bash ``` ノードを初期化します。`$HOME/gaianet/config.json`ファイルに指定されたモデルファイルとベクターデータベースファイルをダウンロードしますが、ファイルが大きいため数分かかる場合があります。 -``` +```bash gaianet init ``` @@ -33,7 +33,7 @@ gaianet init ノードを開始します。 -``` +```bash gaianet start ``` @@ -43,22 +43,21 @@ gaianet start ``` -... ... https://0xf63939431ee11267f4855a166e11cc44d24960c0.gaianet.xyz +... ... https://0xf63939431ee11267f4855a166e11cc44d24960c0.us.gaianet.network ``` ノードを停止するには、次のスクリプトを実行します。 -``` +```bash gaianet stop ``` - ## インストールガイド -``` +```bash curl -sSfL 'https://raw.githubusercontent.com/GaiaNet-AI/gaianet-node/main/install.sh' | bash ``` @@ -66,7 +65,7 @@ curl -sSfL 'https://raw.githubusercontent.com/GaiaNet-AI/gaianet-node/main/insta
出力は以下のようになります: -``` +```console [+] Downloading default config file ... [+] Downloading nodeid.json ... @@ -132,8 +131,7 @@ gaianet init
出力は以下のようになります: - -``` +```bash [+] Downloading Llama-2-7b-chat-hf-Q5_K_M.gguf ... ############################################################################################################################## 100.0%############################################################################################################################## 100.0% @@ -155,24 +153,21 @@ gaianet init * Recovery is done successfully ``` -
`init` コマンドは、`$HOME/gaianet/config.json` ファイルに従ってノードを初期化します。 - -``` +```bash gaianet init --config https://raw.githubusercontent.com/GaiaNet-AI/node-configs/main/llama-3-8b-instruct_london/config.json ``` - プリセット設定のリストを見るには、`gaianet init --help` を実行できます。 `gaianet_docs`のようなプリセット設定の他に、ノードが希望する状態に初期化されるように自分の `config.json` のURLを渡すこともできます。 別のディレクトリにインストールされたノードを初期化するには、以下を実行します。 -``` +```bash gaianet init --base $HOME/gaianet.alt ``` @@ -188,7 +183,7 @@ gaianet start
出力は以下のようになります: -``` +```bash [+] Starting Qdrant instance ... Qdrant instance started with pid: 39762 @@ -209,23 +204,20 @@ wasmedge --dir .:./dashboard --nn-preload default:GGML:AUTO:Llama-2-7b-chat-hf-Q ローカルでノードを開始することができます。これは `localhost` 経由でのみアクセス可能で、GaiaNetドメインの公開URLでは利用できません。 -``` +```bash gaianet start --local-only ``` 別のベースディレクトリにインストールされたノードも開始できます。 - -``` +```bash gaianet start --base $HOME/gaianet.alt ``` - - ### ノードを停止 -``` +```bash gaianet stop ``` @@ -233,7 +225,7 @@ gaianet stop
出力は以下のようになります: -``` +```bash [+] Stopping WasmEdge, Qdrant and frpc ... ``` @@ -243,7 +235,7 @@ gaianet stop 別のベースディレクトリにインストールされたノードを停止します。 -``` +```bash gaianet stop --base $HOME/gaianet.alt ``` @@ -256,7 +248,7 @@ gaianet stop --base $HOME/gaianet.alt たとえば、`chat` フィールドを更新するには、次のコマンドを使用します: -``` +```bash gaianet config --chat-url "https://huggingface.co/second-state/Llama-2-13B-Chat-GGUF/resolve/main/Llama-2-13b-chat-hf-Q5_K_M.gguf" ``` @@ -264,7 +256,7 @@ gaianet config --chat-url "https://huggingface.co/second-state/Llama-2-13B-Chat- たとえば、`chat_ctx_size` フィールドを更新するには、次のコマンドを使用します: -``` +```bash gaianet config --chat-ctx-size 5120 ``` @@ -272,7 +264,7 @@ gaianet config --chat-ctx-size 5120 `config` サブコマンドのすべてのオプションは以下の通りです。 -``` +```console $ gaianet config --help 使用方法: gaianet config [OPTIONS] From c36ad61da94e370b90ddeac03e7b896e7425c70c Mon Sep 17 00:00:00 2001 From: MileyFu Date: Fri, 12 Jul 2024 20:01:49 +0100 Subject: [PATCH 27/36] Update README-cn.md --- README-cn.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README-cn.md b/README-cn.md index 7a5be47..97daba4 100644 --- a/README-cn.md +++ b/README-cn.md @@ -22,7 +22,7 @@ curl -sSfL 'https://github.com/GaiaNet-AI/gaianet-node/releases/latest/download/install.sh' | bash ``` -初始化节点。这将下载 `$HOME/gaianet/config.json` 文件中指定的模型文件和矢量数据库文件,由于文件较大,可能需要几分钟时间。 +初始化节点。这将下载 `$HOME/gaianet/config.json` 文件中指定的模型文件和向量数据库文件,由于文件较大,可能需要几分钟时间。 ```bash gaianet init @@ -39,7 +39,7 @@ gaianet start 您可以打开浏览器访问该 URL,查看节点信息并与节点上的人工智能代理聊天。 ``` -... ... https://0xf63939431ee11267f4855a166e11cc44d24960c0.gaianet.xyz +... ... https://0xf63939431ee11267f4855a166e11cc44d24960c0.us.gaianet.network ``` 要停止节点,可以运行以下脚本。 From 0da4d4da9d37ed7500e7455e7e556d3176814d4e Mon Sep 17 00:00:00 2001 From: MileyFu Date: Fri, 12 Jul 2024 20:12:49 +0100 Subject: [PATCH 28/36] Update README-tr.md --- README-tr.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README-tr.md b/README-tr.md index 3be34de..171f703 100644 --- a/README-tr.md +++ b/README-tr.md @@ -17,7 +17,7 @@ Mac, Linux veya Windows WSL'de tek bir komut satırıyla varsayılan düğüm yazılım yığınını yükleyin. ```bash -curl -sSfL 'https://raw.githubusercontent.com/GaiaNet-AI/gaianet-node/main/install.sh' | bash +curl -sSfL 'https://github.com/GaiaNet-AI/gaianet-node/releases/latest/download/install.sh' | bash ``` Düğümü başlatın. Bu işlem `$HOME/gaianet/config.json` dosyasında belirtilen model dosyalarını ve vektör veritabanı dosyalarını indirecektir ve dosyalar büyük olduğu için birkaç dakika sürebilir. @@ -53,7 +53,7 @@ curl -sSfL 'https://raw.githubusercontent.com/GaiaNet-AI/gaianet-node/main/insta
Çıktı aşağıdaki gibi görünmelidir: -``` +```console [+] Downloading default config file ... [+] Downloading nodeid.json ... @@ -132,6 +132,7 @@ gaianet init * Recovery is done successfully ``` +
init` komutu düğümü `$HOME/gaianet/config.json` dosyasına göre başlatır. Önceden ayarlanmış konfigürasyonlarımızdan bazılarını kullanabilirsiniz. From b87afdaece140e833d60bc581f8a908749b3240a Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Tue, 16 Jul 2024 13:33:49 +0900 Subject: [PATCH 29/36] chore: update default `tmpdir` and qdrant version Signed-off-by: Xin Liu --- install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index d32a5a4..92614ac 100644 --- a/install.sh +++ b/install.sh @@ -27,9 +27,9 @@ config_url="" # path to the gaianet base directory gaianet_base_dir="$HOME/gaianet" # qdrant binary -qdrant_version="v1.9.4" +qdrant_version="v1.10.1" # tmp directory -tmp_dir="/tmp" +tmp_dir="$gaianet_base_dir/tmp" # specific CUDA enabled GGML plugin ggmlcuda="" # 0: disable vector, 1: enable vector @@ -52,7 +52,7 @@ function print_usage { printf " --base Specify a path to the gaianet base directory\n" printf " --reinstall Install and download all required deps\n" printf " --upgrade Upgrade the gaianet node\n" - printf " --tmpdir Specify a path to the temporary directory [default: /tmp]\n" + printf " --tmpdir Specify a path to the temporary directory [default: $gaianet_base_dir/tmp]\n" printf " --ggmlcuda [11/12] Install a specific CUDA enabled GGML plugin version [Possible values: 11, 12].\n" # printf " --unprivileged: install the gaianet CLI tool into base directory instead of system directory\n" printf " --enable-vector: Install vector log aggregator\n" From b63a11f39bf8c7e318a9c18f53ea3195761b10ec Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Tue, 16 Jul 2024 13:47:49 +0900 Subject: [PATCH 30/36] feat: support local snapshot file in CLI tool Signed-off-by: Xin Liu --- gaianet | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/gaianet b/gaianet index 8acf061..a75e6e9 100755 --- a/gaianet +++ b/gaianet @@ -244,16 +244,31 @@ create_collection() { # 10.1 recover from the given qdrant collection snapshot if [ -n "$url_snapshot" ]; then - printf " * Download Qdrant collection snapshot ...\n" - if [[ $url_snapshot == *.tar.gz ]]; then - filename=$(basename $url_snapshot) - check_curl $url_snapshot $gaianet_base_dir/$filename - tar -xzOf $gaianet_base_dir/$filename > $gaianet_base_dir/default.snapshot - rm $gaianet_base_dir/$filename + # Regular expression for URL validation + regex="^(https?|ftp)://[^\s/$.?#].[^\s]*$" + + # Check if $url_snapshot is a valid URL + if [[ $url_snapshot =~ $regex ]]; then + printf " * Download Qdrant collection snapshot ...\n" + if [[ $url_snapshot == *.tar.gz ]]; then + filename=$(basename $url_snapshot) + check_curl $url_snapshot $gaianet_base_dir/$filename + tar -xzOf $gaianet_base_dir/$filename > $gaianet_base_dir/default.snapshot + rm $gaianet_base_dir/$filename + else + check_curl $url_snapshot $gaianet_base_dir/default.snapshot + fi + info " The snapshot is downloaded in $gaianet_base_dir" + + # Check if $url_snapshot is a local file + elif [ -f "$gaianet_base_dir/$url_snapshot" ]; then + # rename the file to default.snapshot + info " * Rename $url_snapshot to default.snapshot ..." + cp $gaianet_base_dir/$url_snapshot $gaianet_base_dir/default.snapshot + else - check_curl $url_snapshot $gaianet_base_dir/default.snapshot + echo "$url_snapshot is neither a valid URL nor a local file." fi - info " The snapshot is downloaded in $gaianet_base_dir" printf " * Import the Qdrant collection snapshot ...\n" printf " The process may take a few minutes. Please wait ...\n" @@ -271,7 +286,8 @@ create_collection() { error " * [Error] Failed to recover from the collection snapshot. $response" if [ "$qdrant_already_running" = false ]; then - kill $qdrant_pid + info " * Stop the Qdrant instance ..." + kill -9 $qdrant_pid fi exit 1 From 89e277f89dbf019f07e2df2197b347bbab2b4fbc Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Sat, 20 Jul 2024 10:29:22 +0900 Subject: [PATCH 31/36] version: bump to `0.2.3` Signed-off-by: Xin Liu --- gaianet | 4 ++-- install.sh | 8 ++++---- uninstall.sh | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gaianet b/gaianet index a75e6e9..6bed5c5 100755 --- a/gaianet +++ b/gaianet @@ -4,11 +4,11 @@ set -e # version of CLI tool # Note that the version should kept same as the version of installer -version="0.2.2" +version="0.2.3" # version of the GaiaNet node # Note that the version should kept same as the version of installer -installer_version="0.2.2" +installer_version="0.2.3" # path to the default gaianet base directory. It could be changed by the --base option gaianet_base_dir="$HOME/gaianet" diff --git a/install.sh b/install.sh index 92614ac..73a6d02 100644 --- a/install.sh +++ b/install.sh @@ -9,10 +9,10 @@ target=$(uname -m) cwd=$(pwd) repo_branch="main" -version="0.2.2" -rag_api_server_version="0.7.3" -llama_api_server_version="0.12.3" -ggml_bn="b3358" +version="0.2.3" +rag_api_server_version="0.7.4" +llama_api_server_version="0.12.4" +ggml_bn="b3405" vector_version="0.38.0" dashboard_version="v3.1" diff --git a/uninstall.sh b/uninstall.sh index 724631f..13035a2 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -5,7 +5,7 @@ set -e # path to the default gaianet base directory. It could be changed by the --base option gaianet_base_dir="$HOME/gaianet" -version="v0.2.2" +version="v0.2.3" # print in red color RED=$'\e[0;31m' From 23805f4565d03f10f49a9353a28d07b8fadebde5 Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Sat, 20 Jul 2024 10:55:39 +0900 Subject: [PATCH 32/36] chore: update regex pattern Signed-off-by: Xin Liu --- gaianet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gaianet b/gaianet index 6bed5c5..307fd71 100755 --- a/gaianet +++ b/gaianet @@ -245,7 +245,7 @@ create_collection() { # 10.1 recover from the given qdrant collection snapshot if [ -n "$url_snapshot" ]; then # Regular expression for URL validation - regex="^(https?|ftp)://[^\s/$.?#].[^\s]*$" + regex='(https?|ftp)://[-[:alnum:]\+&@#/%?=~_|!:,.;]+' # Check if $url_snapshot is a valid URL if [[ $url_snapshot =~ $regex ]]; then From 8319469bb4972184f0c0e449ea6a352a2aa66cb1 Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Sat, 20 Jul 2024 11:04:08 +0900 Subject: [PATCH 33/36] chore: remove unused log message Signed-off-by: Xin Liu --- gaianet | 1 - 1 file changed, 1 deletion(-) diff --git a/gaianet b/gaianet index 307fd71..246b8a4 100755 --- a/gaianet +++ b/gaianet @@ -263,7 +263,6 @@ create_collection() { # Check if $url_snapshot is a local file elif [ -f "$gaianet_base_dir/$url_snapshot" ]; then # rename the file to default.snapshot - info " * Rename $url_snapshot to default.snapshot ..." cp $gaianet_base_dir/$url_snapshot $gaianet_base_dir/default.snapshot else From ee02593d6a1b602eb162578b9ff65a63adb6e7c1 Mon Sep 17 00:00:00 2001 From: alabulei1 Date: Sat, 20 Jul 2024 10:09:34 +0800 Subject: [PATCH 34/36] Create SECURITY.md --- SECURITY.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..bf0f12e --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,13 @@ +### Reporting a vulnerability + +For all Gaia security-related defects, please send an email to security@gaianet.ai. You will receive an acknowledgment mail within 24 hours. After that, we will be sure to give a detailed response about the next step in 48 hours. Please do not submit security vulnerabilities directly as GitHub Issues. + +### Disclosure policy + +We will disclose known public security vulnerabilities as soon as possible after receiving the report. Vulnerabilities discovered for the first time will be disclosed by the following process: + +* The received security vulnerability report shall be handed over to the security team for follow-up coordination and repair work. +* After the vulnerability is confirmed, we will create a draft Security Advisory on Github that lists the details of the vulnerability. +* Invite related personnel to discuss about the fix. +* Fork the temporary private repository on Github, and collaborate to fix the vulnerability. +* After the fix code is merged into all supported versions, the vulnerability will be publicly posted in the GitHub Advisory Database. From 6f9ad8a13b409c0c1143a38bf012193d97658873 Mon Sep 17 00:00:00 2001 From: Venus <30389296+CodeAunt@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:15:37 +0800 Subject: [PATCH 35/36] Update README.md for regenerate node Id Add content about regenerate node Id. Change a typo "THen" by the way. --- docker/README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 4114ee6..e1e3232 100644 --- a/docker/README.md +++ b/docker/README.md @@ -109,10 +109,43 @@ docker cp /local/path/to/nodeid.json gaianet:/root/gaianet/nodeid.json docker cp /local/path/to/1234-abcd-key-store gaianet:/root/gaianet/1234-abcd-key-store ``` -THen, restart the node for the new address and keystore to take effect. +Then, restart the node for the new address and keystore to take effect. ``` docker stop gaianet docker start gaianet ``` +## Regenerate the node Id + +You can also regenerate the nodeId associated with the node. + +First, you need to clear the old nodeId configuration. + +Edit the `nodeid.json` file in the base dir and it should look like the default `nodeid.json` in [nodeid.json](https://github.com/GaiaNet-AI/gaianet-node/blob/main/nodeid.json): +``` +{ +} +``` +And clear the address field in `config.json` and it should look like: +``` +{ + "address": "", + ... +} +``` + +Second, run the `registry.wasm` file: +``` +wasmedge --dir .:. registry.wasm +``` +The output of the command is your new key file stored in your base dir. + +And in the nodeid.json file you can find your new nodeId and key newly generated. +``` +{ + "address": "0xd5ed...d181", + "keystore": "afe0...a12b", + "password": "..." +} +``` From 039d6ebea9f5955719b3a6777a432bc32d480b9a Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Wed, 24 Jul 2024 10:24:51 +0900 Subject: [PATCH 36/36] feat: support local snapshot file with `tar.gz` extension Signed-off-by: Xin Liu --- gaianet | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gaianet b/gaianet index 246b8a4..5dcd193 100755 --- a/gaianet +++ b/gaianet @@ -262,8 +262,13 @@ create_collection() { # Check if $url_snapshot is a local file elif [ -f "$gaianet_base_dir/$url_snapshot" ]; then - # rename the file to default.snapshot - cp $gaianet_base_dir/$url_snapshot $gaianet_base_dir/default.snapshot + info " * Use local snapshot: $url_snapshot" + if [[ $url_snapshot == *.tar.gz ]]; then + tar -xzOf $gaianet_base_dir/$url_snapshot > $gaianet_base_dir/default.snapshot + else + # make a copy of the original snapshot file + cp $gaianet_base_dir/$url_snapshot $gaianet_base_dir/default.snapshot + fi else echo "$url_snapshot is neither a valid URL nor a local file."