o
    {qig                     @  s   d Z ddlmZ ddlZddlmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZ 		d$d%ddZddddddddd&ddZddddd'd"d#ZdS )(zGInterface with the `LangChain Hub <https://smith.langchain.com/hub>`__.    )annotationsN)Sequence)AnyOptional)dumps)loads)BasePromptTemplateapi_keyOptional[str]api_urlreturnr   c                 C  s   z&ddl m} ||| d}t|drt|dr|W S ddlm} ||| dW S  tyP   zddlm} ||| dW  Y S  tyO } zd}t||d }~ww w )Nr   )Client)r	   push_promptpull_promptzdCould not import langsmith or langchainhub (deprecated),please install with `pip install langsmith`.)Z	langsmithr   hasattrZlangchainhubImportError)r	   r   ZLangSmithClientZ	ls_clientZLangChainHubClientemsg r   T/home/app/PaddleOCR-VL/.venv_paddleocr/lib/python3.10/site-packages/langchain/hub.py_get_client   s$   
r   F)r   r	   parent_commit_hashnew_repo_is_publicnew_repo_descriptionreadmetagsrepo_full_namestrobjectr   r   boolr   r   r   Optional[Sequence[str]]c             	   C  sJ   t ||d}	t|	dr|	j| ||||||dS t|}
|	j| |
|||dS )al  
    Push an object to the hub and returns the URL it can be viewed at in a browser.

    :param repo_full_name: The full name of the prompt to push to in the format of
        `owner/prompt_name` or `prompt_name`.
    :param object: The LangChain to serialize and push to the hub.
    :param api_url: The URL of the LangChain Hub API. Defaults to the hosted API service
        if you have an api key set, or a localhost instance if not.
    :param api_key: The API key to use to authenticate with the LangChain Hub API.
    :param parent_commit_hash: The commit hash of the parent commit to push to. Defaults
        to the latest commit automatically.
    :param new_repo_is_public: Whether the prompt should be public. Defaults to
        False (Private by default).
    :param new_repo_description: The description of the prompt. Defaults to an empty
        string.
    r	   r   r   )r   r   Z	is_publicdescriptionr   r   )r   r   r   )r   r   r   r   push)r   r   r   r	   r   r   r   r   r   clientZmanifest_jsonr   r   r   r#   (   s&   
r#   )include_modelr   r	   owner_repo_commitr%   Optional[bool]c                C  s   t ||d}t|dr|j| |dS t|drI|| }tt|d }t|trG|j	du r2i |_	|d |j	d< |d	 |j	d
< |d |j	d< |S |
| }t|S )a
  
    Pull an object from the hub and returns it as a LangChain object.

    :param owner_repo_commit: The full name of the prompt to pull from in the format of
        `owner/prompt_name:commit_hash` or `owner/prompt_name`
        or just `prompt_name` if it's your own prompt.
    :param api_url: The URL of the LangChain Hub API. Defaults to the hosted API service
        if you have an api key set, or a localhost instance if not.
    :param api_key: The API key to use to authenticate with the LangChain Hub API.
    r!   r   )r%   	pull_repomanifestNownerZlc_hub_ownerrepoZlc_hub_repoZcommit_hashZlc_hub_commit_hash)r   r   r   r(   r   jsonr   
isinstancer   metadatapull)r&   r%   r   r	   r$   Zres_dictobjrespr   r   r   r/   ]   s   





r/   )NN)r	   r
   r   r
   r   r   )r   r   r   r   r   r
   r	   r
   r   r
   r   r   r   r
   r   r
   r   r    r   r   )
r&   r   r%   r'   r   r
   r	   r
   r   r   )__doc__
__future__r   r,   collections.abcr   typingr   r   Zlangchain_core.load.dumpr   Zlangchain_core.load.loadr   Zlangchain_core.promptsr   r   r#   r/   r   r   r   r   <module>   s.    8