> ## 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.toolkits.jina reranker toolkit

<a id="camel.toolkits.jina_reranker_toolkit" />

<a id="camel.toolkits.jina_reranker_toolkit.JinaRerankerToolkit" />

## JinaRerankerToolkit

```python theme={"system"}
class JinaRerankerToolkit(BaseToolkit):
```

A class representing a toolkit for reranking documents
using Jina Reranker.

This class provides methods for reranking documents (text or images)
based on their relevance to a given query using the Jina Reranker model.

<a id="camel.toolkits.jina_reranker_toolkit.JinaRerankerToolkit.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    timeout: Optional[float] = None,
    model_name: str = 'jinaai/jina-reranker-m0',
    device: Optional[str] = None,
    use_api: bool = True
):
```

Initializes a new instance of the JinaRerankerToolkit class.

**Parameters:**

* **timeout** (Optional\[float]): The timeout value for API requests in seconds. If None, no timeout is applied. (default: :obj:`None`)
* **model\_name** (str): The reranker model name. (default: :obj:`"jinaai/jina-reranker-m0"`)
* **device** (Optional\[str]): Device to load the model on. If None, will use CUDA if available, otherwise CPU. Only effective when use\_api=False. (default: :obj:`None`)
* **use\_api** (bool): A flag to switch between local model and API. (default: :obj:`True`)

<a id="camel.toolkits.jina_reranker_toolkit.JinaRerankerToolkit._sort_documents" />

### \_sort\_documents

```python theme={"system"}
def _sort_documents(self, documents: List[str], scores: List[float]):
```

Sort documents by their scores in descending order.

**Parameters:**

* **documents** (List\[str]): List of documents to sort.
* **scores** (List\[float]): Corresponding scores for each document.

**Returns:**

List\[Dict\[str, object]]: Sorted list of (document, score) pairs.

<a id="camel.toolkits.jina_reranker_toolkit.JinaRerankerToolkit._call_jina_api" />

### \_call\_jina\_api

```python theme={"system"}
def _call_jina_api(self, data: Dict[str, Any]):
```

Makes a call to the JINA API for reranking.

**Parameters:**

* **data** (Dict\[str]): The data to be passed into the api body.

**Returns:**

List\[Dict\[str, object]]: A list of dictionary containing
the reranked documents and their relevance scores.

<a id="camel.toolkits.jina_reranker_toolkit.JinaRerankerToolkit.rerank_text_documents" />

### rerank\_text\_documents

```python theme={"system"}
def rerank_text_documents(
    self,
    query: str,
    documents: List[str],
    max_length: int = 1024
):
```

Reranks text documents based on their relevance to a text query.

**Parameters:**

* **query** (str): The text query for reranking.
* **documents** (List\[str]): List of text documents to be reranked.
* **max\_length** (int): Maximum token length for processing. (default: :obj:`1024`)

**Returns:**

List\[Dict\[str, object]]: A list of dictionary containing
the reranked documents and their relevance scores.

<a id="camel.toolkits.jina_reranker_toolkit.JinaRerankerToolkit.rerank_image_documents" />

### rerank\_image\_documents

```python theme={"system"}
def rerank_image_documents(
    self,
    query: str,
    documents: List[str],
    max_length: int = 2048
):
```

Reranks image documents based on their relevance to a text query.

**Parameters:**

* **query** (str): The text query for reranking.
* **documents** (List\[str]): List of image URLs or paths to be reranked.
* **max\_length** (int): Maximum token length for processing. (default: :obj:`2048`)

**Returns:**

List\[Dict\[str, object]]: A list of dictionary containing
the reranked image URLs/paths and their relevance scores.

<a id="camel.toolkits.jina_reranker_toolkit.JinaRerankerToolkit.image_query_text_documents" />

### image\_query\_text\_documents

```python theme={"system"}
def image_query_text_documents(
    self,
    image_query: str,
    documents: List[str],
    max_length: int = 2048
):
```

Reranks text documents based on their relevance to an image query.

**Parameters:**

* **image\_query** (str): The image URL or path used as query.
* **documents** (List\[str]): List of text documents to be reranked.
* **max\_length** (int): Maximum token length for processing. (default: :obj:`2048`)

**Returns:**

List\[Dict\[str, object]]: A list of dictionary containing
the reranked documents and their relevance scores.

<a id="camel.toolkits.jina_reranker_toolkit.JinaRerankerToolkit.image_query_image_documents" />

### image\_query\_image\_documents

```python theme={"system"}
def image_query_image_documents(
    self,
    image_query: str,
    documents: List[str],
    max_length: int = 2048
):
```

Reranks image documents based on their relevance to an image query.

**Parameters:**

* **image\_query** (str): The image URL or path used as query.
* **documents** (List\[str]): List of image URLs or paths to be reranked.
* **max\_length** (int): Maximum token length for processing. (default: :obj:`2048`)

**Returns:**

List\[Dict\[str, object]]: A list of dictionary containing
the reranked image URLs/paths and their relevance scores.

<a id="camel.toolkits.jina_reranker_toolkit.JinaRerankerToolkit.get_tools" />

### get\_tools

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

**Returns:**

List\[FunctionTool]: A list of FunctionTool objects
representing the functions in the toolkit.
