> ## 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.agents.repo agent

<a id="camel.agents.repo_agent" />

<a id="camel.agents.repo_agent.GitHubFile" />

## GitHubFile

```python theme={"system"}
class GitHubFile(BaseModel):
```

Model to hold GitHub file information.

**Parameters:**

* **content** (str): The content of the GitHub text.
* **file\_path** (str): The path of the file.
* **html\_url** (str): The actual url of the file.

<a id="camel.agents.repo_agent.RepositoryInfo" />

## RepositoryInfo

```python theme={"system"}
class RepositoryInfo(BaseModel):
```

Model to hold GitHub repository information.

**Parameters:**

* **repo\_name** (str): The full name of the repository.
* **repo\_url** (str): The URL of the repository.
* **contents** (list): A list to hold the repository contents.

<a id="camel.agents.repo_agent.RepoAgent" />

## RepoAgent

```python theme={"system"}
class RepoAgent(ChatAgent):
```

A specialized agent designed to interact with GitHub repositories for
code generation tasks.
The RepoAgent enhances a base ChatAgent by integrating context from
one or more GitHub repositories. It supports two processing modes:

* FULL\_CONTEXT: loads and injects full repository content into the
  prompt.
* RAG (Retrieval-Augmented Generation): retrieves relevant
  code/documentation chunks using a vector store when context
  length exceeds a specified token limit.

**Parameters:**

* **vector\_retriever** (VectorRetriever): Retriever used to perform semantic search in RAG mode. Required if repo content exceeds context limit.
* **system\_message** (Optional\[str]): The system message for the chat agent. (default: :str:`"You are a code assistant with repo context."`)
* **repo\_paths** (Optional\[List\[str]]): List of GitHub repository URLs to load during initialization. (default: :obj:`None`)
* **model** (BaseModelBackend): The model backend to use for generating responses. (default: :obj:`ModelPlatformType.DEFAULT` with `ModelType.DEFAULT`)
* **max\_context\_tokens** (Optional\[int]): Maximum number of tokens allowed before switching to RAG mode. (default: :obj:`2000`)
* **github\_auth\_token** (Optional\[str]): GitHub personal access token for accessing private or rate-limited repositories. (default: :obj:`None`)
* **chunk\_size** (Optional\[int]): Maximum number of characters per code chunk when indexing files for RAG. (default: :obj:`8192`)
* **top\_k** (int): Number of top-matching chunks to retrieve from the vector store in RAG mode. (default: :obj:`5`)
* **similarity** (Optional\[float]): Minimum similarity score required to include a chunk in the RAG context. (default: :obj:`0.6`)
* **collection\_name** (Optional\[str]): Name of the vector database collection to use for storing and retrieving chunks. (default: :obj:`None`) \*\*kwargs: Inherited from ChatAgent

**Note:**

The current implementation of RAG mode requires using Qdrant as the
vector storage backend. The VectorRetriever defaults to QdrantStorage
if no storage is explicitly provided. Other vector storage backends
are not currently supported for the RepoAgent's RAG functionality.

<a id="camel.agents.repo_agent.RepoAgent.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    vector_retriever: VectorRetriever,
    system_message: Optional[str] = 'You are a code assistant with repo context.',
    repo_paths: Optional[List[str]] = None,
    model: Optional[BaseModelBackend] = None,
    max_context_tokens: int = 2000,
    github_auth_token: Optional[str] = None,
    chunk_size: Optional[int] = 8192,
    top_k: Optional[int] = 5,
    similarity: Optional[float] = 0.6,
    collection_name: Optional[str] = None,
    **kwargs
):
```

<a id="camel.agents.repo_agent.RepoAgent.parse_url" />

### parse\_url

```python theme={"system"}
def parse_url(self, url: str):
```

Parse the GitHub URL and return the (owner, repo\_name) tuple.

**Parameters:**

* **url** (str): The URL to be parsed.

**Returns:**

Tuple\[str, str]: The (owner, repo\_name) tuple.

<a id="camel.agents.repo_agent.RepoAgent.load_repositories" />

### load\_repositories

```python theme={"system"}
def load_repositories(self, repo_urls: List[str]):
```

Load the content of a GitHub repository.

**Parameters:**

* **repo\_urls** (str): The list of Repo URLs.

**Returns:**

List\[RepositoryInfo]: A list of objects containing information
about the all repositories, including the contents.

<a id="camel.agents.repo_agent.RepoAgent.load_repository" />

### load\_repository

```python theme={"system"}
def load_repository(self, repo_url: str, github_client: 'Github'):
```

Load the content of a GitHub repository.

**Parameters:**

* **repo\_urls** (str): The Repo URL to be loaded.
* **github\_client** (GitHub): The established GitHub client.

**Returns:**

RepositoryInfo: The object containing information
about the repository, including the contents.

<a id="camel.agents.repo_agent.RepoAgent.count_tokens" />

### count\_tokens

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

**Returns:**

int: The number of tokens

<a id="camel.agents.repo_agent.RepoAgent.construct_full_text" />

### construct\_full\_text

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

Construct full context text from repositories by concatenation.

<a id="camel.agents.repo_agent.RepoAgent.add_repositories" />

### add\_repositories

```python theme={"system"}
def add_repositories(self, repo_urls: List[str]):
```

Add a GitHub repository to the list of repositories.

**Parameters:**

* **repo\_urls** (str): The Repo URL to be added.

<a id="camel.agents.repo_agent.RepoAgent.check_switch_mode" />

### check\_switch\_mode

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

**Returns:**

bool: True if the mode was switched, False otherwise.

<a id="camel.agents.repo_agent.RepoAgent.step" />

### step

```python theme={"system"}
def step(
    self,
    input_message: Union[BaseMessage, str],
    *args,
    **kwargs
):
```

Overrides `ChatAgent.step()` to first retrieve relevant context
from the vector store before passing the input to the language model.

<a id="camel.agents.repo_agent.RepoAgent.reset" />

### reset

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

<a id="camel.agents.repo_agent.RepoAgent.search_by_file_path" />

### search\_by\_file\_path

```python theme={"system"}
def search_by_file_path(self, file_path: str):
```

Search for all payloads in the vector database where
file\_path matches the given value (the same file),
then sort by piece\_num and concatenate text fields to return a
complete result.

**Parameters:**

* **file\_path** (str): The `file_path` value to filter the payloads.

**Returns:**

str: A concatenated string of the `text` fields sorted by
`piece_num`.
