review.bot.open_ai_interface
#
Functions to interface with OpenAI.
Module Contents#
Functions#
|
Review a patch in a pull request and generate suggestions for improvement. |
|
Reviews an specific file from the PR. The file must have been modified in the PR. |
|
Reviews an specific file from the PR. The file must have been modified in the PR. |
|
Review a patch in a pull request and generate suggestions for improvement. |
|
Generate the required message for each type of query request. |
|
Generate suggestions for a given file source and patch. |
Attributes#
- review.bot.open_ai_interface.LOG#
- review.bot.open_ai_interface.OPEN_AI_MODEL#
- review.bot.open_ai_interface.review_patch(owner: str, repo: str, pr: int, use_src: bool = False, filter_filename=None, gh_access_token: str = None, docs_only: bool = False, config_file: str = None) List[Dict] #
Review a patch in a pull request and generate suggestions for improvement.
- Parameters:
- owner
str
The GitHub owner/organization of the repository.
- repo
str
The name of the repository on GitHub.
- pr
str
The pull request number.
- use_srcbool, default:
False
Use the source file as context for the patch. Works for small files and not for large ones.
- filter_filename
str
,optional
If set, filters out all but the file matching this string.
- gh_access_token
str
,optional
GitHub token needed to communicate with the repository. By default,
None
, which means it will try to read an existing env variable namedGITHUB_TOKEN
.- config_file
str
,optional
Path to OpenAI configuration file. By default,
None
.- Returns
- ——-
- list[dict]
A dictionary containing suggestions for the reviewed patch.
- owner
- review.bot.open_ai_interface.review_folder(owner: str, repo: str, pr: int, folder: str, gh_access_token: str = None, config_file: str = None) List[Dict] #
Reviews an specific file from the PR. The file must have been modified in the PR.
- Parameters:
- owner
str
The GitHub owner/organization of the repository.
- repo
str
The name of the repository on GitHub.
- pr
str
The pull request number.
- folder
str
Name of the folder you want to review.
- gh_access_token
str
,optional
GitHub token needed to communicate with the repository. By default,
None
, which means it will try to read an existing env variable namedGITHUB_TOKEN
.- config_file
str
,optional
Path to OpenAI configuration file. By default,
None
.
- owner
- Returns:
List
[Dict
]List of dictionaries with the PR suggestions.
- review.bot.open_ai_interface.review_file(owner: str, repo: str, pr: int, filename: str, gh_access_token: str = None, config_file: str = None) List[Dict] #
Reviews an specific file from the PR. The file must have been modified in the PR.
- Parameters:
- owner
str
The GitHub owner/organization of the repository.
- repo
str
The name of the repository on GitHub.
- pr
str
The pull request number.
- filename
str
Name of the file you want to review.
- gh_access_token
str
,optional
GitHub token needed to communicate with the repository. By default,
None
, which means it will try to read an existing env variable namedGITHUB_TOKEN
.- config_file
str
,optional
Path to OpenAI configuration file. By default,
None
.
- owner
- Returns:
List
[Dict
]List of dictionaries with the PR suggestions.
- review.bot.open_ai_interface.review_patch_local(repo: str, branch: str = None, use_src: bool = False, filter_filename: str = None, config_file: str = None) List[Dict] #
Review a patch in a pull request and generate suggestions for improvement.
- Parameters:
- repo
str
The path to the local repository.
- branch
str
Name of the branch you want to compare to main. By default, current branch.
- use_srcbool, default:
False
Use the source file as context for the patch. Works for small files and not for large ones.
- filter_filename
str
,optional
If set, filters out all but the file matching this string.
- config_file
str
,optional
Path to OpenAI configuration file. By default,
None
.
- repo
- Returns:
- review.bot.open_ai_interface.message_generation(filename: str, patch: str = None, file_src: str = None, docs_only: bool = False) str #
Generate the required message for each type of query request.
- Parameters:
- Returns:
- review.bot.open_ai_interface.generate_suggestions(filename, patch=None, file_src=None, config_file: str = None, docs_only=False) List[Dict[str, str]] #
Generate suggestions for a given file source and patch.
- Parameters:
- filename
str
Name of the file being patched.
- patch
str
,optional
The patch text containing line numbers and changes.
- file_src: str, optional
Source file of the patch.
- config_file
str
,optional
Path to OpenAI configuration file. By default,
None
.- docs_only: bool, optional
Whether to review documentation only or the whole code. By default
False
.- Returns
- ——-
- list[dict]
A list of dictionaries containing suggestions for the patch.
- filename