Repository
ChangeRepository
¶
Bases: ChangeRepositoryProtocol
Repository for managing Change requests logic.
get_change_request_data(project_id, change_id)
¶
Retrieves the change request data for a given project and change ID.
This method interacts with the Git server to fetch the diffs associated with a specific merge request. If the Git server is not configured, or no diffs are found, appropriate runtime errors are raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_id
|
int | str
|
The identifier of the project. This can be an integer or string representing the project. |
required |
change_id
|
int
|
The unique identifier for the specific change request or merge request. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Change |
Change
|
An instance of the |
Raises:
| Type | Description |
|---|---|
RARepositoryError
|
If the Git server is not configured, |
ChangeRepositoryProtocol
¶
Bases: Protocol
Protocol for managing Change requests logic.
get_change_request_data(project_id, change_id)
¶
Fetches detailed information about a specific change request.
This method retrieves the data for a change request identified by its change_id in the context of a project specified by project_id. It is expected to be implemented by subclasses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_id
|
int | str
|
int | str The unique identifier of the project containing the change request. It can be an integer or string representation of the project ID. |
required |
change_id
|
int
|
int The unique identifier of the change request for the specified project. |
required |
Returns:
| Type | Description |
|---|---|
Change
|
Change Returns an instance of the Change class containing detailed information about the change request if available. |
ConfigRepository
¶
Handles configuration management logic.
This class provides static methods to locate a configuration file, validate its permissions and data content, and read its contents into a configuration object. It can operate using default directories, environment variables, or a custom path provided by the user. The class also allows for creating a default configuration if none exists or the existing configuration data is invalid.
The main entry point for this class is the load method, which
returns a Configuration object based on the provided configuration file path.
create_default_config()
staticmethod
¶
Create the default config at the default location, return its configuration.
Returns:
| Name | Type | Description |
|---|---|---|
Configuration |
Configuration
|
An instance of the Configuration class with default data |
load(config_file_path=None)
staticmethod
¶
Loads a configuration from a file or creates a default one if none is found.
This method handles retrieving a configuration file, validating its correctness, and returning a Configuration instance. If no configuration file exists, it creates a default configuration file and returns the respective Configuration instance. In case of parsing errors or invalid configuration data, exceptions are raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_file_path
|
str | None
|
Optional path to the configuration file. If not provided, a default configuration location will be used. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Configuration |
Configuration
|
An instance of the Configuration class containing |
Configuration
|
the loaded or default data. |
Raises:
| Type | Description |
|---|---|
RARepositoryError
|
Raised when there is an error parsing the configuration file or the configuration data is invalid. |
read_and_validate(config_location)
staticmethod
¶
Reads and validates a configuration file from the provided location.
This method reads a configuration file and validates its contents against specific requirements. If the reading or validation fails, appropriate errors are raised. Once the configuration file is successfully read and validated, it returns the parsed configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_location
|
str
|
The path to the configuration file to be loaded. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ConfigParser |
ConfigParser
|
A configuration parser instance containing the parsed and |
ConfigParser
|
validated configuration data. |
Raises:
| Type | Description |
|---|---|
RAConfigError
|
If an error occurs while reading the configuration file. or if the configuration data is invalid (schema validation fails). |
resolve_config_location(custom_path=None)
staticmethod
¶
Resolves the configuration file location based on a given custom path.
This method checks for a configuration file in the following order:
1. If custom_path is provided and exists, it is returned as the config path.
2. If no custom path or test mode path is found, the method iterates through
the default configuration directories, searching for the configuration file.
Returns None if no configuration file is found.
custom_path: str | None A custom path to the configuration file. If None, fallback methods are used to resolve the configuration file location.
str | None The resolved path to the configuration file, or None if no configuration file is found.
IntelligenceRepository
¶
Repository for managing AI intelligence.
instruct_model(chat)
¶
Handles LLM interaction to generate a response based on a given ChatSession.
Attributes: llm_provider (LLMProvider): The language model provider used to process the chat session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat
|
ChatSession
|
A chat session for user input and related context. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
LLMResponse |
LLMResponse
|
An object containing the generated response from the LLM. |
Raises:
| Type | Description |
|---|---|
RARepositoryError
|
If the language model type provided is unsupported. |
load_instructions()
¶
Loads instructions into a new ChatSession instance based on the LLM provider.
The method checks the type of the LLM provider and initialises a chat context accordingly. If the LLM provider type is unsupported, a ValueError is raised.
Raises:
| Type | Description |
|---|---|
RARepositoryError
|
If the type of LLM provider is unsupported. |
Returns:
| Name | Type | Description |
|---|---|---|
ChatSession |
ChatSession
|
A new chat session initialised with the provided prompt data. |
ProjectRepository
¶
Bases: ProjectRepositoryProtocol
Repository for interacting with GitLab projects.
ProjectRepositoryProtocol
¶
Bases: Protocol
Protocol for interacting with a git server.
get_project_data(project_id)
¶
Retrieve data on the git server for the specified project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_id
|
int | str
|
The GitLab project ID (int or str) |
required |
Returns:
| Type | Description |
|---|---|
Project | None
|
Project or None: immutable data class containing project details |
Raises:
| Type | Description |
|---|---|
RAGitServerError
|
If API request fails |
ReviewRepository
¶
Bases: ReviewRepositoryProtocol
Repository for interacting with GitLab merge request discussions.
publish_review_comment(project_id, change_id, content)
¶
Publishes a review comment on a given merge request.
This method interacts with the Git server to publish a comment on the specified merge request discussion thread. It constructs the payload with the provided content and sends a POST request to the server API. The method requires the Git server to be properly configured before making the API call.
Raises¶
RARepositoryError If the Git server is not configured.
Parameters¶
project_id : int | str The unique identifier of the project where the merge request exists. change_id : int The unique identifier of the merge request to which the comment is related. content : Any The content of the comment to be published.
Returns¶
Any The response returned by the Git server after the comment is published.
ReviewRepositoryProtocol
¶
Bases: Protocol
Protocol for managing review comments.
publish_review_comment(project_id, change_id, content)
¶
Publishes a review comment for a specific change within a project.
This method is responsible for submitting a review comment to a defined change in a project. Subclasses are required to implement the functionality for handling the publication of the comment.
project_id: int | str The identifier of the project to which the review belongs. This can be an integer or a string.
int
The identifier of the change (review item) within the project for which the comment is being published.
Any
The content of the comment to be published. The specific type and structure depend on the implementation details in the subclass.
Any The result of the operation, as determined by the subclass implementation. This could include details of the published comment or a confirmation of success.
NotImplementedError If the method is not implemented by the subclass.