Skip to content

Commit

Permalink
Merge pull request #108 from VinciGit00/master
Browse files Browse the repository at this point in the history
Create install.sh
  • Loading branch information
teaxio authored Nov 3, 2024
2 parents 7f48ba6 + bb852dc commit 36bb938
Show file tree
Hide file tree
Showing 4 changed files with 258 additions and 4 deletions.
41 changes: 38 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,45 @@ This provides a natural language way to interacting with a web browser:
While Agent-E is growing, it is already equipped to handle a versatile range of tasks, but the best task is the one that you come up with. So, take it for a spin and tell us what you were able to do with it. For more information see our [blog article](https://www.emergence.ai/blog/distilling-the-web-for-multi-agent-automation).


## Quick Start
## Setup

## Quick Start Using Scripts
To get started with Agent-E, follow the steps below to install dependencies and configure your environment.
#### 1. Run the Installation Script

- **macOS/Linux**:
- From the project root, run the following command to set up the environment and install all dependencies:
```bash
./install.sh
```
- For **Playwright support**, you can pass the `-p` flag to install Playwright without further prompting:
```bash
./install.sh -p
```

- **Windows**:
- From the project root, execute the following command in PowerShell:
```powershell
.\win_install.ps1
```
- To install Playwright without further prompting, add the `-p` flag:
```powershell
.\win_install.ps1 -p
```
#### 2. Configure Environment Variables
- Go to the newly created `.env` and `agents_llm_config.json` and follow the instructions to set the fields

#### 3. Run Agent-E
Once you have set up the environment and installed all the dependencies, you can run Agent-E using the following command:
```bash
python -m ae.main
```

**For macOS Users**
```bash
python -u -m ae.main
```


## Manual Setup

### 1. Install `uv`
Agent-E uses `uv` to manage the Python virtual environment and package dependencies.
Expand Down
110 changes: 110 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash

# Parse options
install_playwright=false
while getopts "p" opt; do
case ${opt} in
p ) install_playwright=true ;;
\? ) echo "Usage: install.sh [-p]" ;;
esac
done

# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}

echo "🤖 Installing Agent-E..."

# Check Python version
if ! command_exists python3; then
echo "❌ Python 3 is required but not installed. Please install Python 3.10 or higher."
exit 1
fi

# Playwright installation check
if [ "$install_playwright" = false ]; then
read -p "Would you like to install Playwright drivers? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
install_playwright=true
fi
fi

# Install uv if not present
if ! command_exists uv; then
echo "📦 Installing uv package manager..."
curl -LsSf https://astral.sh/uv/install.sh | sh

# Add uv to current shell session
export PATH="$HOME/.cargo/bin:$PATH"
fi

# Create and activate virtual environment
echo "🔧 Creating virtual environment..."
uv venv --python 3.11

# Determine the activation script based on OS
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
if [ -f .venv/Scripts/activate ]; then
source .venv/Scripts/activate
else
echo "❌ Virtual environment activation script not found. Ensure virtual environment is created successfully."
exit 1
fi
else
if [ -f .venv/bin/activate ]; then
source .venv/bin/activate
else
echo "❌ Virtual environment activation script not found. Ensure virtual environment is created successfully."
exit 1
fi
fi

# Install dependencies
echo "📚 Installing dependencies..."
uv pip compile pyproject.toml -o requirements.txt
uv pip install -r requirements.txt

# Install development dependencies
echo "🛠️ Installing development dependencies..."
uv pip install -r pyproject.toml --extra dev

# Optional Playwright installation
if [ "$install_playwright" = true ]; then
echo "🎭 Installing Playwright..."
playwright install
fi

# Create .env file if it doesn't exist
new_env_file_created=false
if [ ! -f .env ]; then
echo "📝 Creating .env file..."
cp .env-example .env
new_env_file_created=true
fi

# Create agents_llm_config.json if it doesn't exist
new_agents_llm_config=false
if [ ! -f agents_llm_config.json ]; then
echo "📝 Creating agents_llm_config.json file..."
cp agents_llm_config-example.json agents_llm_config.json
new_agents_llm_config=true
fi

echo "✅ Installation complete!"

# Configuration guidance
if [ "$new_env_file_created" = true ]; then
echo "⚠️ Please edit the .env file with your API keys and configuration."
fi

if [ "$new_agents_llm_config" = true ]; then
echo "⚠️ Please edit the agents_llm_config.json file with your LLM configuration."
fi

