langchain_community.utilities.github
.GitHubAPIWrapper¶
- class langchain_community.utilities.github.GitHubAPIWrapper[source]¶
Bases:
BaseModel
GitHub API的包装器。
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- param active_branch: Optional[str] = None¶
- param github_app_id: Optional[str] = None¶
- param github_app_private_key: Optional[str] = None¶
- param github_base_branch: Optional[str] = None¶
- param github_repository: Optional[str] = None¶
- comment_on_issue(comment_query: str) str [source]¶
将评论添加到github问题 参数:
comment_query(str):一个包含问题编号、两个换行符和评论的字符串。 例如:”1
- 现在正在处理”
将评论“现在正在处理”添加到问题1
- 返回:
str:成功或失败消息
- Parameters
comment_query (str) –
- Return type
str
- classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model ¶
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values
- Parameters
_fields_set (Optional[SetStr]) –
values (Any) –
- Return type
Model
- copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model ¶
Duplicate a model, optionally choose which fields to include, exclude and change.
- Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include
update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data
deep (bool) – set to True to make a deep copy of the model
self (Model) –
- Returns
new model instance
- Return type
Model
- create_branch(proposed_branch_name: str) str [source]¶
创建一个新的分支,并将其设置为活动的机器人分支。 相当于 git switch -c proposed_branch_name 如果提议的分支已经存在,我们会追加 _v1,然后 _v2… 直到找到一个唯一的名称。
- 返回:
str: 一个纯文本的成功消息。
- Parameters
proposed_branch_name (str) –
- Return type
str
- create_file(file_query: str) str [source]¶
- 在Github仓库上创建一个新文件
- 参数:
file_query(str): 一个包含文件路径和文件内容的字符串。文件路径是字符串的第一行,内容是字符串的其余部分。 例如, “hello_world.md
- # Hello World!”
- 返回:
str: 一个成功或失败的消息
- Parameters
file_query (str) –
- Return type
str
- create_pull_request(pr_query: str) str [source]¶
- 从机器人的分支向基础分支发起拉取请求
- 参数:
pr_query(str): 包含PR标题和PR正文的字符串。标题是字符串的第一行,正文是字符串的其余部分。 例如,”更新了README
- 进行了添加信息的更改”
- 返回:
str: 成功或失败消息
- Parameters
pr_query (str) –
- Return type
str
- create_review_request(reviewer_username: str) str [source]¶
在与当前活动分支匹配的*开放拉取请求*上创建一个审查请求。
- 参数:
reviewer_username(str): 被请求人的用户名
- 返回:
str: 确认创建审查请求的消息
- Parameters
reviewer_username (str) –
- Return type
str
- delete_file(file_path: str) str [source]¶
从仓库中删除一个文件 参数:
file_path(str): 文件所在的路径
- 返回:
str: 成功或失败的消息
- Parameters
file_path (str) –
- Return type
str
- dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny ¶
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
by_alias (bool) –
skip_defaults (Optional[bool]) –
exclude_unset (bool) –
exclude_defaults (bool) –
exclude_none (bool) –
- Return type
DictStrAny
- classmethod from_orm(obj: Any) Model ¶
- Parameters
obj (Any) –
- Return type
Model
- get_files_from_directory(directory_path: str) str [source]¶
递归地从存储库中的目录中获取文件。
- 参数:
directory_path(str):目录路径
- 返回:
str:文件路径列表,或错误消息。
- Parameters
directory_path (str) –
- Return type
str
- get_issue(issue_number: int) Dict[str, Any] [source]¶
获取特定问题及其前10条评论 参数:
issue_number(int): Github问题的编号
- 返回:
dict: 包含问题标题、内容、评论(字符串形式)以及开启问题的用户的用户名的字典
- Parameters
issue_number (int) –
- Return type
Dict[str, Any]
- get_issues() str [source]¶
获取存储库中的所有未解决问题,不包括拉取请求
- 返回:
str: 一个包含问题数量以及每个问题标题和编号的纯文本报告。
- Return type
str
- get_pull_request(pr_number: int) Dict[str, Any] [source]¶
获取特定的拉取请求及其前10条评论,受 max_tokens 限制。
- 参数:
pr_number(int): Github 拉取请求的编号 max_tokens(int): 响应中的最大令牌数
- 返回:
dict: 包含拉取请求的标题、正文和评论的字符串的字典
- Parameters
pr_number (int) –
- Return type
Dict[str, Any]
- json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode ¶
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
- Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
by_alias (bool) –
skip_defaults (Optional[bool]) –
exclude_unset (bool) –
exclude_defaults (bool) –
exclude_none (bool) –
encoder (Optional[Callable[[Any], Any]]) –
models_as_dict (bool) –
dumps_kwargs (Any) –
- Return type
unicode
- list_files_in_bot_branch() str [source]¶
获取存储库活动分支中的所有文件, 机器人用于进行更改的分支。
- 返回:
str:包含分支中文件路径的纯文本列表。
- Return type
str
- list_open_pull_requests() str [source]¶
从存储库中获取所有打开的PR
- 返回:
str:包含PR数量以及每个PR的标题和编号的纯文本报告。
- Return type
str
- list_pull_request_files(pr_number: int) List[Dict[str, Any]] [source]¶
获取PR中所有文件的完整文本。在前3k个标记后截断。 # TODO: 如果文件变得很长,通过ctags对文件进行摘要。
- 参数:
pr_number(int): Github上拉取请求的编号
- 返回:
dict: 包含问题标题、正文和评论的字符串的字典
- Parameters
pr_number (int) –
- Return type
List[Dict[str, Any]]
- classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model ¶
- Parameters
path (Union[str, Path]) –
content_type (unicode) –
encoding (unicode) –
proto (Protocol) –
allow_pickle (bool) –
- Return type
Model
- parse_issues(issues: List[Issue]) List[dict] [source]¶
从每个问题中提取标题和编号,并将它们放入字典中 参数:
issues(List[Issue]): Github问题对象的列表
- 返回:
List[dict]: 问题标题和编号的字典
- Parameters
issues (List[Issue]) –
- Return type
List[dict]
- classmethod parse_obj(obj: Any) Model ¶
- Parameters
obj (Any) –
- Return type
Model
- parse_pull_requests(pull_requests: List[PullRequest]) List[dict] [source]¶
从每个问题中提取标题和编号,并将它们放入字典中 参数:
issues(List[Issue]): Github问题对象的列表
- 返回:
List[dict]: 问题标题和编号的字典
- Parameters
pull_requests (List[PullRequest]) –
- Return type
List[dict]
- classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model ¶
- Parameters
b (Union[str, bytes]) –
content_type (unicode) –
encoding (unicode) –
proto (Protocol) –
allow_pickle (bool) –
- Return type
Model
- read_file(file_path: str) str [source]¶
从此代理的分支中读取一个文件,由self.active_branch定义,支持PR分支。 参数:
file_path(str): 文件路径
- 返回:
str: 解码为字符串的文件,如果未找到则返回错误消息
- Parameters
file_path (str) –
- Return type
str
- classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') DictStrAny ¶
- Parameters
by_alias (bool) –
ref_template (unicode) –
- Return type
DictStrAny
- classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) unicode ¶
- Parameters
by_alias (bool) –
ref_template (unicode) –
dumps_kwargs (Any) –
- Return type
unicode
- search_code(query: str) str [source]¶
在存储库中搜索代码。 # 待办事项:限制返回的总令牌数量…
- 参数:
query(str): 搜索查询
- 返回:
str: 包含最多前5个搜索结果的字符串
- Parameters
query (str) –
- Return type
str
- search_issues_and_prs(query: str) str [source]¶
搜索存储库中的问题和拉取请求。
- 参数:
query(str): 搜索查询
- 返回:
str: 包含前5个问题和拉取请求的字符串
- Parameters
query (str) –
- Return type
str
- set_active_branch(branch_name: str) str [source]¶
对于此代理,相当于`git checkout branch_name`。 从Github克隆格式。 如果分支不存在,则返回错误(作为字符串)。
- Parameters
branch_name (str) –
- Return type
str
- update_file(file_query: str) str [source]¶
更新文件内容。 参数:
- file_query(str): 包含文件路径和文件内容。
旧文件内容被包裹在 OLD <<<< 和 >>>> OLD 中 新文件内容被包裹在 NEW <<<< 和 >>>> NEW 中 例如: /test/hello.txt OLD <<<< Hello Earth! >>>> OLD NEW <<<< Hello Mars! >>>> NEW
- 返回:
成功或失败消息
- Parameters
file_query (str) –
- Return type
str
- classmethod update_forward_refs(**localns: Any) None ¶
Try to update ForwardRefs on fields based on this Model, globalns and localns.
- Parameters
localns (Any) –
- Return type
None
- classmethod validate(value: Any) Model ¶
- Parameters
value (Any) –
- Return type
Model