# JungleGym AI Overview

JungleGym is an open-source playground for testing, analyzing, benchmarking, and developing autonomous web agents. You can download the Agent demonstration data to train your own LLM (GPT-4, LLaMA2, Mistral, etc) and/or you can use them to test your Agents.&#x20;

You can see these in action in [JungleGym.ai](https://www.junglegym.ai/)

JungleGym provides three APIs for building your agents:&#x20;

1. Mind2Web Dataset API (paper [here](https://arxiv.org/abs/2306.06070)).
2. WebArena Dataset API (paper [here](https://arxiv.org/pdf/2307.13854.pdf)).
3. TreeVoyager API.&#x20;

In addition to these three APIs, JungleGym has six fully functional web-emulated sites, created and mirrored from WebArena. These sites span six categories:

1. Online store (link [here](http://shop.junglegym.ai/)).
2. GitLab (link [here](http://git.junglegym.ai)).
3. Social forum (link [here](http://forum.junglegym.ai)).
4. Wikipedia (link [here](http://wiki.junglegym.ai)).
5. E-commerce CMS (link [here](http://cms.junglegym.ai/)).
6. Map (link [here](http://ec2-3-131-244-37.us-east-2.compute.amazonaws.com:3000/#map=7/42.896/-75.108)).


# API Documentation:


# Mind2Web API

## Mind2Web Description

Mind2Web is a dataset for developing and evaluating generalist agents for the web that can follow language instructions to complete complex tasks on websites. The Mind2Web paper can be found [here](https://arxiv.org/abs/2306.06070).

Note that this API only contains the Mind2Web Training data. We do not include the Test data to avoid data contamination with data crawlers for training LLMs.

## Mind2Web API Documentation

### Introduction

This API serves the Mind2Web engine which provides endpoints to access partial and full datasets.

* **Version**: 0.0.9 (Experimental)
* **Status**: Development
* **Rate Limit**: 500 requests per minute.

**Root Endpoint**: [`https://api.junglegym.ai/`](https://api.junglegym.ai/)

### Endpoints

#### 1. Root Test Endpoint

* **URL**: [`https://api.junglegym.ai/`](https://api.junglegym.ai/)
* **Method**: `GET`
* **Rate Limit**: 500/minute.
* **Response**: A welcome message.

```json
jsonCopy code{
    "message": "Hello World from the JungleGym dataset server!"
}
```

#### 2. Load Light Train Dataset

* **URL**: `/load_light_train_dataset`
* **Method**: `GET`
* **Rate Limit**: 500/minute.
* **Response**: Returns light training dataset.

```json
jsonCopy code{
    "data": [...]
}
```

#### 3. Load Full Train Dataset

* **URL**: `/load_full_train_dataset`
* **Method**: `GET`
* **Rate Limit**: 500/minute.
* **Response**: Returns full training dataset.

```json
jsonCopy code{
    "data": [...]
}
```

#### 4. Get List of Actions

* **URL**: `/get_list_of_actions?annotation_id=<annotation_id>`
* **Method**: `GET`
* **Rate Limit**: 500/minute.
* **Response**: Returns actions and their representations for a given annotation ID.

```json
jsonCopy code{
    "actions": [...],
    "action_reprs": [...]
}
```

#### 5. Get Raw JSON Screenshots

* **URL**: `/get_raw_json_screenshots?annotation_id=<annotation_id>`
* **Method**: `GET`
* **Rate Limit**: 500/minute.
* **Response**: Returns raw JSON screenshots for a given annotation ID.

```json
jsonCopy code{
    "data": {...}
}
```

#### 6. Get Raw DOM Content

* **URL**: `/get_raw_dom_content?annotation_id=<annotation_id>`
* **Method**: `GET`
* **Rate Limit**: 500/minute.
* **Response**: Returns raw DOM content for a given annotation ID.

```json
jsonCopy code{
    "data": {...}
}
```

#### 7. Get Storage

* **URL**: `/get_storage?annotation_id=<annotation_id>`
* **Method**: `GET`
* **Rate Limit**: 500/minute.
* **Response**: Returns storage data for a given annotation ID.

```json
jsonCopy code{
    "data": {...}
}
```

#### 8. Get Raw Trace Zip

* **URL**: `/get_raw_trace_zip?annotation_id=<annotation_id>`
* **Method**: `GET`
* **Rate Limit**: 500/minute.
* **Response**: Returns a trace.zip file for the given annotation ID.

### Errors

The API will return specific HTTP status codes for different kinds of errors:

* `401 Unauthorized`: For forbidden or unauthorized access.
* `404 Not Found`: If the requested resource or data is not found.
* `500 Internal Server Error`: For any internal server issues.

Make sure to check the `detail` field in the response for a specific error message.


# Endpoints Description Summary

Mind2Web endpoints summary

* **Training dataset Endpoints**
  * `/load_light_train_dataset`: Loads a lightweight training dataset with a short sample of the dataset.
  * `/load_full_train_dataset`: Loads the complete training dataset (ideally to train your LLM or test your agent).
  * `/get_list_of_actions`: Retrieves a list of actions and action representations linked to a specific annotation.
* **Raw Dump Task Data Endpoints**
  * `/get_raw_json_screenshots`: Retrieves raw JSON screenshots for a specific annotation.
  * `/get_raw_dom_content`: Retrieves raw DOM content for a specific annotation.
  * `/get_storage`: Retrieves raw storage data for a specific annotation.
  * `/get_raw_trace_zip`: Retrieves a raw trace ZIP file for a specific annotation.


# WebArena API

## WebArena Description

WebArena provides a dataset of tasks with different fully functional emulated web environments for testing web agents. The tasks (intents) can be found in this API and the emulated web environments [here](https://www.junglegym.ai/Emulated%20Web%20Enviroments). The WebArena paper can be found [here](https://arxiv.org/abs/2307.13854).

## WebArena API Documentation

### Introduction

This API serves the WebArena dataset engine which provides endpoints to access partial and full datasets.

* **Version**: 0.0.9 (Experimental).
* **Status**: Development.
* **Rate Limit**: 500 requests per minute.
* **Root Endpoint**: `https://api.junglegym.ai/`

### WebArena Endpoints

#### 1. Get Full WebArena Dataset

* **URL**: `/get_full_webarena_dataset`
* **Method**: GET
* **Rate Limit**: 500/minute.
* **Response**: Returns full WebArena dataset.

```json
jsonCopy code{
    "data": [...]
}
```

#### 2. Get WebArena Tasks

* **URL**: `/get_webarena_tasks`
* **Method**: GET
* **Rate Limit**: 500/minute.
* **Response**: Returns WebArena tasks' intents and start URLs.

```json
jsonCopy code{
    "data": [...]
}
```

#### 3. Get WebArena by Task

* **URL**: `/get_webarena_by_task?task=<task>`
* **Method**: GET
* **Rate Limit**: 500/minute.
* **Response**: Returns data filtered by task.

```json
jsonCopy code{
    "data": [...]
}
```

#### 4. Get WebArena by Task ID

* **URL**: `/get_webarena_by_task_id?task_id=<task_id>`
* **Method**: GET
* **Rate Limit**: 500/minute.
* **Response**: Returns data filtered by task ID.

```json
jsonCopy code{
    "data": [...]
}
```

#### 5. Get WebArena by Domain

* **URL**: `/get_webarena_by_domain?domain=<domain>`
* **Method**: GET
* **Rate Limit**: 500/minute.
* **Response**: Returns data filtered by domain.

```json
jsonCopy code{
    "data": [...]
}
```

### Errors

* **401 Unauthorized**: Forbidden or unauthorized access.
* **404 Not Found**: Requested resource or data not found.
* **500 Internal Server Error**: Internal server issues.

Check the `detail` field in the response for a specific error message.


# Endpoints Description Summary

WebArena endpoints summary

* **/get\_full\_webarena\_dataset**: Retrieves the complete WebArena dataset.
* **/get\_webarena\_tasks**: Fetches tasks' intents and start URLs from the WebArena dataset.
* **/get\_webarena\_by\_task**: Returns data filtered by a specific task from the dataset.
* **/get\_webarena\_by\_task\_id**: Returns data filtered by a specific task ID from the WebArena dataset.
* **/get\_webarena\_by\_domain**: Returns data filtered by a specific domain from the WebArena dataset.

<br>


# AgentInstruct API

### AgentInstruct Description

AgentInstruct is a dataset that aims to improve LLMs’ generalized agent abilities. It was introduced with [AgentTuning](https://arxiv.org/abs/2310.12823): Enabling Generalized Agent Abilities for LLMs (A Zeng et al., 2023). The AgentInstruct dataset includes 1,866 trajectories from 6 agents' tasks. “Inst.” stands for instruction, the agent needs to interact with the environment to complete the task specified in the instruction, “Traj.” stands for interaction trajectory, “Filt. Traj.” stands for filtered trajectories. “Task Deri.” stands for Task Derivation.

To see the full dataset composition check its [JungleGym page](https://junglegym.ai/AgentInstruct%20Overview).

### AgentInstruct API Documentation

This API provides access to the full AgentInstruct dataset in its original format.

Version: 0.0.9 (Experimental) Status: Development Rate Limit: 500 requests per minute Root Endpoint: <https://api.junglegym.ai/>

#### Agent Instruction Endpoints

1. **Load Agent Instruction Dataset**
   * URL: `/load_agent_instruct`
   * Method: GET
   * Rate Limit: 500/minute.
   * Response: Returns the Agent Instruction dataset.
   * ```json
     jsonCopy code{
         "data": [...]
     }
     ```


# TreeVoyager API

## Introduction

TreeVoyager is a Python-based protocol designed to implement some principles from the papers '[Tree of Thoughts](https://arxiv.org/abs/2305.10601)' (ToT) and '[Minecraft's Voyager](https://voyager.minedojo.org/)' to parse, generate curriculum, select HTML IDs, generate paths, and create skills (memory) for the steps required in the agent trajectory.

We developed TreeVoyager to address the lack of a standardized protocol that allows AI agents to interact with the web. This is just one way of many to mitigate the problem. TreeVoyager aims to solve this issue while also incorporating proven concepts from other agent environments (such as Minecraft's Voyager).

This API serves the TreeVoyager API service, which provides endpoints for running tasks and sequences of actions in a web environment.

**TreeVoyager Functionality Diagram:**

<figure><img src="/files/LhgAWfuwUqTphBWu5Ccc" alt="" width="375"><figcaption></figcaption></figure>

**Inside TreeVoyager:**

<figure><img src="/files/gIgHJQnEs3rcp7SrrPzs" alt=""><figcaption><p>TreeVoyager's Diagram</p></figcaption></figure>

## **How to use this TreeVoyager API?**

You can use the `/run_step` endpoint, and pass the parameters of each step:

```python
task, page, curriculum, prev_code, step
```

If it's the first time you run the step, just pass the "task" and "page" (URL) parameters and TreeVoyager will know it's the first time/step to run and it will create the curriculum and code for the first step.&#x20;

For subsequent steps, pass the "task", "page" (if it's the same URL as the first step, pass it, or if your agent already submitted to a new page, pass the new URL), the "prev\_code" (previous code) generated in the previous step and the "step" (from the curriculum) you want to execute.&#x20;

Note that you can edit the "step", it doesn't need to be the exact one from the curriculum.

## Endpoints:

**Version**: 0.9.0\
**Status**: Development\
**Root Endpoint**: `https://treevoyager.junglegym.ai/`

### TreeVoyager Endpoints

#### 1. Health Check and Welcome Message

* **URL**: `/`
* **Method**: GET
* **Rate Limit**: 500 requests per minute
* **Response**: Returns a welcome message.

```json
jsonCopy code{
    "message": "Hello from TreeVoyager's server. Check the full api documentation at: https://docs.junglegym.ai"
}
```

#### 2. Run a Task Step-by-Step

* **URL**: `/run_step`
* **Method**: GET
* **Rate Limit**: 500 requests per minute
* **Parameters**:
  * `task` (the task you want to accomplish, "buy coffee", "rent a car", etc)
  * `page` (the URL of the page)
  * `curriculum` (leave blank the first time you run it, for subsequent steps, pass the curriculum generated in the first step)
  * `prev_code` (leave blank the first time you run it, for subsequent steps pass the code generated in the first or previous step)
  * `step` (step name from the curriculum; edit step if needed)
* **Response**: Streams a sequence of JSON objects with step-by-step task execution details.

```json
jsonCopy code{
    "task": "buy coffee",
    "curriculum": {...},
    "step_name": "Step 1...",
    ...
}
```


