> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Camel.benchmarks.apibench

<a id="camel.benchmarks.apibench" />

<a id="camel.benchmarks.apibench.encode_question" />

## encode\_question

```python theme={"system"}
def encode_question(question: str, dataset_name: str):
```

Encode multiple prompt instructions into a single string.

<a id="camel.benchmarks.apibench.APIBenchBenchmark" />

## APIBenchBenchmark

```python theme={"system"}
class APIBenchBenchmark(BaseBenchmark):
```

APIBench Benchmark adopted from `Gorilla: Large Language Model
Connected with Massive APIs`
`<https://huggingface.co/datasets/gorilla-llm/APIBench>`.

**Parameters:**

* **data\_dir** (str): The directory to save the data.
* **save\_to** (str): The file to save the results.
* **processes** (int, optional): The number of processes to use. (default: :obj:`1`)

<a id="camel.benchmarks.apibench.APIBenchBenchmark.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    data_dir: str,
    save_to: str,
    processes: int = 1
):
```

Initialize the APIBench benchmark.

**Parameters:**

* **data\_dir** (str): The directory to save the data.
* **save\_to** (str): The file to save the results.
* **processes** (int, optional): The number of processes to use for parallel processing. (default: :obj:`1`)

<a id="camel.benchmarks.apibench.APIBenchBenchmark.download" />

### download

```python theme={"system"}
def download(self):
```

Download the APIBench dataset.

<a id="camel.benchmarks.apibench.APIBenchBenchmark.load" />

### load

```python theme={"system"}
def load(self, dataset_name: str, force_download: bool = False):
```

Load the APIBench Benchmark dataset.

**Parameters:**

* **dataset\_name** (str): Name of the specific dataset to be loaded.
* **force\_download** (bool, optional): Whether to force download the data. (default: :obj:`False`)

<a id="camel.benchmarks.apibench.APIBenchBenchmark.run" />

### run

```python theme={"system"}
def run(
    self,
    agent: ChatAgent,
    dataset_name: Literal['huggingface', 'tensorflowhub', 'torchhub'],
    randomize: bool = False,
    subset: Optional[int] = None
):
```

Run the benchmark.

**Parameters:**

* **agent** (ChatAgent): The agent to run the benchmark. dataset\_name (Literal\["huggingface", "tensorflowhub", "torchhub"]): The dataset to run the benchmark.
* **randomize** (bool, optional): Whether to randomize the data. (default: :obj:`False`)
* **subset** (Optional\[int], optional): The subset of data to run. (default: :obj:`None`)

<a id="camel.benchmarks.apibench.get_all_sub_trees" />

## get\_all\_sub\_trees

```python theme={"system"}
def get_all_sub_trees(root_node):
```

<a id="camel.benchmarks.apibench.ast_parse" />

## ast\_parse

```python theme={"system"}
def ast_parse(candidate):
```

<a id="camel.benchmarks.apibench.get_args" />

## get\_args

```python theme={"system"}
def get_args(node, dataset_name):
```

<a id="camel.benchmarks.apibench.ast_check" />

## ast\_check

```python theme={"system"}
def ast_check(candidate_subtree_list, base_tree_list, dataset_name):
```

<a id="camel.benchmarks.apibench.evaluate_response" />

## evaluate\_response

```python theme={"system"}
def evaluate_response(
    response,
    question_id,
    dataset_name,
    api_database,
    qa_pairs,
    ast_database
):
```
