Ë
    µŒjÅ<  ã                   ó  — d Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	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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	„ d
e	«      Z' G d„ de	«      Z( G d„ de	«      Z) G d„ de	«      Z* G d„ de	«      Z+ G d„ de	«      Z, G d„ de	«      Z- G d„ de	«      Z. G d„ de	«      Z/ G d„ de	«      Z0 G d„ de	«      Z1 G d„ d e	«      Z2 G d!„ d"e	«      Z3 G d#„ d$e	«      Z4 G d%„ d&e	«      Z5 G d'„ d(e«      Z6y))*zGitHub Toolkit.é    )ÚDictÚList)ÚBaseTool)ÚBaseToolkit)Ú	BaseModelÚField)ÚCOMMENT_ON_ISSUE_PROMPTÚCREATE_BRANCH_PROMPTÚCREATE_FILE_PROMPTÚCREATE_PULL_REQUEST_PROMPTÚCREATE_REVIEW_REQUEST_PROMPTÚDELETE_FILE_PROMPTÚGET_FILES_FROM_DIRECTORY_PROMPTÚGET_ISSUE_PROMPTÚGET_ISSUES_PROMPTÚGET_LATEST_RELEASE_PROMPTÚGET_PR_PROMPTÚGET_RELEASE_PROMPTÚGET_RELEASES_PROMPTÚLIST_BRANCHES_IN_REPO_PROMPTÚLIST_PRS_PROMPTÚLIST_PULL_REQUEST_FILESÚ"OVERVIEW_EXISTING_FILES_BOT_BRANCHÚOVERVIEW_EXISTING_FILES_IN_MAINÚREAD_FILE_PROMPTÚSEARCH_CODE_PROMPTÚSEARCH_ISSUES_AND_PRS_PROMPTÚSET_ACTIVE_BRANCH_PROMPTÚUPDATE_FILE_PROMPT)ÚGitHubAction)ÚGitHubAPIWrapperc                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)ÚNoInputz4Schema for operations that do not require any input.Ú z*No input required, e.g. `` (empty string).©ÚdescriptionÚno_inputN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r'   ÚstrÚ__annotations__© ó    ú{/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/agent_toolkits/github/toolkit.pyr#   r#   &   s   … Ù>á˜"Ð*VÔW€HˆcÔWr/   r#   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)ÚGetIssuez<Schema for operations that require an issue number as input.r   z%Issue number as an integer, e.g. `42`r%   Úissue_numberN)r(   r)   r*   r+   r   r3   Úintr-   r.   r/   r0   r2   r2   ,   s   … ÙFá˜aÐ-TÔU€L�#ÔUr/   r2   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)ÚCommentOnIssuez6Schema for operations that require a comment as input..úFollow the required formatting.r%   ÚinputN©r(   r)   r*   r+   r   r8   r,   r-   r.   r/   r0   r6   r6   2   s   … Ù@á�sÐ(IÔJ€Eˆ3ÔJr/   r6   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)ÚGetPRz8Schema for operations that require a PR number as input.r   z&The PR number as an integer, e.g. `12`r%   Ú	pr_numberN)r(   r)   r*   r+   r   r<   r4   r-   r.   r/   r0   r;   r;   8   s   … ÙBá˜1Ð*RÔS€IˆsÔSr/   r;   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)ÚCreatePRz@Schema for operations that require a PR title and body as input..r7   r%   Úformatted_prN)r(   r)   r*   r+   r   r?   r,   r-   r.   r/   r0   r>   r>   >   s   … ÙJá˜cÐ/PÔQ€L�#ÔQr/   r>   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)Ú
CreateFileúDSchema for operations that require a file path and content as input..r7   r%   Úformatted_fileN)r(   r)   r*   r+   r   rC   r,   r-   r.   r/   r0   rA   rA   D   s   … ÙNá Ð1RÔS€N�CÔSr/   rA   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)ÚReadFileú8Schema for operations that require a file path as input..z}The full file path of the file you would like to read where the path must NOT start with a slash, e.g. `some_dir/my_file.py`.r%   Úformatted_filepathN©r(   r)   r*   r+   r   rG   r,   r-   r.   r/   r0   rE   rE   J   s    … ÙBá#ØðLôÐ˜ô r/   rE   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)Ú
UpdateFilerB   .z#Strictly follow the provided rules.r%   Úformatted_file_updateN)r(   r)   r*   r+   r   rK   r,   r-   r.   r/   r0   rJ   rJ   V   s   … ÙNá!&ØÐ>ô"Ð˜3ô r/   rJ   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)Ú
DeleteFilerF   .z¨The full file path of the file you would like to delete where the path must NOT start with a slash, e.g. `some_dir/my_file.py`. Only input a string, not the param name.r%   rG   NrH   r.   r/   r0   rM   rM   ^   s   … ÙBá#Øð#ôÐ˜ô r/   rM   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)ÚDirectoryPathz=Schema for operations that require a directory path as input.r$   zmThe path of the directory, e.g. `some_dir/inner_dir`. Only input a string, do not include the parameter name.r%   r8   Nr9   r.   r/   r0   rO   rO   l   s   … ÙGáØ
ðGô€Eˆ3ô r/   rO   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)Ú
BranchNamez:Schema for operations that require a branch name as input..z)The name of the branch, e.g. `my_branch`.r%   Úbranch_nameN)r(   r)   r*   r+   r   rR   r,   r-   r.   r/   r0   rQ   rQ   x   s   … ÙDáØÐDô€K�ô r/   rQ   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)Ú
SearchCodeú;Schema for operations that require a search query as input..zQA keyword-focused natural language searchquery for code, e.g. `MyFunctionName()`.r%   Úsearch_queryN©r(   r)   r*   r+   r   rV   r,   r-   r.   r/   r0   rT   rT   €   s   … ÙEáØð7ô€L�#ô r/   rT   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)ÚCreateReviewRequestz7Schema for operations that require a username as input..z@GitHub username of the user being requested, e.g. `my_username`.r%   ÚusernameN)r(   r)   r*   r+   r   rZ   r,   r-   r.   r/   r0   rY   rY   Œ   s   … ÙAáØØVô€Hˆcô r/   rY   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)ÚSearchIssuesAndPRsrU   .z>Natural language search query, e.g. `My issue title or topic`.r%   rV   NrW   r.   r/   r0   r\   r\   •   s   … ÙEáØØTô€L�#ô r/   r\   c                   ó0   — e Zd ZU dZ edd¬«      Zeed<   y)ÚTagNamez7Schema for operations that require a tag name as input..z+The tag name of the release, e.g. `v1.0.0`.r%   Útag_nameN)r(   r)   r*   r+   r   r_   r,   r-   r.   r/   r0   r^   r^   ž   s   … ÙAáØØAô€Hˆcô r/   r^   c                   óZ   — e Zd ZU dZg Zee   ed<   e	 d	de	de
dd fd„«       Zdee   fd„Zy)
ÚGitHubToolkita)  GitHub 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 GitHub.

        See [Security](https://python.langchain.com/docs/security) for more information.

    Setup:
        See detailed installation instructions here:
        https://python.langchain.com/docs/integrations/tools/github/#installation

        You will need to install ``pygithub`` and set the following environment
        variables:

        .. code-block:: bash

            pip install -U pygithub
            export GITHUB_APP_ID="your-app-id"
            export GITHUB_APP_PRIVATE_KEY="path-to-private-key"
            export GITHUB_REPOSITORY="your-github-repository"

    Instantiate:
        .. code-block:: python

            from langchain_community.agent_toolkits.github.toolkit import GitHubToolkit
            from langchain_community.utilities.github import GitHubAPIWrapper

            github = GitHubAPIWrapper()
            toolkit = GitHubToolkit.from_github_api_wrapper(github)

    Tools:
        .. code-block:: python

            tools = toolkit.get_tools()
            for tool in tools:
                print(tool.name)

        .. code-block:: none

            Get Issues
            Get Issue
            Comment on Issue
            List open pull requests (PRs)
            Get Pull Request
            Overview of files included in PR
            Create Pull Request
            List Pull Requests' Files
            Create File
            Read File
            Update File
            Delete File
            Overview of existing files in Main branch
            Overview of files in current working branch
            List branches in this repository
            Set active branch
            Create a new branch
            Get files from a directory
            Search issues and pull requests
            Search code
            Create review request

    Include release tools:
        By default, the toolkit does not include release-related tools.
        You can include them by setting ``include_release_tools=True`` when
        initializing the toolkit:

        .. code-block:: python

            toolkit = GitHubToolkit.from_github_api_wrapper(
                github, include_release_tools=True
            )

        Setting ``include_release_tools=True`` will include the following tools:

        .. code-block:: none

            Get latest release
            Get releases
            Get release

    Use within an agent:
        .. code-block:: python

            from langchain_openai import ChatOpenAI
            from langgraph.prebuilt import create_react_agent

            # Select example tool
            tools = [tool for tool in toolkit.get_tools() if tool.name == "Get Issue"]
            assert len(tools) == 1
            tools[0].name = "get_issue"

            llm = ChatOpenAI(model="gpt-4o-mini")
            agent_executor = create_react_agent(llm, tools)

            example_query = "What is the title of issue 24888?"

            events = agent_executor.stream(
                {"messages": [("user", example_query)]},
                stream_mode="values",
            )
            for event in events:
                event["messages"][-1].pretty_print()

        .. code-block:: none

             ================================[1m Human Message [0m=================================

            What is the title of issue 24888?
            ==================================[1m Ai Message [0m==================================
            Tool Calls:
            get_issue (call_iSYJVaM7uchfNHOMJoVPQsOi)
            Call ID: call_iSYJVaM7uchfNHOMJoVPQsOi
            Args:
                issue_number: 24888
            =================================[1m Tool Message [0m=================================
            Name: get_issue

            {"number": 24888, "title": "Standardize KV-Store Docs", "body": "..."
            ==================================[1m Ai Message [0m==================================

            The title of issue 24888 is "Standardize KV-Store Docs".

    Parameters:
        tools: List[BaseTool]. The tools in the toolkit. Default is an empty list.
    ÚtoolsÚgithub_api_wrapperÚinclude_release_toolsÚreturnc                 óD  — ddt         t        dœddt        t        dœddt        t
        dœdd	t        t        dœd
dt        t        dœddt        t        dœddt        t        dœddt        t        dœddt        t        dœddt        t        dœddt         t"        dœddt$        t&        dœddt(        t        dœddt*        t        dœddt,        t        dœdd t.        t0        dœd!d"t2        t0        dœd#d$t4        t6        dœd%d&t8        t:        dœd'd(t<        t>        dœd)d*t@        tB        dœg}d+d,tD        t        dœd-d.tF        t        dœd/d0tH        tJ        dœg}||r|ng z   }|D �cg c]+  }tM        |d1   |d2   |d3   ||jO                  d4d5«      ¬6«      ‘Œ- }} | |¬7«      S c c}w )8aH  Create a GitHubToolkit from a GitHubAPIWrapper.

        Args:
            github_api_wrapper: GitHubAPIWrapper. The GitHub API wrapper.
            include_release_tools: bool. Whether to include release-related tools.
                Defaults to False.

        Returns:
            GitHubToolkit. The GitHub toolkit.
        Ú
get_issuesz
Get Issues)ÚmodeÚnamer&   Úargs_schemaÚ	get_issuez	Get IssueÚcomment_on_issuezComment on IssueÚlist_open_pull_requestszList open pull requests (PRs)Úget_pull_requestzGet Pull RequestÚlist_pull_request_filesz Overview of files included in PRÚcreate_pull_requestzCreate Pull RequestzList Pull Requests' FilesÚcreate_filezCreate FileÚ	read_filez	Read FileÚupdate_filezUpdate FileÚdelete_filezDelete FileÚlist_files_in_main_branchz)Overview of existing files in Main branchÚlist_files_in_bot_branchz+Overview of files in current working branchÚlist_branches_in_repoz List branches in this repositoryÚset_active_branchzSet active branchÚcreate_branchzCreate a new branchÚget_files_from_directoryzGet files from a directoryÚsearch_issues_and_prszSearch issues and pull requestsÚsearch_codezSearch codeÚcreate_review_requestzCreate review requestÚget_latest_releasezGet latest releaseÚget_releaseszGet releasesÚget_releasezGet releaseri   r&   rh   rj   N)ri   r&   rh   Úapi_wrapperrj   ©rb   )(r   r#   r   r2   r	   r6   r   r   r;   r   r   r>   r   rA   r   rE   r   rJ   r   rM   r   r   r   r   rQ   r
   r   rO   r   r\   r   rT   r   rY   r   r   r   r^   r    Úget)Úclsrc   rd   Ú
operationsÚrelease_operationsÚactionrb   s          r0   Úfrom_github_api_wrapperz%GitHubToolkit.from_github_api_wrapper,  sS  € ð  %Ø$Ü0Ü&ñ	ð $Ø#Ü/Ü'ñ	ð +Ø*Ü6Ü-ñ	ð 2Ø7Ü.Ü&ñ	ð +Ø*Ü,Ü$ñ	ð 2Ø:Ü6Ü$ñ	ð .Ø-Ü9Ü'ñ	ð 2Ø3Ü6Ü$ñ	ð &Ø%Ü1Ü)ñ	ð $Ø#Ü/Ü'ñ	ð &Ø%Ü1Ü)ñ	ð &Ø%Ü1Ü)ñ	ð 4ØCÜ>Ü&ñ	ð 3ØEÜAÜ&ñ	ð 0Ø:Ü;Ü&ñ	ð ,Ø+Ü7Ü)ñ	ð (Ø-Ü3Ü)ñ	ð 3Ø4Ü>Ü,ñ	ð 0Ø9Ü;Ü1ñ	ð &Ø%Ü1Ü)ñ	ð 0Ø/Ü;Ü2ñ	ðs"
ˆ
ðF -Ø,Ü8Ü&ñ	ð 'Ø&Ü2Ü&ñ	ð &Ø%Ü1Ü&ñ	ð*
Ðð*  Ñ9NÑ#5ÐTVÑWˆ
ñ %ó	
ñ %�ô Ø˜F‘^Ø" =Ñ1Ø˜F‘^Ø.Ø"ŸJ™J }°dÓ;öð %ð 	ð 	
ñ ˜ÔÐùò	
s   Å"0Fc                 ó   — | j                   S )zGet the tools in the toolkit.r‚   )Úselfs    r0   Ú	get_toolszGitHubToolkit.get_toolsÝ  s   € à�z‰zÐr/   N)F)r(   r)   r*   r+   rb   r   r   r-   Úclassmethodr!   Úboolrˆ   r‹   r.   r/   r0   ra   ra   §   s\   … ñ@ðD €Eˆ4�‰>ÓààQVñn Ø!1ðn ØJNðn à	òn ó ðn ð`˜4 ™>ô r/   ra   N)7r+   Útypingr   r   Úlangchain_core.toolsr   Úlangchain_core.tools.baser   Úpydanticr   r   Ú'langchain_community.tools.github.promptr	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Ú%langchain_community.tools.github.toolr    Ú$langchain_community.utilities.githubr!   r#   r2   r6   r;   r>   rA   rE   rJ   rM   rO   rQ   rT   rY   r\   r^   ra   r.   r/   r0   Ú<module>r•      s  ðÙ ç å )Ý 1ß %÷÷ ÷ ÷ ÷ ÷ ñ õ2 ?Ý AôXˆiô XôVˆyô VôK�Yô KôTˆIô TôRˆyô RôT�ô Tô	ˆyô 	ô�ô ô�ô ô	�Iô 	ô�ô ô	�ô 	ô˜)ô ô˜ô ôˆiô ôx�Kõ xr/   