From 5b8c09264cc71a6575b607427671883652871b8b Mon Sep 17 00:00:00 2001 From: Marco Vinciguerra Date: Wed, 30 Oct 2024 14:08:34 +0100 Subject: [PATCH 1/4] Create install.sh --- install.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..7b69765 --- /dev/null +++ b/install.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# 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 + +# 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 + source .venv/Scripts/activate +else + source .venv/bin/activate +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 + +# Install Playwright (optional) +read -p "Would you like to install Playwright drivers? (y/n) " -n 1 -r +echo +if [[ $REPLY =~ ^[Yy]$ ]]; then + echo "🎭 Installing Playwright..." + playwright install +fi + +# Create .env file if it doesn't exist +if [ ! -f .env ]; then + echo "📝 Creating .env file..." + cp .env-example .env + echo "⚠️ Please edit .env file with your API keys and configuration" +fi + +echo "✅ Installation complete!" +echo "🚀 To start Agent-E, activate the virtual environment and run: python -m ae.main" +echo "📝 Don't forget to configure your .env file with the necessary API keys and settings" From 4a86fb59864eb4d4ad04dffa3cbaf554eaeb82a6 Mon Sep 17 00:00:00 2001 From: teaxio Date: Fri, 1 Nov 2024 15:57:38 -0400 Subject: [PATCH 2/4] add config json and helpful messages --- ae/utils/logger.py | 2 +- install.sh | 66 +++++++++++++++++++++++++++----- requirements.txt | 16 +++++++- win_install.ps1 | 95 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 168 insertions(+), 11 deletions(-) mode change 100644 => 100755 install.sh create mode 100644 win_install.ps1 diff --git a/ae/utils/logger.py b/ae/utils/logger.py index 658b516..f8fbfc5 100644 --- a/ae/utils/logger.py +++ b/ae/utils/logger.py @@ -40,7 +40,7 @@ def configure_logger(level: str = "INFO") -> None: http_loggers = ["openai", "autogen"] for http_logger in http_loggers: lib_logger = logging.getLogger(http_logger) - lib_logger.setLevel(logging.DEBUG) + lib_logger.setLevel(logging._nameToLevel[level.upper()]) lib_logger.handlers = [] # Clear any existing handlers lib_logger.addHandler(handler) # Add the same handler diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 7b69765..42546e3 --- a/install.sh +++ b/install.sh @@ -1,5 +1,14 @@ #!/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 @@ -13,6 +22,15 @@ if ! command_exists python3; then 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..." @@ -28,9 +46,19 @@ uv venv --python 3.11 # Determine the activation script based on OS if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then - source .venv/Scripts/activate + 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 - source .venv/bin/activate + 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 @@ -42,21 +70,41 @@ uv pip install -r requirements.txt echo "🛠️ Installing development dependencies..." uv pip install -r pyproject.toml --extra dev -# Install Playwright (optional) -read -p "Would you like to install Playwright drivers? (y/n) " -n 1 -r -echo -if [[ $REPLY =~ ^[Yy]$ ]]; then +# 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 - echo "⚠️ Please edit .env file with your API keys and configuration" + 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!" -echo "🚀 To start Agent-E, activate the virtual environment and run: python -m ae.main" -echo "📝 Don't forget to configure your .env file with the necessary API keys and settings" + +# 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 diff --git a/requirements.txt b/requirements.txt index ca3bd51..890eb49 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/win_install.ps1 b/win_install.ps1 new file mode 100644 index 0000000..75bdac5 --- /dev/null +++ b/win_install.ps1 @@ -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" +} From 51420457741d850a714d3d88c4416441686f5c4b Mon Sep 17 00:00:00 2001 From: Tamer <70958516+teaxio@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:59:22 -0400 Subject: [PATCH 3/4] revert logger.py --- ae/utils/logger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ae/utils/logger.py b/ae/utils/logger.py index f8fbfc5..658b516 100644 --- a/ae/utils/logger.py +++ b/ae/utils/logger.py @@ -40,7 +40,7 @@ def configure_logger(level: str = "INFO") -> None: http_loggers = ["openai", "autogen"] for http_logger in http_loggers: lib_logger = logging.getLogger(http_logger) - lib_logger.setLevel(logging._nameToLevel[level.upper()]) + lib_logger.setLevel(logging.DEBUG) lib_logger.handlers = [] # Clear any existing handlers lib_logger.addHandler(handler) # Add the same handler From bb852dc1d2440c7da78d32972afd8ae958940a80 Mon Sep 17 00:00:00 2001 From: teaxio Date: Fri, 1 Nov 2024 16:40:42 -0400 Subject: [PATCH 4/4] Instructions to use new install scripts --- README.md | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 823f0dc..7e2bcf5 100644 --- a/README.md +++ b/README.md @@ -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.