Skip to content

Commit

Permalink
Merge branch 'main' into v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dongyuanjushi committed Oct 15, 2024
2 parents de19cbf + e2ee970 commit 470e7a9
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions installer/linux-installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash

# 1. Clone the GitHub repository
echo "Cloning the AIOS..."
git clone https://github.com/agiresearch/AIOS.git
cd repository || exit

# 2. Create a new environment and install dependencies
echo "Creating a virtual environment..."
python3 -m venv venv
source venv/bin/activate

echo "Installing dependencies..."
pip install -r requirements.txt

# 3. Set up API keys interactively
echo "Setting up API keys..."

# Check if the config file exists; if not, create one
CONFIG_FILE=".env"
if [ ! -f "$CONFIG_FILE" ]; then
touch "$CONFIG_FILE"
fi

# Ask the user for API keys interactively and store them
save_api_key() {
local key_name="$1"
local user_input="$2"

if [ -n "$user_input" ]; then
echo "$key_name=$user_input" >> "$CONFIG_FILE"
echo "$key_name has been saved."
else
echo "$key_name was skipped."
fi
}

# Ask the user for API keys interactively and allow pressing Enter to skip
read -p "Enter your OPENAI API key for using openai models (or press Enter to skip): " OPENAI_API_KEY
save_api_key "OPENAI_API_KEY" "$OPENAI_API_KEY"

read -p "Enter your Huggingface token for using open-sourced models (or press Enter to skip): " HF_AUTH_TOKENS
save_api_key "HF_AUTH_TOKENS" "$HF_AUTH_TOKENS"

# Notify the user where keys are stored
echo "Installation complete. Your API keys are saved in $CONFIG_FILE if provided."

# 4. Exit the script, leaving the environment active
echo "Activate your environment with: source venv/bin/activate"
Explanation of Changes:
Function to Save API Keys: The save_api_key function is used to store API keys only if the user enters a value. If the input is empty (i.e., the user pressed "Enter"), the key is skipped.

bash
复制代码
save_api_key() {
local key_name="$1"
local user_input="$2"

if [ -n "$user_input" ]; then
echo "$key_name=$user_input" >> "$CONFIG_FILE"
echo "$key_name has been saved."
else
echo "$key_name was skipped."
fi
}

0 comments on commit 470e7a9

Please sign in to comment.