o
    Zh                     @   s   d Z ddlmZmZmZ ddlmZ ddlmZ ddl	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ ddlmZ g dZG d	d
 d
eZdS )zGitLab Toolkit.    )DictListOptional)BaseTool)BaseToolkit)COMMENT_ON_ISSUE_PROMPTCREATE_FILE_PROMPTCREATE_PULL_REQUEST_PROMPTCREATE_REPO_BRANCHDELETE_FILE_PROMPTGET_ISSUE_PROMPTGET_ISSUES_PROMPTGET_REPO_FILES_FROM_DIRECTORYGET_REPO_FILES_IN_BOT_BRANCHGET_REPO_FILES_IN_MAINLIST_REPO_BRANCESREAD_FILE_PROMPTSET_ACTIVE_BRANCHUPDATE_FILE_PROMPTGitLabAction)GitLabAPIWrapper)
get_issues	get_issuecomment_on_issuecreate_pull_requestcreate_file	read_fileupdate_filedelete_filec                   @   s\   e Zd ZU dZg Zee ed< eddde	de
ee  dd fdd	Zdee fd
dZdS )GitLabToolkita  GitLab Toolkit.

    *Security Note*: This toolkit contains tools that can read and modify
        the state of a service; e.g., by creating, deleting, or updating,
        reading underlying data.

        For example, this toolkit can be used to create issues, pull requests,
        and comments on GitLab.

        See https://python.langchain.com/docs/security for more information.

    Parameters:
        tools: List[BaseTool]. The tools in the toolkit. Default is an empty list.
    toolsN)included_toolsgitlab_api_wrapperr"   returnc                   s   |dur|nt ddtdddtdddtdd	d
tdddtdddtdddtdddtdddt	dddt
dddtdddtdddtdddtdg}fdd |D } fd!d |D }| |d"S )#zCreate a GitLabToolkit from a GitLabAPIWrapper.

        Args:
            gitlab_api_wrapper: GitLabAPIWrapper. The GitLab API wrapper.

        Returns:
            GitLabToolkit. The GitLab toolkit.
        Nr   z
Get Issues)modenamedescriptionr   z	Get Issuer   zComment on Issuer   zCreate Pull Requestr   zCreate Filer   z	Read Filer   zUpdate Filer   zDelete FileZcreate_branchzCreate a new branchZlist_branches_in_repozGet the list of branchesZset_active_branchzChange the active branchZlist_files_in_main_branchz)Overview of existing files in Main branchZlist_files_in_bot_branchz+Overview of files in current working branchZlist_files_from_directoryz@Overview of files in current working branch from a specific pathc                    s   g | ]
}|d   v r|qS )r%    ).0Z	operation)tools_to_includer(   h/var/www/html/lang_env/lib/python3.10/site-packages/langchain_community/agent_toolkits/gitlab/toolkit.py
<listcomp>   s
    z9GitLabToolkit.from_gitlab_api_wrapper.<locals>.<listcomp>c                    s(   g | ]}t |d  |d |d  dqS )r&   r'   r%   )r&   r'   r%   Zapi_wrapperr   )r)   action)r#   r(   r+   r,      s    r!   )DEFAULT_INCLUDED_TOOLSr   r   r   r	   r   r   r   r   r
   r   r   r   r   r   )clsr#   r"   
operationsZoperations_filteredr!   r(   )r#   r*   r+   from_gitlab_api_wrapper<   s   
H

	z%GitLabToolkit.from_gitlab_api_wrapperc                 C   s   | j S )zGet the tools in the toolkit.r.   )selfr(   r(   r+   	get_tools   s   zGitLabToolkit.get_tools)__name__
__module____qualname____doc__r!   r   r   __annotations__classmethodr   r   strr2   r4   r(   r(   r(   r+   r    *   s   
 
kr    N)r8   typingr   r   r   Zlangchain_core.toolsr   Zlangchain_core.tools.baser   Z'langchain_community.tools.gitlab.promptr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   Z%langchain_community.tools.gitlab.toolr   Z$langchain_community.utilities.gitlabr   r/   r    r(   r(   r(   r+   <module>   s    @