if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
echo "🚀 To start Agent-E, activate the virtual environment (source .venv/Scripts/activate) and run: python -m ae.main"
else
echo "🚀 To start Agent-E, activate the virtual environment (source .venv/bin/activate) and run: python -u -m ae.main"
fi
16 changes: 15 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
annotated-types==0.6.0
# via pydantic
anthropic==0.23.1
# via agent-e (pyproject.toml)
anyio==4.3.0
# via
# anthropic
Expand Down Expand Up @@ -43,6 +44,7 @@ docker==7.0.0
email-validator==2.2.0
# via fastapi
fastapi==0.111.1
# via agent-e (pyproject.toml)
fastapi-cli==0.0.4
# via fastapi
filelock==3.13.3
Expand Down Expand Up @@ -70,6 +72,7 @@ google-auth==2.29.0
google-auth-httplib2==0.2.0
# via google-api-python-client
google-generativeai==0.5.1
# via agent-e (pyproject.toml)
googleapis-common-protos==1.63.0
# via
# google-api-core
Expand Down Expand Up @@ -118,7 +121,9 @@ markupsafe==2.1.5
mdurl==0.1.2
# via markdown-it-py
nest-asyncio==1.6.0
# via agent-e (pyproject.toml)
nltk==3.8.1
# via agent-e (pyproject.toml)
numpy==1.26.4
# via
# flaml
Expand All @@ -132,9 +137,11 @@ packaging==23.2
pdfminer-six==20231228
# via pdfplumber
pdfplumber==0.11.1
# via agent-e (pyproject.toml)
pillow==10.3.0
# via pdfplumber
playwright==1.44.0
# via agent-e (pyproject.toml)
proto-plus==1.23.0
# via
# google-ai-generativelanguage
Expand All @@ -154,10 +161,12 @@ pyasn1==0.6.0
pyasn1-modules==0.4.0
# via google-auth
pyautogen==0.2.27
# via agent-e (pyproject.toml)
pycparser==2.22
# via cffi
pydantic==2.6.2
# via
# agent-e (pyproject.toml)
# anthropic
# fastapi
# google-generativeai
Expand All @@ -175,9 +184,11 @@ pypdfium2==4.30.0
# via pdfplumber
python-dotenv==1.0.0
# via
# agent-e (pyproject.toml)
# pyautogen
# uvicorn
python-json-logger==2.0.7
# via agent-e (pyproject.toml)
python-multipart==0.0.9
# via fastapi
pyyaml==6.0.1
Expand Down Expand Up @@ -209,6 +220,7 @@ sniffio==1.3.1
starlette==0.37.2
# via fastapi
tabulate==0.9.0
# via agent-e (pyproject.toml)
termcolor==2.4.0
# via pyautogen
tiktoken==0.6.0
Expand Down Expand Up @@ -241,7 +253,9 @@ urllib3==2.2.1
# docker
# requests
uvicorn==0.30.3
# via fastapi
# via
# agent-e (pyproject.toml)
# fastapi
uvloop==0.19.0
# via uvicorn
watchfiles==0.22.0
Expand Down
95 changes: 95 additions & 0 deletions win_install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
param (
[switch]$p # Short flag to install Playwright
)

Write-Output "Installing Agent-E..."

# Function to check if a command exists
function Command-Exists {
param (
[string]$Command
)
return $null -ne (Get-Command $Command -ErrorAction SilentlyContinue)
}

# Check Python version
if (-not (Command-Exists 'python3')) {
Write-Output "Python 3 is required but not installed. Please install Python 3.10 or higher."
exit 1
}

# Ask the user about Playwright installation if the flag is not provided
$installPlaywright = $false
if (-not $p) {
$response = Read-Host "Would you like to install Playwright drivers? (y/n)"
if ($response -match '^[Yy]$') {
$installPlaywright = $true
}
} else {
$installPlaywright = $true
}

# Install `uv` if not present
if (-not (Command-Exists 'uv')) {
Write-Output "Installing uv package manager..."
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://astral.sh/uv/install.ps1'))

# Add uv to current session
$cargoBinPath = Join-Path $HOME ".cargo/bin"
$env:PATH = "$env:PATH;$cargoBinPath"
}

# Create and activate virtual environment
Write-Output "Creating virtual environment..."
uv venv --python 3.11

# Activate virtual environment
if (Test-Path ".venv\Scripts\Activate.ps1") {
. .venv\Scripts\Activate.ps1
} else {
Write-Output "Virtual environment activation script not found. Ensure virtual environment is created successfully."
exit 1
}

# Install dependencies
Write-Output "Installing dependencies..."
uv pip compile pyproject.toml -o requirements.txt
uv pip install -r requirements.txt

# Install development dependencies
Write-Output "Installing development dependencies..."
uv pip install -r pyproject.toml --extra dev

# Optional Playwright installation
if ($installPlaywright) {
Write-Output "Installing Playwright..."
playwright install
}

$new_env_file_created = $false
# Create .env file if it doesn't exist
if (-not (Test-Path ".env")) {
$new_env_file_created = $true
Write-Output "Creating .env file..."
Copy-Item ".env-example" ".env"
Write-Output "Please edit .env file with your API keys and configuration"
}

$new_agents_llm_config = $false
if (-not (Test-Path "agents_llm_config.json")) {
$new_agents_llm_config = $true
Write-Output "Creating agents_llm_config.json"
Copy-Item "agents_llm_config-example.json" "agents_llm_config.json"
Write-Output "Please edit agents_llm_config.json file with your LLM config"
}

Write-Output "Installation complete!"
Write-Output "To start Agent-E, activate the virtual environment (source .venv/Scripts/activate) and run: python -m ae.main"

if ($new_env_file_created) {
Write-Output "Don't forget to configure your .env file with the necessary API keys and settings."
}

if ($new_agents_llm_config) {
Write-Output "Don't forget to configure agents_llm_config.json"
}

0 comments on commit 36bb938

Please sign in to comment.