review.bot.open_ai_interface#

Functions to interface with OpenAI.

Module Contents#

Functions#

review_patch(owner, repo, pr[, use_src, ...])

Review a patch in a pull request and generate suggestions for improvement.

review_patch_local(repo[, branch, use_src, ...])

Review a patch in a pull request and generate suggestions for improvement.

generate_suggestions_with_source(→ List[Dict[str, str]])

Generate suggestions for a given file source and patch.

generate_suggestions(→ List[Dict[str, str]])

Generate suggestions for a given file source and patch.

Attributes#

LOG

OPEN_AI_MODEL

review.bot.open_ai_interface.LOG#
review.bot.open_ai_interface.OPEN_AI_MODEL#
review.bot.open_ai_interface.review_patch(owner, repo, pr, use_src=False, filter_filename=None, gh_access_token=None, config_file: str = None)#

Review a patch in a pull request and generate suggestions for improvement.

Parameters:
ownerstr

The GitHub owner/organization of the repository.

repostr

The name of the repository on GitHub.

prstr

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_filenamestr, optional

If set, filters out all but the file matching this string.

gh_access_tokenstr, optional

GitHub token needed to communicate with the repository. By default, None, which means it will try to read an existing env variable named GITHUB_TOKEN.

config_filestr, optional

Path to OpenAI configuration file. By default, None.

Returns
——-
list[dict]

A dictionary containing suggestions for the reviewed patch.

review.bot.open_ai_interface.review_patch_local(repo: str, branch: str = None, use_src=False, filter_filename=None, config_file: str = None)#

Review a patch in a pull request and generate suggestions for improvement.

Parameters:
repostr

The path to the local repository.

branchstr

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_filenamestr, optional

If set, filters out all but the file matching this string.

config_filestr, optional

Path to OpenAI configuration file. By default, None.

Returns:
list[dict]

A dictionary containing suggestions for the reviewed patch.

review.bot.open_ai_interface.generate_suggestions_with_source(filename, file_src, patch, config_file: str = None) List[Dict[str, str]]#

Generate suggestions for a given file source and patch.

Parameters:
filenamestr

Name of the file being patched.

file_srcstr

The source file text including the file name and its contents.

patchstr

The patch text containing line numbers and changes.

config_filestr, optional

Path to OpenAI configuration file. By default, None.

Returns:
list[dict]

A list of dictionaries containing suggestions for the patch.

review.bot.open_ai_interface.generate_suggestions(filename, patch, config_file: str = None) List[Dict[str, str]]#

Generate suggestions for a given file source and patch.

Parameters:
filenamestr

Name of the file being patched.

patchstr

The patch text containing line numbers and changes.

config_filestr, optional

Path to OpenAI configuration file. By default, None.

Returns:
list[dict]

A list of dictionaries containing suggestions for the patch.