AppAgentX Documentation

repository·main·Indexed 20 days ago

https://github.com/westlake-agi-lab/appagentx

An evolutionary framework for GUI agents designed for smartphone interaction. AppAgentX utilizes a memory mechanism to evolve repetitive action sequences into high-level shortcut actions. The system includes a Gradio-based demo and a containerized backend featuring an Image Feature Extraction Service (Port 8001) and a Screen Parsing Service based on OmniParser (Port 8000). It integrates with LangChain, LangGraph, Neo4j, Pinecone, and requires ADB for Android device connectivity.

Tokens
1.4K
Snippets
5
Records
10
Agent score
71%

What's inside AppAgentX

  1. Install AppAgentX dependencies

    main

    AppAgentX relies on LangChain and LangGraph for its agent framework. To install the required Python dependencies, use pip to install from the provided requirements.txt file.

    Note: You must also configure your LLM settings (such as OpenAI or DeepSeek) in the config.py file.

    pip install -r requirements.txt
  2. Set up ADB and Android devices

    main

    AppAgentX requires a connection to an Android device or emulator via ADB (Android Debug Bridge).

    Physical Device Setup

    1. Install ADB: Download and install the ADB command-line tool on your PC.
    2. Enable USB Debugging: On your Android device, go to Settings > Developer Options and enable USB Debugging.
    3. Connect: Connect the device to your PC using a USB cable.

    Emulator Setup (Optional)

    If you do not have a physical device, use the Android Studio emulator:

    1. Install Android Studio.
    2. Use the Device Manager to create and launch an emulator.
    3. Install apps by dragging APK files into the emulator window.
  3. Deploy Screen Recognition and Feature Extraction

    main

    Screen recognition and feature extraction services are containerized using Docker. This modular approach allows for easy replacement of parsing tools.

    To deploy these services:

    1. Navigate to the backend folder.
    2. Follow the specific instructions in the backend/README.md file.
    3. Note: This deployment may require Docker's GPU support. Ensure your Docker configuration is set up for GPU access if required.
  4. Deploy the Backend Services via Docker Compose

    main

    The backend consists of two containerized FastAPI services: the Image Feature Extraction Service (Port 8001) and the Screen Parsing Service (Port 8000).

    Prerequisites

    • Docker
    • Docker Compose
    • NVIDIA GPU support (requires NVIDIA Container Toolkit)

    Model Weights Preparation

    You must manually download model weights from OmniParser on Hugging Face and place them in the OmniParser/weights/ directory before starting, otherwise the API will fail to process images.

    Required structure:

    • OmniParser/weights/icon_detect_v1_5/best.pt (YOLO detection model)
    • OmniParser/weights/icon_caption_florence/ (Caption model files)

    Deployment Commands

    To build and start the services in the foreground:

    docker-compose up --build

    To run the services in the background:

    docker-compose up -d --build
  5. Configure LLM and Database settings

    main

    All core service configurations are managed via the config.py file. You must provide credentials and connection details for the following services:

    • LLM: Configure settings for your chosen model. DeepSeek can be used via an OpenAI-compatible API format by adjusting the configuration to use the OpenAI SDK.
    • Neo4j: Used as the memory storage for the agent (utilizing Cypher queries). Provide the necessary API keys and connection details.
    • Pinecone: Used for vector storage. Provide the necessary API keys and connection details.
  6. API Reference for Image Feature Extraction Service

    main

    The Image Feature Extraction Service runs on http://localhost:8001. Use the following endpoints to manage models and extract image features:

    MethodEndpointDescription
    GET/available_modelsGet list of available models
    POST/set_modelSet the model to use
    POST/extract_single/Extract features from a single image
    POST/extract_batch/Batch extract features from multiple images
    GET/model_infoGet current model information
    GET/benchmark/Run performance tests
  7. Manage and Shut Down Backend Services

    main

    Use the following Docker Compose commands to manage the lifecycle of the backend services:

    Check service status:

    docker-compose ps

    View logs:

    • View all logs: docker-compose logs
    • Follow logs for a specific service (e.g., omniparser): docker-compose logs -f omniparser

    Stop and remove services:

    • Standard stop (removes containers): docker-compose down
    • Stop services but keep containers: docker-compose stop
    • Stop and remove containers, networks, and volumes: docker-compose down -v
    • Stop and remove everything including images: docker-compose down --rmi all -v
    docker-compose down
  8. Reference the backend service ports and configurations

    main

    The following services are defined in the backend/docker-compose.yml file. Use these ports to communicate with the respective backend APIs.

    services:
      image-embedding:
        ports:
          - "8001:8001"
        deploy:
          resources:
            reservations:
              devices:
                - driver: nvidia
                  count: 1
                  capabilities: [ gpu ]
    
      omni-parser:
        ports:
          - "8000:8000"
        deploy:
          resources:
            reservations:
              devices:
                - driver: nvidia
                  count: 1
                  capabilities: [ gpu ]