From b0950d346bb3607badc6038070c9b57090f304d1 Mon Sep 17 00:00:00 2001 From: letonghan Date: Tue, 14 Oct 2025 14:35:01 +0800 Subject: [PATCH 1/9] init Signed-off-by: letonghan --- BrowserUseAgent/Dockerfile | 25 +++++ BrowserUseAgent/browser_use_agent.py | 96 +++++++++++++++++++ .../intel/hpu/gaudi/compose.yaml | 35 +++++++ .../docker_compose/intel/hpu/gaudi/set_env.sh | 9 ++ BrowserUseAgent/requirements.txt | 1 + 5 files changed, 166 insertions(+) create mode 100644 BrowserUseAgent/Dockerfile create mode 100644 BrowserUseAgent/browser_use_agent.py create mode 100644 BrowserUseAgent/docker_compose/intel/hpu/gaudi/compose.yaml create mode 100644 BrowserUseAgent/docker_compose/intel/hpu/gaudi/set_env.sh create mode 100644 BrowserUseAgent/requirements.txt diff --git a/BrowserUseAgent/Dockerfile b/BrowserUseAgent/Dockerfile new file mode 100644 index 0000000000..738477d5dc --- /dev/null +++ b/BrowserUseAgent/Dockerfile @@ -0,0 +1,25 @@ +# Copyright (C) 2025 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +ARG IMAGE_REPO=opea +ARG BASE_TAG=latest +FROM $IMAGE_REPO/comps-base:$BASE_TAG + +RUN apt update && apt install -y software-properties-common && \ + add-apt-repository -y ppa:deadsnakes/ppa && \ + apt install python3.12 python3.12-venv python3.12-distutils -y python3.12 --version && \ + playwright install chromium --with-deps --no-shell && \ + apt clean && rm -rf /var/lib/apt/lists/* + +COPY ./requirements.txt $HOME/requirements.txt +COPY ./browser_use_agent.py $HOME/browser_use_agent.py + +USER root +ARG uvpip='uv pip install --system --no-cache-dir' +RUN pip install --no-cache-dir --upgrade pip setuptools uv && \ + $uvpip -r requirements.txt && \ + chown -R user:user $HOME + +USER user + +ENTRYPOINT ["python", "browser_use_agent.py"] diff --git a/BrowserUseAgent/browser_use_agent.py b/BrowserUseAgent/browser_use_agent.py new file mode 100644 index 0000000000..6aaf70ef8a --- /dev/null +++ b/BrowserUseAgent/browser_use_agent.py @@ -0,0 +1,96 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + + +import os +from pydantic import BaseModel, SecretStr +from fastapi import Request +from langchain_openai import ChatOpenAI +from browser_use import Agent, BrowserProfile +from comps import opea_microservices, register_microservice +from comps.cores.telemetry.opea_telemetry import opea_telemetry + + +LLM = None +BROWSER_PROFILE = None +LLM_ENDPOINT = os.getenv("LLM_ENDPOINT", "http://0.0.0.0:8000") +LLM_MODEL = os.getenv("LLM_MODEL", "Qwen/Qwen2-VL-72B-Instruct") + + +def initiate_llm_and_browser(llm_endpoint: str, model: str, secret_key: str="sk-xxxxxx"): + # Initialize global LLM and BrowserProfile if not already initialized + global LLM, BROWSER_PROFILE + if not LLM: + LLM = ChatOpenAI( + base_url=llm_endpoint + "/v1", + model = model, + api_key=SecretStr(secret_key), + temperature=0.1, + ) + if not BROWSER_PROFILE: + BROWSER_PROFILE = BrowserProfile( + headless=True, + chromium_sandbox=False, + ) + return LLM, BROWSER_PROFILE + + +class BrowserUseRequest(BaseModel): + task_prompt: str + use_vision: bool = True + secret_key: str = "sk-xxxxxx" + llm_endpoint: str = LLM_ENDPOINT + llm_model: str = LLM_MODEL + agent_max_steps: int = 10 + + +class BrowserUseResponse(BaseModel): + model: str + task_prompt: str + use_vision: bool + agent_researched_urls: list[str] = [] + agent_actions: list[str] = [] + agent_durations: float + agent_steps: int + final_result: str + + +@register_microservice( + name="opea_service@browser_use_agent", + endpoint="/v1/browser_use_agent", + host="0.0.0.0", + port=8022, +) +@opea_telemetry +async def run(request: Request): + data = await request.json() + chat_request = BrowserUseRequest.model_validate(data) + model_name = chat_request.llm_model.split("/")[-1].replace(".", "_").replace("-", "_") + llm, browser_profile = initiate_llm_and_browser( + llm_endpoint=chat_request.llm_endpoint, + model=chat_request.llm_model, + secret_key=chat_request.secret_key + ) + agent = Agent( + task=chat_request.task_prompt, + llm=llm, + agent_name=f"agent_{model_name}", + use_vision=chat_request.use_vision, + enable_memory=False, + browser_profile=browser_profile, + ) + history = await agent.run(max_steps=chat_request.agent_max_steps) + return BrowserUseResponse( + model=chat_request.model, + task_prompt=chat_request.task_prompt, + use_vision=chat_request.use_vision, + agent_researched_urls=history.urls(), + agent_actions=history.action_names(), + agent_durations=round(history.total_duration_seconds(), 3), + agent_steps=history.number_of_steps(), + final_result=history.final_result(), + ) + + +if __name__ == "__main__": + opea_microservices["opea_service@browser_use_agent"].start() \ No newline at end of file diff --git a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/compose.yaml b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/compose.yaml new file mode 100644 index 0000000000..04a93aecd6 --- /dev/null +++ b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/compose.yaml @@ -0,0 +1,35 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +services: + vllm-gaudi-server: + image: ${REGISTRY:-opea}/vllm-gaudi:${TAG:-latest} + container_name: vllm-gaudi-server + ports: + - ${LLM_ENDPOINT_PORT:-8008}:80 + volumes: + - "${DATA_PATH:-./data}:/data" + environment: + no_proxy: ${no_proxy} + http_proxy: ${http_proxy} + https_proxy: ${https_proxy} + HF_TOKEN: ${HF_TOKEN} + HABANA_VISIBLE_DEVICES: all + OMPI_MCA_btl_vader_single_copy_mechanism: none + LLM_MODEL_ID: ${LLM_MODEL_ID} + VLLM_TORCH_PROFILER_DIR: "/mnt" + host_ip: ${host_ip} + LLM_ENDPOINT_PORT: ${LLM_ENDPOINT_PORT} + VLLM_SKIP_WARMUP: ${VLLM_SKIP_WARMUP:-false} + MAX_MODEL_LEN: ${MAX_TOTAL_TOKENS:-4096} + MAX_SEQ_LEN_TO_CAPTURE: ${MAX_TOTAL_TOKENS:-4096} + runtime: habana + cap_add: + - SYS_NICE + ipc: host + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"] + interval: 10s + timeout: 10s + retries: 150 + command: --model $LLM_MODEL_ID --tensor-parallel-size $NUM_CARDS --host 0.0.0.0 --port 80 --block-size 128 --max-num-seqs 16 --max-model-len $MAX_TOTAL_TOKENS diff --git a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/set_env.sh b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/set_env.sh new file mode 100644 index 0000000000..2f8f27dcfc --- /dev/null +++ b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/set_env.sh @@ -0,0 +1,9 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +export LLM_ENDPOINT_PORT=8008 +export DATA_PATH=./data +export HF_TOKEN= +export LLM_MODEL_ID="Qwen/Qwen2.5-VL-32B-Instruct" +export MAX_TOTAL_TOKENS=4096 +export NUM_CARDS=4 diff --git a/BrowserUseAgent/requirements.txt b/BrowserUseAgent/requirements.txt new file mode 100644 index 0000000000..08afe30806 --- /dev/null +++ b/BrowserUseAgent/requirements.txt @@ -0,0 +1 @@ +browser-use==0.3.2 From d25fe29cd8d066e03a285fa6be1718dc1170a78d Mon Sep 17 00:00:00 2001 From: Joshua Yao Date: Sat, 18 Oct 2025 03:51:13 +0000 Subject: [PATCH 2/9] Consolidate BrowserUseAgent example Signed-off-by: Joshua Yao --- .github/CODEOWNERS | 1 + BrowserUseAgent/Dockerfile | 18 +-- BrowserUseAgent/README.md | 17 ++ BrowserUseAgent/browser_use_agent.py | 24 +-- .../docker_compose/intel/hpu/gaudi/README.md | 101 ++++++++++++ .../intel/hpu/gaudi/compose.yaml | 35 ++-- .../docker_compose/intel/hpu/gaudi/set_env.sh | 41 ++++- BrowserUseAgent/docker_image_build/build.yaml | 22 +++ BrowserUseAgent/tests/README.md | 0 .../tests/test_compose_on_gaudi.sh | 152 ++++++++++++++++++ BrowserUseAgent/tests/webarena/README.md | 22 +++ BrowserUseAgent/tests/webarena/set_env.sh | 11 ++ .../tests/webarena/shopping_admin.sh | 83 ++++++++++ 13 files changed, 489 insertions(+), 38 deletions(-) create mode 100644 BrowserUseAgent/README.md create mode 100644 BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md create mode 100644 BrowserUseAgent/docker_image_build/build.yaml create mode 100644 BrowserUseAgent/tests/README.md create mode 100644 BrowserUseAgent/tests/test_compose_on_gaudi.sh create mode 100644 BrowserUseAgent/tests/webarena/README.md create mode 100644 BrowserUseAgent/tests/webarena/set_env.sh create mode 100644 BrowserUseAgent/tests/webarena/shopping_admin.sh diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5033ca6483..fc1636b743 100755 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,6 +5,7 @@ /AgentQnA/ abolfazl.shahbazi@intel.com kaokao.lv@intel.com minmin.hou@intel.com xinyu.ye@intel.com /AudioQnA/ sihan.chen@intel.com wenjiao.yue@intel.com /AvatarChatbot/ chun.tao@intel.com kaokao.lv@intel.com xinyu.ye@intel.com +/BrowserUseAgent/ letong.han@intel.com yi.a.yao@intel.com /ChatQnA/ liang1.lv@intel.com letong.han@intel.com /CodeGen/ liang1.lv@intel.com qing.yao@intel.com /CodeTrans/ sihan.chen@intel.com letong.han@intel.com diff --git a/BrowserUseAgent/Dockerfile b/BrowserUseAgent/Dockerfile index 738477d5dc..f930359549 100644 --- a/BrowserUseAgent/Dockerfile +++ b/BrowserUseAgent/Dockerfile @@ -5,21 +5,19 @@ ARG IMAGE_REPO=opea ARG BASE_TAG=latest FROM $IMAGE_REPO/comps-base:$BASE_TAG -RUN apt update && apt install -y software-properties-common && \ - add-apt-repository -y ppa:deadsnakes/ppa && \ - apt install python3.12 python3.12-venv python3.12-distutils -y python3.12 --version && \ - playwright install chromium --with-deps --no-shell && \ - apt clean && rm -rf /var/lib/apt/lists/* +USER root + +RUN apt update && apt install vim curl -y COPY ./requirements.txt $HOME/requirements.txt COPY ./browser_use_agent.py $HOME/browser_use_agent.py -USER root ARG uvpip='uv pip install --system --no-cache-dir' -RUN pip install --no-cache-dir --upgrade pip setuptools uv && \ +RUN uv pip install --system --upgrade pip setuptools uv && \ + $uvpip pytest-playwright && \ + playwright install chromium --with-deps --no-shell && \ $uvpip -r requirements.txt && \ - chown -R user:user $HOME + $uvpip posthog==5.4.0 USER user - -ENTRYPOINT ["python", "browser_use_agent.py"] +ENTRYPOINT ["python", "browser_use_agent.py"] \ No newline at end of file diff --git a/BrowserUseAgent/README.md b/BrowserUseAgent/README.md new file mode 100644 index 0000000000..5375bf9406 --- /dev/null +++ b/BrowserUseAgent/README.md @@ -0,0 +1,17 @@ +# Browser-use Agent Application +Browser-use agent empowers anyone to automate repetitive web tasks. It controls your web browser to perform tasks like visiting websites and extracting data. The application is powered by [browser-use](https://github.com/browser-use/browser-use) and OPEA LLM serving microservice. + + +## Deployment Options + +The table below lists currently available deployment options. They outline in detail the implementation of this example on selected hardware. + +| Category | Deployment Option | Description | +| ---------------------- | ---------------------- | ----------------------------------------------------------------- | +| On-premise Deployments | Docker Compose (Gaudi) | [Deployment on Gaudi](./docker_compose/intel/hpu/gaudi/README.md) | + +## Validated Configurations + +| **Deploy Method** | **LLM Engine** | **LLM Model** | **Hardware** | +| ----------------- | -------------- | -------------------------------------- | ------------ | +| Docker Compose | vLLM | meta-llama/Meta-Llama-3.3-70B-Instruct | Intel Gaudi | \ No newline at end of file diff --git a/BrowserUseAgent/browser_use_agent.py b/BrowserUseAgent/browser_use_agent.py index 6aaf70ef8a..559e237e7c 100644 --- a/BrowserUseAgent/browser_use_agent.py +++ b/BrowserUseAgent/browser_use_agent.py @@ -10,11 +10,10 @@ from comps import opea_microservices, register_microservice from comps.cores.telemetry.opea_telemetry import opea_telemetry - LLM = None BROWSER_PROFILE = None -LLM_ENDPOINT = os.getenv("LLM_ENDPOINT", "http://0.0.0.0:8000") -LLM_MODEL = os.getenv("LLM_MODEL", "Qwen/Qwen2-VL-72B-Instruct") +LLM_ENDPOINT = os.getenv("LLM_ENDPOINT", "http://0.0.0.0:8008") +LLM_MODEL = os.getenv("LLM_MODEL", "Qwen/Qwen2.5-VL-32B-Instruct") def initiate_llm_and_browser(llm_endpoint: str, model: str, secret_key: str="sk-xxxxxx"): @@ -22,10 +21,10 @@ def initiate_llm_and_browser(llm_endpoint: str, model: str, secret_key: str="sk- global LLM, BROWSER_PROFILE if not LLM: LLM = ChatOpenAI( - base_url=llm_endpoint + "/v1", - model = model, + base_url=f"{llm_endpoint}/v1", + model=model, api_key=SecretStr(secret_key), - temperature=0.1, + temperature=0.1 ) if not BROWSER_PROFILE: BROWSER_PROFILE = BrowserProfile( @@ -45,6 +44,7 @@ class BrowserUseRequest(BaseModel): class BrowserUseResponse(BaseModel): + is_success: bool = False model: str task_prompt: str use_vision: bool @@ -65,7 +65,6 @@ class BrowserUseResponse(BaseModel): async def run(request: Request): data = await request.json() chat_request = BrowserUseRequest.model_validate(data) - model_name = chat_request.llm_model.split("/")[-1].replace(".", "_").replace("-", "_") llm, browser_profile = initiate_llm_and_browser( llm_endpoint=chat_request.llm_endpoint, model=chat_request.llm_model, @@ -74,23 +73,24 @@ async def run(request: Request): agent = Agent( task=chat_request.task_prompt, llm=llm, - agent_name=f"agent_{model_name}", use_vision=chat_request.use_vision, enable_memory=False, browser_profile=browser_profile, ) history = await agent.run(max_steps=chat_request.agent_max_steps) + return BrowserUseResponse( - model=chat_request.model, + is_success=history.is_successful() if history.is_successful() is not None else False, + model=chat_request.llm_model, task_prompt=chat_request.task_prompt, use_vision=chat_request.use_vision, agent_researched_urls=history.urls(), agent_actions=history.action_names(), agent_durations=round(history.total_duration_seconds(), 3), agent_steps=history.number_of_steps(), - final_result=history.final_result(), - ) - + final_result=history.final_result() if history.is_successful() else f"Task failed: {history.errors()}", + ) + if __name__ == "__main__": opea_microservices["opea_service@browser_use_agent"].start() \ No newline at end of file diff --git a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md new file mode 100644 index 0000000000..14eee4c1f1 --- /dev/null +++ b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md @@ -0,0 +1,101 @@ +# Example BrowserUseAgent deployments on an Intel® Gaudi® Platform + +This example covers the single-node on-premises deployment of the BrowserUseAgent example using OPEA components. This example begins with a Quick Start section and then documents how to modify deployments, leverage new models and configure the number of allocated devices. + +**Note** This example requires access to a properly installed Intel® Gaudi® platform with a functional Docker service configured to use the habanalabs-container-runtime. Please consult the [Intel® Gaudi® software Installation Guide](https://docs.habana.ai/en/v1.20.1/Installation_Guide/Driver_Installation.html) for more information. + + +## Quick Start Deployment + +This section describes how to quickly deploy and test the BrowserUseAgent service manually on an Intel® Gaudi® platform. The basic steps are: + +1. [Access the Code](#access-the-code) +2. [Generate a HuggingFace Access Token](#generate-a-huggingface-access-token) +3. [Configure the Deployment Environment](#configure-the-deployment-environment) +4. [Deploy the Services Using Docker Compose](#deploy-the-services-using-docker-compose) +5. [Check the Deployment Status](#check-the-deployment-status) +6. [Test the Pipeline](#test-the-pipeline) +7. [Cleanup the Deployment](#cleanup-the-deployment) + + +### Access the Code + +Clone the GenAIExample repository and access the BrowserUseAgent Intel® Gaudi® platform Docker Compose files and supporting scripts: + +```bash +git clone https://github.com/opea-project/GenAIExamples.git +cd GenAIExamples/BrowserUseAgent/docker_compose/intel/hpu/gaudi/ +``` + +Checkout a released version, such as v1.5: + +```bash +git checkout v1.5 +``` + + +### Generate a HuggingFace Access Token + +Some HuggingFace resources, such as some models, are only accessible if you have an access token. If you do not already have a HuggingFace access token, you can create one by first creating an account by following the steps provided at [HuggingFace](https://huggingface.co/) and then generating a [user access token](https://huggingface.co/docs/transformers.js/en/guides/private#step-1-generating-a-user-access-token). + + +### Configure the Deployment Environment + +To set up environment variables for deploying BrowserUseAgent services, source the _setup_env.sh_ script in this directory: + +```bash +source ./set_env.sh +``` + +The _set_env.sh_ script will prompt for required and optional environment variables used to configure the ChatQnA services. If a value is not entered, the script will use a default value for the same. Users need to check if the values fit your deployment environment. + + +### Deploy the Services Using Docker Compose + +To deploy the BrowserUseAgent services, execute the `docker compose up` command with the appropriate arguments. For a default deployment, execute: + +```bash +docker compose up -d +``` + +The BrowserUseAgent docker images should automatically be downloaded from the `OPEA registry` and deployed on the Intel® Gaudi® Platform. + + +### Check the Deployment Status + +After running docker compose, check if all the containers launched via docker compose have started: + +```bash +docker ps -a +``` + +For the default deployment, the following 10 containers should have started: + +``` +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +96cb590c749c opea/browser-use-agent:latest "python browser_use_…" 9 seconds ago Up 8 seconds 0.0.0.0:8022->8022/tcp, :::8022->8022/tcp browser-use-agent-server +8072e1c33a4b opea/vllm-gaudi:latest "python3 -m vllm.ent…" 9 seconds ago Up 8 seconds (health: starting) 0.0.0.0:8008->80/tcp, [::]:8008->80/tcp vllm-gaudi-server +``` + +### Test the Pipeline + +If you don't have existing websites to test, follow the [guide](./../../../../tests/webarena/README.md) to deploy one in your local environment. + +Once the BrowserUseAgent services are running, test the pipeline using the following command: + +```bash +curl -X POST http://${host_ip}:${BROWSER_USE_AGENT_PORT}/v1/browser_use_agent \ + -H "Content-Type: application/json" \ + -d '{"task_prompt": "Nagivate to http://10.7.4.57:8083/admin and login with the credentials: username: admin, password: admin1234. Then, find out What are the top-2 best-selling product in 2022?"}' +``` + +* Note that Update the `task_prompt` to match the evaluation question relevant to your configured website. + + +### Cleanup the Deployment + +To stop the containers associated with the deployment, execute the following command: + +```bash +docker compose -f compose.yaml down +``` \ No newline at end of file diff --git a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/compose.yaml b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/compose.yaml index 04a93aecd6..42c2bc546b 100644 --- a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/compose.yaml +++ b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/compose.yaml @@ -1,28 +1,30 @@ # Copyright (C) 2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +x-common-environment: + &common-env + no_proxy: ${no_proxy} + http_proxy: ${http_proxy} + https_proxy: ${https_proxy} + services: vllm-gaudi-server: - image: ${REGISTRY:-opea}/vllm-gaudi:${TAG:-latest} + image: ${REGISTRY:-opea}/vllm-gaudi:${TAG:-1.22.0} container_name: vllm-gaudi-server ports: - ${LLM_ENDPOINT_PORT:-8008}:80 volumes: - "${DATA_PATH:-./data}:/data" environment: - no_proxy: ${no_proxy} - http_proxy: ${http_proxy} - https_proxy: ${https_proxy} + <<: *common-env HF_TOKEN: ${HF_TOKEN} + HF_HOME: /data HABANA_VISIBLE_DEVICES: all OMPI_MCA_btl_vader_single_copy_mechanism: none LLM_MODEL_ID: ${LLM_MODEL_ID} VLLM_TORCH_PROFILER_DIR: "/mnt" - host_ip: ${host_ip} - LLM_ENDPOINT_PORT: ${LLM_ENDPOINT_PORT} - VLLM_SKIP_WARMUP: ${VLLM_SKIP_WARMUP:-false} - MAX_MODEL_LEN: ${MAX_TOTAL_TOKENS:-4096} - MAX_SEQ_LEN_TO_CAPTURE: ${MAX_TOTAL_TOKENS:-4096} + VLLM_SKIP_WARMUP: true + PT_HPU_ENABLE_LAZY_COLLECTIVES: true runtime: habana cap_add: - SYS_NICE @@ -32,4 +34,17 @@ services: interval: 10s timeout: 10s retries: 150 - command: --model $LLM_MODEL_ID --tensor-parallel-size $NUM_CARDS --host 0.0.0.0 --port 80 --block-size 128 --max-num-seqs 16 --max-model-len $MAX_TOTAL_TOKENS + command: --model $LLM_MODEL_ID --tensor-parallel-size $NUM_CARDS --host 0.0.0.0 --port 80 --max-seq-len-to-capture $MAX_TOTAL_TOKENS + + browser-use-agent-server: + image: ${REGISTRY:-opea}/browser-use-agent:${TAG:-latest} + container_name: browser-use-agent-server + depends_on: + - vllm-gaudi-server + ports: + - ${BROWSER_USE_AGENT_PORT:-8022}:8022 + environment: + <<: *common-env + LLM_ENDPOINT: ${LLM_ENDPOINT-http://0.0.0.0:8008} + LLM_MODEL: ${LLM_MODEL_ID-Qwen/Qwen2-VL-72B-Instruct} + ipc: host \ No newline at end of file diff --git a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/set_env.sh b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/set_env.sh index 2f8f27dcfc..b6a36a5eef 100644 --- a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/set_env.sh +++ b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/set_env.sh @@ -1,9 +1,38 @@ +#!/usr/bin/env bash + # Copyright (C) 2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -export LLM_ENDPOINT_PORT=8008 -export DATA_PATH=./data -export HF_TOKEN= -export LLM_MODEL_ID="Qwen/Qwen2.5-VL-32B-Instruct" -export MAX_TOTAL_TOKENS=4096 -export NUM_CARDS=4 +# Navigate to the parent directory and source the environment +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + +pushd "$SCRIPT_DIR/../../../../../" > /dev/null +source .set_env.sh +popd > /dev/null + +# Function to check if a variable is set +check_var() { + if [ "$#" -ne 1 ]; then + echo "Error: Usage: check_var " >&2 + return 2 + fi + + local var_name="$1" + if [ -n "${!var_name}" ]; then + # Variable value is non-empty + return 0 + else + # Variable is unset or set to an empty string + return 1 + fi +} + +check_var "HF_TOKEN" +export ip_address=$(hostname -I | awk '{print $1}') + +export LLM_ENDPOINT_PORT="${LLM_ENDPOINT_PORT:-8008}" +export LLM_ENDPOINT="http://${ip_address}:${LLM_ENDPOINT_PORT}" +export DATA_PATH="${DATA_PATH-"./data"}" +export LLM_MODEL_ID="${LLM_MODEL_ID-"Qwen/Qwen2.5-VL-32B-Instruct"}" +export MAX_TOTAL_TOKENS="${MAX_TOTAL_TOKENS-12288}" +export NUM_CARDS="${NUM_CARDS-4}" \ No newline at end of file diff --git a/BrowserUseAgent/docker_image_build/build.yaml b/BrowserUseAgent/docker_image_build/build.yaml new file mode 100644 index 0000000000..723c29064d --- /dev/null +++ b/BrowserUseAgent/docker_image_build/build.yaml @@ -0,0 +1,22 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +services: + browser-use-agent: + build: + args: + IMAGE_REPO: ${REGISTRY} + BASE_TAG: ${TAG} + http_proxy: ${http_proxy} + https_proxy: ${https_proxy} + no_proxy: ${no_proxy} + context: ../ + dockerfile: ./Dockerfile + image: ${REGISTRY:-opea}/browser-use-agent:${TAG:-latest} + + vllm-gaudi: + build: + context: vllm-fork + dockerfile: ./docker/Dockerfile.hpu + extends: browser-use-agent + image: ${REGISTRY:-opea}/vllm-gaudi:${TAG:-latest} \ No newline at end of file diff --git a/BrowserUseAgent/tests/README.md b/BrowserUseAgent/tests/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/BrowserUseAgent/tests/test_compose_on_gaudi.sh b/BrowserUseAgent/tests/test_compose_on_gaudi.sh new file mode 100644 index 0000000000..0b080ec66f --- /dev/null +++ b/BrowserUseAgent/tests/test_compose_on_gaudi.sh @@ -0,0 +1,152 @@ +#!/bin/bash +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +set -xe +IMAGE_REPO=${IMAGE_REPO:-"opea"} +IMAGE_TAG=${IMAGE_TAG:-"latest"} +echo "REGISTRY=IMAGE_REPO=${IMAGE_REPO}" +echo "TAG=IMAGE_TAG=${IMAGE_TAG}" +export REGISTRY=${IMAGE_REPO} +export TAG=${IMAGE_TAG} +export MODEL_CACHE=${model_cache:-"./data"} +export HF_TOKEN=${HF_TOKEN} +export LLM_ENDPOINT_PORT=8008 +export LLM_ENDPOINT="http://0.0.0.0:${LLM_ENDPOINT_PORT}" +export BROWSER_USE_AGENT_PORT=8022 +export LLM_MODEL_ID="Qwen/Qwen2.5-VL-32B-Instruct" +export MAX_TOTAL_TOKENS=131072 +export NUM_CARDS=4 + +WORKPATH=$(dirname "$PWD") +LOG_PATH="$WORKPATH/tests" +ip_address=$(hostname -I | awk '{print $1}') + +function build_docker_images() { + opea_branch=${opea_branch:-"main"} + cd $WORKPATH/docker_image_build + git clone --depth 1 --branch ${opea_branch} https://github.com/opea-project/GenAIComps.git + pushd GenAIComps + echo "GenAIComps test commit is $(git rev-parse HEAD)" + docker build --no-cache -t ${REGISTRY}/comps-base:${TAG} --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile . + popd && sleep 1s + + VLLM_FORK_VER=v0.9.0.1+Gaudi-1.22.0 + git clone --depth 1 -b ${VLLM_FORK_VER} --single-branch https://github.com/HabanaAI/vllm-fork.git + + echo "Build all the images with --no-cache, check docker_image_build.log for details..." + docker compose -f build.yaml build --no-cache --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy > ${LOG_PATH}/docker_image_build.log + + docker images && sleep 1s +} + +function start_services() { + cd $WORKPATH/docker_compose/intel/hpu/gaudi + source set_env.sh + + # Start Docker Containers + docker compose -f compose.yaml up -d --quiet-pull > ${LOG_PATH}/start_services_with_compose.log + n=0 + until [[ "$n" -ge 200 ]]; do + echo "n=$n" + docker logs vllm-gaudi-server > vllm_service_start.log 2>&1 + if grep -q "Application startup complete" vllm_service_start.log; then + break + fi + sleep 5s + n=$((n+1)) + done +} + +function validate_service() { + local URL="$1" + local EXPECTED_RESULT="$2" + local SERVICE_NAME="$3" + local DOCKER_NAME="$4" + local INPUT_DATA="$5" + + local HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST -d "$INPUT_DATA" -H 'Content-Type: application/json' "$URL") + if [ "$HTTP_STATUS" -eq 200 ]; then + echo "[ $SERVICE_NAME ] HTTP status is 200. Checking content..." + + local CONTENT=$(curl -s -X POST -d "$INPUT_DATA" -H 'Content-Type: application/json' "$URL" | tee ${LOG_PATH}/${SERVICE_NAME}.log) + + if echo "$CONTENT" | grep -q "$EXPECTED_RESULT"; then + echo "[ $SERVICE_NAME ] Content is as expected." + else + echo "[ $SERVICE_NAME ] Content does not match the expected result: $CONTENT" + docker logs ${DOCKER_NAME} >> ${LOG_PATH}/${SERVICE_NAME}.log + exit 1 + fi + else + echo "[ $SERVICE_NAME ] HTTP status is not 200. Received status was $HTTP_STATUS" + docker logs ${DOCKER_NAME} >> ${LOG_PATH}/${SERVICE_NAME}.log + exit 1 + fi + sleep 1s +} + +function validate_microservices() { + # vllm for llm service + validate_service \ + "${ip_address}:${LLM_ENDPOINT_PORT}/v1/chat/completions" \ + "content" \ + "vllm-llm" \ + "vllm-gaudi-server" \ + '{"model": "'${LLM_MODEL_ID}'", "messages": [{"role": "user", "content": "What is Deep Learning?"}], "max_tokens":17}' +} + +function validate_megaservice() { + # start web server for testing + cd $WORKPATH/tests/webarena + bash shopping_admin.sh start + + # Curl the Mega Service + validate_service \ + "${ip_address}:${BROWSER_USE_AGENT_PORT}/v1/browser_use_agent" \ + "\"is_success\":true" \ + "browser-use-agent" \ + "browser-use-agent-server" \ + '{"task_prompt": "Nagivate to http://10.7.4.57:8084/admin and login with the credentials: username: admin, password: admin1234. Then, find out What are the top-3 best-selling product in 2022?"}' +} + +function stop_docker() { + cd $WORKPATH/docker_compose/intel/hpu/gaudi + docker compose -f compose.yaml down + + cd $WORKPATH/tests/webarena + bash shopping_admin.sh stop +} + +function main() { + + # echo "::group::stop_docker" + # stop_docker + # echo "::endgroup::" + + # echo "::group::build_docker_images" + # if [[ "$IMAGE_REPO" == "opea" ]]; then build_docker_images; fi + # echo "::endgroup::" + + # echo "::group::start_services" + # start_services + # sleep 30 + # echo "::endgroup::" + + # echo "::group::validate_microservices" + # validate_microservices + # echo "::endgroup::" + + echo "::group::validate_megaservice" + validate_megaservice + echo "::endgroup::" + + # echo "::group::stop_docker" + # stop_docker + # echo "::endgroup::" + + # docker system prune -f + +} + +main diff --git a/BrowserUseAgent/tests/webarena/README.md b/BrowserUseAgent/tests/webarena/README.md new file mode 100644 index 0000000000..af770a4807 --- /dev/null +++ b/BrowserUseAgent/tests/webarena/README.md @@ -0,0 +1,22 @@ +# Setup Scripts for Webarena + +We will launch a shopping admin website, part of [WebArena](https://github.com/web-arena-x/webarena), to serve as a web server for agent evaluation. The deployment process will follow the instructions in the [webarena-setup](https://github.com/gasse/webarena-setup) repository. + + +## Download Docker Image + +1. Download shopping_admin_final_0719.tar from the [official webarena repo](https://github.com/web-arena-x/webarena/tree/main/environment_docker). + +2. Place the archive file, shopping_admin_final_0719.tar, into the directory specified by the `ARCHIVES_LOCATION` parameter within `tests/webarena/set_env.sh` + + +## Launch the Web Site +Please ensure Docker services work in your environment, and perform the following command to launch the web site: +```bash +bash shopping_admin.sh start +``` + +## Stop the Web Site +``` bash +bash shopping_admin.sh stop +``` \ No newline at end of file diff --git a/BrowserUseAgent/tests/webarena/set_env.sh b/BrowserUseAgent/tests/webarena/set_env.sh new file mode 100644 index 0000000000..7e81f40a57 --- /dev/null +++ b/BrowserUseAgent/tests/webarena/set_env.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +WORKING_DIR=$(pwd) +PUBLIC_HOSTNAME=$(hostname -I | awk '{print $1}') +SHOPPING_ADMIN_USER=admin +SHOPPING_ADMIN_PASSWORD=admin1234 +SHOPPING_ADMIN_PORT=8084 +SHOPPING_ADMIN_URL="http://${PUBLIC_HOSTNAME}:${SHOPPING_ADMIN_PORT}/admin" +ARCHIVES_LOCATION="/data2/hf_model" \ No newline at end of file diff --git a/BrowserUseAgent/tests/webarena/shopping_admin.sh b/BrowserUseAgent/tests/webarena/shopping_admin.sh new file mode 100644 index 0000000000..b3e3c4fc04 --- /dev/null +++ b/BrowserUseAgent/tests/webarena/shopping_admin.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# Reference: https://github.com/gasse/webarena-setup + +# stop if any error occur +set -e + +BASE_DIR=`dirname "${BASH_SOURCE[0]}"` +source ${BASE_DIR}/set_env.sh + +assert() { + if ! "$@"; then + echo "Assertion failed: $@" >&2 + exit 1 + fi +} + +load_docker_image() { + local IMAGE_NAME="$1" + local INPUT_FILE="$2" + + if ! docker images --format "{{.Repository}}:{{.Tag}}" | grep -q "^${IMAGE_NAME}:"; then + echo "Loading Docker image ${IMAGE_NAME} from ${INPUT_FILE}" + docker load --input "${INPUT_FILE}" + else + echo "Docker image ${IMAGE_NAME} is already loaded." + fi +} + +start() { + # Verify that the docker image archive file exists + assert [ -f ${ARCHIVES_LOCATION}/shopping_admin_final_0719.tar ] + + # Load image + load_docker_image "shopping_admin_final_0719" ${ARCHIVES_LOCATION}/shopping_admin_final_0719.tar + + # Create and run the container + docker create --name shopping_admin_server -p ${SHOPPING_ADMIN_PORT}:80 shopping_admin_final_0719 + + # Start the container + docker start shopping_admin_server + echo -n -e "Waiting 60 seconds for all services to start..." + sleep 60 + echo -n -e " done\n" + + echo -n -e "Configuring Magento settings inside the container..." + docker exec shopping_admin_server php /var/www/magento2/bin/magento config:set admin/security/password_is_forced 0 + docker exec shopping_admin_server php /var/www/magento2/bin/magento config:set admin/security/password_lifetime 0 + docker exec shopping_admin_server /var/www/magento2/bin/magento setup:store-config:set --base-url="http://${PUBLIC_HOSTNAME}:${SHOPPING_ADMIN_PORT}" + docker exec shopping_admin_server mysql -u magentouser -pMyPassword magentodb -e "UPDATE core_config_data SET value='http://$PUBLIC_HOSTNAME:$SHOPPING_ADMIN_PORT/' WHERE path = 'web/secure/base_url';" + docker exec shopping_admin_server /var/www/magento2/bin/magento cache:flush + echo -n -e " done\n" +} + +stop() { + docker stop shopping_admin_server || true + docker rm shopping_admin_server || true +} + +case "$1" in + start) + echo "Starting shopping_admin server..." + start + echo "shopping_admin server started." + ;; + stop) + echo "Stopping shopping_admin server..." + stop + echo "shopping_admin server stopped." + ;; + restart) + echo "Restarting shopping_admin server..." + $stop + sleep 2 + start + echo "shopping_admin server restarted." + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac \ No newline at end of file From ef2a9dbd43d57ec8981e7422050b7c761790374f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 18 Oct 2025 09:50:37 +0000 Subject: [PATCH 3/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- BrowserUseAgent/README.md | 10 +++--- BrowserUseAgent/browser_use_agent.py | 34 ++++++++----------- .../docker_compose/intel/hpu/gaudi/README.md | 15 +++----- .../intel/hpu/gaudi/compose.yaml | 2 +- .../docker_compose/intel/hpu/gaudi/set_env.sh | 2 +- BrowserUseAgent/docker_image_build/build.yaml | 2 +- .../tests/test_compose_on_gaudi.sh | 2 +- BrowserUseAgent/tests/webarena/README.md | 9 ++--- BrowserUseAgent/tests/webarena/set_env.sh | 2 +- .../tests/webarena/shopping_admin.sh | 2 +- 10 files changed, 34 insertions(+), 46 deletions(-) diff --git a/BrowserUseAgent/README.md b/BrowserUseAgent/README.md index faa7075af9..a15ca1e5d5 100644 --- a/BrowserUseAgent/README.md +++ b/BrowserUseAgent/README.md @@ -1,6 +1,6 @@ # Browser-use Agent Application -Browser-use agent empowers anyone to automate repetitive web tasks. It controls your web browser to perform tasks like visiting websites and extracting data. The application is powered by [browser-use](https://github.com/browser-use/browser-use) and OPEA LLM serving microservice. +Browser-use agent empowers anyone to automate repetitive web tasks. It controls your web browser to perform tasks like visiting websites and extracting data. The application is powered by [browser-use](https://github.com/browser-use/browser-use) and OPEA LLM serving microservice. ## Deployment Options @@ -12,7 +12,7 @@ The table below lists currently available deployment options. They outline in de ## Validated Configurations -| **Deploy Method** | **LLM Engine** | **LLM Model** | **Hardware** | -| ----------------- | -------------- | -------------------------------------- | ------------ | -| Docker Compose | vLLM | Qwen/Qwen2.5-VL-32B-Instruct | Intel Gaudi | -| Docker Compose | vLLM | Qwen/Qwen2.5-VL-72B-Instruct | Intel Gaudi | \ No newline at end of file +| **Deploy Method** | **LLM Engine** | **LLM Model** | **Hardware** | +| ----------------- | -------------- | ---------------------------- | ------------ | +| Docker Compose | vLLM | Qwen/Qwen2.5-VL-32B-Instruct | Intel Gaudi | +| Docker Compose | vLLM | Qwen/Qwen2.5-VL-72B-Instruct | Intel Gaudi | diff --git a/BrowserUseAgent/browser_use_agent.py b/BrowserUseAgent/browser_use_agent.py index 559e237e7c..78b97d464b 100644 --- a/BrowserUseAgent/browser_use_agent.py +++ b/BrowserUseAgent/browser_use_agent.py @@ -3,12 +3,13 @@ import os -from pydantic import BaseModel, SecretStr -from fastapi import Request -from langchain_openai import ChatOpenAI + from browser_use import Agent, BrowserProfile from comps import opea_microservices, register_microservice from comps.cores.telemetry.opea_telemetry import opea_telemetry +from fastapi import Request +from langchain_openai import ChatOpenAI +from pydantic import BaseModel, SecretStr LLM = None BROWSER_PROFILE = None @@ -16,16 +17,11 @@ LLM_MODEL = os.getenv("LLM_MODEL", "Qwen/Qwen2.5-VL-32B-Instruct") -def initiate_llm_and_browser(llm_endpoint: str, model: str, secret_key: str="sk-xxxxxx"): +def initiate_llm_and_browser(llm_endpoint: str, model: str, secret_key: str = "sk-xxxxxx"): # Initialize global LLM and BrowserProfile if not already initialized global LLM, BROWSER_PROFILE if not LLM: - LLM = ChatOpenAI( - base_url=f"{llm_endpoint}/v1", - model=model, - api_key=SecretStr(secret_key), - temperature=0.1 - ) + LLM = ChatOpenAI(base_url=f"{llm_endpoint}/v1", model=model, api_key=SecretStr(secret_key), temperature=0.1) if not BROWSER_PROFILE: BROWSER_PROFILE = BrowserProfile( headless=True, @@ -41,8 +37,8 @@ class BrowserUseRequest(BaseModel): llm_endpoint: str = LLM_ENDPOINT llm_model: str = LLM_MODEL agent_max_steps: int = 10 - - + + class BrowserUseResponse(BaseModel): is_success: bool = False model: str @@ -53,7 +49,7 @@ class BrowserUseResponse(BaseModel): agent_durations: float agent_steps: int final_result: str - + @register_microservice( name="opea_service@browser_use_agent", @@ -66,9 +62,7 @@ async def run(request: Request): data = await request.json() chat_request = BrowserUseRequest.model_validate(data) llm, browser_profile = initiate_llm_and_browser( - llm_endpoint=chat_request.llm_endpoint, - model=chat_request.llm_model, - secret_key=chat_request.secret_key + llm_endpoint=chat_request.llm_endpoint, model=chat_request.llm_model, secret_key=chat_request.secret_key ) agent = Agent( task=chat_request.task_prompt, @@ -78,7 +72,7 @@ async def run(request: Request): browser_profile=browser_profile, ) history = await agent.run(max_steps=chat_request.agent_max_steps) - + return BrowserUseResponse( is_success=history.is_successful() if history.is_successful() is not None else False, model=chat_request.llm_model, @@ -89,8 +83,8 @@ async def run(request: Request): agent_durations=round(history.total_duration_seconds(), 3), agent_steps=history.number_of_steps(), final_result=history.final_result() if history.is_successful() else f"Task failed: {history.errors()}", - ) - + ) + if __name__ == "__main__": - opea_microservices["opea_service@browser_use_agent"].start() \ No newline at end of file + opea_microservices["opea_service@browser_use_agent"].start() diff --git a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md index 14eee4c1f1..79262313df 100644 --- a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md +++ b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md @@ -4,7 +4,6 @@ This example covers the single-node on-premises deployment of the BrowserUseAgen **Note** This example requires access to a properly installed Intel® Gaudi® platform with a functional Docker service configured to use the habanalabs-container-runtime. Please consult the [Intel® Gaudi® software Installation Guide](https://docs.habana.ai/en/v1.20.1/Installation_Guide/Driver_Installation.html) for more information. - ## Quick Start Deployment This section describes how to quickly deploy and test the BrowserUseAgent service manually on an Intel® Gaudi® platform. The basic steps are: @@ -17,7 +16,6 @@ This section describes how to quickly deploy and test the BrowserUseAgent servic 6. [Test the Pipeline](#test-the-pipeline) 7. [Cleanup the Deployment](#cleanup-the-deployment) - ### Access the Code Clone the GenAIExample repository and access the BrowserUseAgent Intel® Gaudi® platform Docker Compose files and supporting scripts: @@ -33,12 +31,10 @@ Checkout a released version, such as v1.5: git checkout v1.5 ``` - ### Generate a HuggingFace Access Token Some HuggingFace resources, such as some models, are only accessible if you have an access token. If you do not already have a HuggingFace access token, you can create one by first creating an account by following the steps provided at [HuggingFace](https://huggingface.co/) and then generating a [user access token](https://huggingface.co/docs/transformers.js/en/guides/private#step-1-generating-a-user-access-token). - ### Configure the Deployment Environment To set up environment variables for deploying BrowserUseAgent services, source the _setup_env.sh_ script in this directory: @@ -47,8 +43,7 @@ To set up environment variables for deploying BrowserUseAgent services, source t source ./set_env.sh ``` -The _set_env.sh_ script will prompt for required and optional environment variables used to configure the ChatQnA services. If a value is not entered, the script will use a default value for the same. Users need to check if the values fit your deployment environment. - +The _set_env.sh_ script will prompt for required and optional environment variables used to configure the ChatQnA services. If a value is not entered, the script will use a default value for the same. Users need to check if the values fit your deployment environment. ### Deploy the Services Using Docker Compose @@ -60,7 +55,6 @@ docker compose up -d The BrowserUseAgent docker images should automatically be downloaded from the `OPEA registry` and deployed on the Intel® Gaudi® Platform. - ### Check the Deployment Status After running docker compose, check if all the containers launched via docker compose have started: @@ -86,11 +80,10 @@ Once the BrowserUseAgent services are running, test the pipeline using the follo ```bash curl -X POST http://${host_ip}:${BROWSER_USE_AGENT_PORT}/v1/browser_use_agent \ -H "Content-Type: application/json" \ - -d '{"task_prompt": "Nagivate to http://10.7.4.57:8083/admin and login with the credentials: username: admin, password: admin1234. Then, find out What are the top-2 best-selling product in 2022?"}' + -d '{"task_prompt": "Navigate to http://10.7.4.57:8083/admin and login with the credentials: username: admin, password: admin1234. Then, find out What are the top-2 best-selling product in 2022?"}' ``` -* Note that Update the `task_prompt` to match the evaluation question relevant to your configured website. - +- Note that Update the `task_prompt` to match the evaluation question relevant to your configured website. ### Cleanup the Deployment @@ -98,4 +91,4 @@ To stop the containers associated with the deployment, execute the following com ```bash docker compose -f compose.yaml down -``` \ No newline at end of file +``` diff --git a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/compose.yaml b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/compose.yaml index 42c2bc546b..720916b4f3 100644 --- a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/compose.yaml +++ b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/compose.yaml @@ -47,4 +47,4 @@ services: <<: *common-env LLM_ENDPOINT: ${LLM_ENDPOINT-http://0.0.0.0:8008} LLM_MODEL: ${LLM_MODEL_ID-Qwen/Qwen2-VL-72B-Instruct} - ipc: host \ No newline at end of file + ipc: host diff --git a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/set_env.sh b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/set_env.sh index b6a36a5eef..b11bbf903d 100644 --- a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/set_env.sh +++ b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/set_env.sh @@ -35,4 +35,4 @@ export LLM_ENDPOINT="http://${ip_address}:${LLM_ENDPOINT_PORT}" export DATA_PATH="${DATA_PATH-"./data"}" export LLM_MODEL_ID="${LLM_MODEL_ID-"Qwen/Qwen2.5-VL-32B-Instruct"}" export MAX_TOTAL_TOKENS="${MAX_TOTAL_TOKENS-12288}" -export NUM_CARDS="${NUM_CARDS-4}" \ No newline at end of file +export NUM_CARDS="${NUM_CARDS-4}" diff --git a/BrowserUseAgent/docker_image_build/build.yaml b/BrowserUseAgent/docker_image_build/build.yaml index 723c29064d..6f39d9577f 100644 --- a/BrowserUseAgent/docker_image_build/build.yaml +++ b/BrowserUseAgent/docker_image_build/build.yaml @@ -19,4 +19,4 @@ services: context: vllm-fork dockerfile: ./docker/Dockerfile.hpu extends: browser-use-agent - image: ${REGISTRY:-opea}/vllm-gaudi:${TAG:-latest} \ No newline at end of file + image: ${REGISTRY:-opea}/vllm-gaudi:${TAG:-latest} diff --git a/BrowserUseAgent/tests/test_compose_on_gaudi.sh b/BrowserUseAgent/tests/test_compose_on_gaudi.sh index 7814264634..cbf4c79e57 100644 --- a/BrowserUseAgent/tests/test_compose_on_gaudi.sh +++ b/BrowserUseAgent/tests/test_compose_on_gaudi.sh @@ -107,7 +107,7 @@ function validate_megaservice() { "\"is_success\":true" \ "browser-use-agent" \ "browser-use-agent-server" \ - '{"task_prompt": "Nagivate to http://10.7.4.57:8084/admin and login with the credentials: username: admin, password: admin1234. Then, find out What are the top-3 best-selling product in 2022?"}' + '{"task_prompt": "Navigate to http://10.7.4.57:8084/admin and login with the credentials: username: admin, password: admin1234. Then, find out What are the top-3 best-selling product in 2022?"}' } function stop_docker() { diff --git a/BrowserUseAgent/tests/webarena/README.md b/BrowserUseAgent/tests/webarena/README.md index af770a4807..12be9ebade 100644 --- a/BrowserUseAgent/tests/webarena/README.md +++ b/BrowserUseAgent/tests/webarena/README.md @@ -2,21 +2,22 @@ We will launch a shopping admin website, part of [WebArena](https://github.com/web-arena-x/webarena), to serve as a web server for agent evaluation. The deployment process will follow the instructions in the [webarena-setup](https://github.com/gasse/webarena-setup) repository. - ## Download Docker Image 1. Download shopping_admin_final_0719.tar from the [official webarena repo](https://github.com/web-arena-x/webarena/tree/main/environment_docker). 2. Place the archive file, shopping_admin_final_0719.tar, into the directory specified by the `ARCHIVES_LOCATION` parameter within `tests/webarena/set_env.sh` - ## Launch the Web Site + Please ensure Docker services work in your environment, and perform the following command to launch the web site: + ```bash bash shopping_admin.sh start ``` ## Stop the Web Site -``` bash + +```bash bash shopping_admin.sh stop -``` \ No newline at end of file +``` diff --git a/BrowserUseAgent/tests/webarena/set_env.sh b/BrowserUseAgent/tests/webarena/set_env.sh index 7e81f40a57..a212913961 100644 --- a/BrowserUseAgent/tests/webarena/set_env.sh +++ b/BrowserUseAgent/tests/webarena/set_env.sh @@ -8,4 +8,4 @@ SHOPPING_ADMIN_USER=admin SHOPPING_ADMIN_PASSWORD=admin1234 SHOPPING_ADMIN_PORT=8084 SHOPPING_ADMIN_URL="http://${PUBLIC_HOSTNAME}:${SHOPPING_ADMIN_PORT}/admin" -ARCHIVES_LOCATION="/data2/hf_model" \ No newline at end of file +ARCHIVES_LOCATION="/data2/hf_model" diff --git a/BrowserUseAgent/tests/webarena/shopping_admin.sh b/BrowserUseAgent/tests/webarena/shopping_admin.sh index b3e3c4fc04..3659d754c0 100644 --- a/BrowserUseAgent/tests/webarena/shopping_admin.sh +++ b/BrowserUseAgent/tests/webarena/shopping_admin.sh @@ -80,4 +80,4 @@ case "$1" in echo "Usage: $0 {start|stop|restart}" exit 1 ;; -esac \ No newline at end of file +esac From 8436b7e889f710a1414a69e1b84ed40122e98b7a Mon Sep 17 00:00:00 2001 From: Joshua Yao Date: Sat, 18 Oct 2025 09:53:44 +0000 Subject: [PATCH 4/9] Add all supported models Signed-off-by: Joshua Yao --- BrowserUseAgent/README.md | 3 +- .../tests/test_compose_on_gaudi.sh | 34 +++++++++---------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/BrowserUseAgent/README.md b/BrowserUseAgent/README.md index 5375bf9406..faa7075af9 100644 --- a/BrowserUseAgent/README.md +++ b/BrowserUseAgent/README.md @@ -14,4 +14,5 @@ The table below lists currently available deployment options. They outline in de | **Deploy Method** | **LLM Engine** | **LLM Model** | **Hardware** | | ----------------- | -------------- | -------------------------------------- | ------------ | -| Docker Compose | vLLM | meta-llama/Meta-Llama-3.3-70B-Instruct | Intel Gaudi | \ No newline at end of file +| Docker Compose | vLLM | Qwen/Qwen2.5-VL-32B-Instruct | Intel Gaudi | +| Docker Compose | vLLM | Qwen/Qwen2.5-VL-72B-Instruct | Intel Gaudi | \ No newline at end of file diff --git a/BrowserUseAgent/tests/test_compose_on_gaudi.sh b/BrowserUseAgent/tests/test_compose_on_gaudi.sh index 0b080ec66f..7814264634 100644 --- a/BrowserUseAgent/tests/test_compose_on_gaudi.sh +++ b/BrowserUseAgent/tests/test_compose_on_gaudi.sh @@ -120,32 +120,32 @@ function stop_docker() { function main() { - # echo "::group::stop_docker" - # stop_docker - # echo "::endgroup::" + echo "::group::stop_docker" + stop_docker + echo "::endgroup::" - # echo "::group::build_docker_images" - # if [[ "$IMAGE_REPO" == "opea" ]]; then build_docker_images; fi - # echo "::endgroup::" + echo "::group::build_docker_images" + if [[ "$IMAGE_REPO" == "opea" ]]; then build_docker_images; fi + echo "::endgroup::" - # echo "::group::start_services" - # start_services - # sleep 30 - # echo "::endgroup::" + echo "::group::start_services" + start_services + sleep 30 + echo "::endgroup::" - # echo "::group::validate_microservices" - # validate_microservices - # echo "::endgroup::" + echo "::group::validate_microservices" + validate_microservices + echo "::endgroup::" echo "::group::validate_megaservice" validate_megaservice echo "::endgroup::" - # echo "::group::stop_docker" - # stop_docker - # echo "::endgroup::" + echo "::group::stop_docker" + stop_docker + echo "::endgroup::" - # docker system prune -f + docker system prune -f } From 2cc92f81d92e67be451485c6d54fd508c9c0e6da Mon Sep 17 00:00:00 2001 From: Joshua Yao Date: Sat, 18 Oct 2025 15:13:43 +0000 Subject: [PATCH 5/9] Fix CI Failures Signed-off-by: Joshua Yao --- BrowserUseAgent/Dockerfile | 2 -- BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md | 2 +- BrowserUseAgent/tests/test_compose_on_gaudi.sh | 2 +- BrowserUseAgent/tests/webarena/shopping_admin.sh | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/BrowserUseAgent/Dockerfile b/BrowserUseAgent/Dockerfile index f930359549..ad7b3377db 100644 --- a/BrowserUseAgent/Dockerfile +++ b/BrowserUseAgent/Dockerfile @@ -7,8 +7,6 @@ FROM $IMAGE_REPO/comps-base:$BASE_TAG USER root -RUN apt update && apt install vim curl -y - COPY ./requirements.txt $HOME/requirements.txt COPY ./browser_use_agent.py $HOME/browser_use_agent.py diff --git a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md index 14eee4c1f1..fc1c08e26a 100644 --- a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md +++ b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md @@ -47,7 +47,7 @@ To set up environment variables for deploying BrowserUseAgent services, source t source ./set_env.sh ``` -The _set_env.sh_ script will prompt for required and optional environment variables used to configure the ChatQnA services. If a value is not entered, the script will use a default value for the same. Users need to check if the values fit your deployment environment. +The _set_env.sh_ script will prompt for required and optional environment variables used to configure the BrowserUseAgent services. If a value is not entered, the script will use a default value for the same. Users need to check if the values fit your deployment environment. ### Deploy the Services Using Docker Compose diff --git a/BrowserUseAgent/tests/test_compose_on_gaudi.sh b/BrowserUseAgent/tests/test_compose_on_gaudi.sh index 7814264634..2159b7a665 100644 --- a/BrowserUseAgent/tests/test_compose_on_gaudi.sh +++ b/BrowserUseAgent/tests/test_compose_on_gaudi.sh @@ -107,7 +107,7 @@ function validate_megaservice() { "\"is_success\":true" \ "browser-use-agent" \ "browser-use-agent-server" \ - '{"task_prompt": "Nagivate to http://10.7.4.57:8084/admin and login with the credentials: username: admin, password: admin1234. Then, find out What are the top-3 best-selling product in 2022?"}' + '{"task_prompt": "Navigate to http://'${ip_address}':8084/admin and login with the credentials: username: admin, password: admin1234. Then, find out What are the top-3 best-selling product in 2022?"}' } function stop_docker() { diff --git a/BrowserUseAgent/tests/webarena/shopping_admin.sh b/BrowserUseAgent/tests/webarena/shopping_admin.sh index b3e3c4fc04..cd24359a4c 100644 --- a/BrowserUseAgent/tests/webarena/shopping_admin.sh +++ b/BrowserUseAgent/tests/webarena/shopping_admin.sh @@ -11,7 +11,7 @@ source ${BASE_DIR}/set_env.sh assert() { if ! "$@"; then - echo "Assertion failed: $@" >&2 + echo "Assertion failed: $*" >&2 exit 1 fi } From 17dc98b9094108bb1b8f86fed343748b1eb47be8 Mon Sep 17 00:00:00 2001 From: Joshua Yao Date: Sat, 18 Oct 2025 15:23:45 +0000 Subject: [PATCH 6/9] Fix Readme Signed-off-by: Joshua Yao --- BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md index 79262313df..c27ea4544e 100644 --- a/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md +++ b/BrowserUseAgent/docker_compose/intel/hpu/gaudi/README.md @@ -43,7 +43,7 @@ To set up environment variables for deploying BrowserUseAgent services, source t source ./set_env.sh ``` -The _set_env.sh_ script will prompt for required and optional environment variables used to configure the ChatQnA services. If a value is not entered, the script will use a default value for the same. Users need to check if the values fit your deployment environment. +The _set_env.sh_ script will prompt for required and optional environment variables used to configure the BrowserUseAgent services. If a value is not entered, the script will use a default value for the same. Users need to check if the values fit your deployment environment. ### Deploy the Services Using Docker Compose From 005b58c26eb74b41dee04c13732860e3d30573db Mon Sep 17 00:00:00 2001 From: Joshua Yao Date: Sat, 18 Oct 2025 15:33:16 +0000 Subject: [PATCH 7/9] Fix shellcheck warnings Signed-off-by: Joshua Yao --- DeepResearchAgent/docker_compose/intel/hpu/gaudi/set_env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DeepResearchAgent/docker_compose/intel/hpu/gaudi/set_env.sh b/DeepResearchAgent/docker_compose/intel/hpu/gaudi/set_env.sh index e38d0ef378..9df0330f46 100644 --- a/DeepResearchAgent/docker_compose/intel/hpu/gaudi/set_env.sh +++ b/DeepResearchAgent/docker_compose/intel/hpu/gaudi/set_env.sh @@ -4,7 +4,7 @@ # SPDX-License-Identifier: Apache-2.0 # Navigate to the parent directory and source the environment -SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" pushd "$SCRIPT_DIR/../../../../../" > /dev/null source .set_env.sh From fc093387beeccc84635ff88934823beecf09a533 Mon Sep 17 00:00:00 2001 From: Joshua Yao Date: Mon, 20 Oct 2025 01:15:21 +0000 Subject: [PATCH 8/9] Fix shellcheck issues Signed-off-by: Joshua Yao --- BrowserUseAgent/tests/webarena/set_env.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BrowserUseAgent/tests/webarena/set_env.sh b/BrowserUseAgent/tests/webarena/set_env.sh index a212913961..2a05d1ab9e 100644 --- a/BrowserUseAgent/tests/webarena/set_env.sh +++ b/BrowserUseAgent/tests/webarena/set_env.sh @@ -2,10 +2,10 @@ # Copyright (C) 2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -WORKING_DIR=$(pwd) -PUBLIC_HOSTNAME=$(hostname -I | awk '{print $1}') -SHOPPING_ADMIN_USER=admin -SHOPPING_ADMIN_PASSWORD=admin1234 +WORKING_DIR="$(pwd)" +PUBLIC_HOSTNAME="$(hostname -I | awk '{print $1}')" +SHOPPING_ADMIN_USER="admin" +SHOPPING_ADMIN_PASSWORD="admin1234" SHOPPING_ADMIN_PORT=8084 SHOPPING_ADMIN_URL="http://${PUBLIC_HOSTNAME}:${SHOPPING_ADMIN_PORT}/admin" -ARCHIVES_LOCATION="/data2/hf_model" +ARCHIVES_LOCATION="/data2/hf_model" \ No newline at end of file From afb9f187d9f6c0c53b5d3e9a09acbb020fc01132 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 Oct 2025 01:08:17 +0000 Subject: [PATCH 9/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- BrowserUseAgent/tests/webarena/set_env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BrowserUseAgent/tests/webarena/set_env.sh b/BrowserUseAgent/tests/webarena/set_env.sh index 2a05d1ab9e..0acd826453 100644 --- a/BrowserUseAgent/tests/webarena/set_env.sh +++ b/BrowserUseAgent/tests/webarena/set_env.sh @@ -8,4 +8,4 @@ SHOPPING_ADMIN_USER="admin" SHOPPING_ADMIN_PASSWORD="admin1234" SHOPPING_ADMIN_PORT=8084 SHOPPING_ADMIN_URL="http://${PUBLIC_HOSTNAME}:${SHOPPING_ADMIN_PORT}/admin" -ARCHIVES_LOCATION="/data2/hf_model" \ No newline at end of file +ARCHIVES_LOCATION="/data2/hf_model"