
    dhw$                         S SK JrJrJrJrJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJrJr  \(       a  S SKJr  \" SSS	S
9 " S S\5      5       rg)    )TYPE_CHECKINGAnyCallableDictOptional)
deprecated)Document)get_from_dict_or_env)	BaseModelmodel_validatorApifyDatasetLoaderz0.3.18zThis class is deprecated and will be removed in a future version. You can swap to using the `ApifyWrapper` implementation in `langchain_apify` package. See <https://github.com/apify/langchain-apify>zlangchain_apify.ApifyWrapper)sincemessagealternative_importc                      \ rS rSr% Sr\\S'   \\S'   Sr\\	   \S'   \
" SS9\S	\S
\4S j5       5       rSSSS.S\	S\S\\/\4   S\\	   S\\   S\\   S
S4S jjrSSSS.S\	S\S\\/\4   S\\	   S\\   S\\   S
S4S jjrSSSS.S\	S\S\\/\4   S\\	   S\\   S\\   S
S4S jjrSSSS.S\	S\S\\/\4   S\\	   S\\   S\\   S
S4S jjrSrg)ApifyWrapper   zWrapper around Apify.
To use, you should have the ``apify-client`` python package installed,
and the environment variable ``APIFY_API_TOKEN`` set with your API key, or pass
`apify_api_token` as a named parameter to the constructor.
apify_clientapify_client_asyncNapify_api_tokenbefore)modevaluesreturnc                 d   [        USS5      n SSKJnJn  U" U5      n[	        UR
                  S5      =n(       a  UR                  S==   S-  ss'   U" U5      n[	        UR
                  S5      =n(       a  UR                  S==   S-  ss'   XQS	'   XqS
'   U$ ! [         a    [        S5      ef = f)zValidate environment.
Validate that an Apify API token is set and the apify-client
Python package exists in the current environment.
r   APIFY_API_TOKENr   )ApifyClientApifyClientAsynchttpx_clientz
user-agentz; Origin/langchainhttpx_async_clientr   r   z`Could not import apify-client Python package. Please install it with `pip install apify-client`.)r
   r   r   r   getattrhttp_clientheadersImportError)	clsr   r   r   r   clientr    async_clientr!   s	            [/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/utilities/apify.pyvalidate_environment!ApifyWrapper.validate_environment!   s     /%'8
	B 1F&v'9'9>JJ|J$$\26JJ2+O<L%,((*>& !  #**<8<PP8%+>"+7'(   	E 	s   BB B/)buildmemory_mbytestimeout_secsactor_id	run_inputdataset_mapping_functionr,   r-   r.   r   c                x    SSK Jn  U R                  R                  U5      R	                  UUUUS9nU" US   US9$ )a,  Run an Actor on the Apify platform and wait for results to be ready.
Args:
    actor_id (str): The ID or name of the Actor on the Apify platform.
    run_input (Dict): The input object of the Actor that you're trying to run.
    dataset_mapping_function (Callable): A function that takes a single
        dictionary (an Apify dataset item) and converts it to an
        instance of the Document class.
    build (str, optional): Optionally specifies the actor build to run.
        It can be either a build tag or build number.
    memory_mbytes (int, optional): Optional memory limit for the run,
        in megabytes.
    timeout_secs (int, optional): Optional timeout for the run, in seconds.
Returns:
    ApifyDatasetLoader: A loader that will fetch the records from the
        Actor run's default dataset.
r   r   r0   r,   r-   r.   defaultDatasetId
dataset_idr1   )$langchain_community.document_loadersr   r   actorcall	selfr/   r0   r1   r,   r-   r.   r   
actor_calls	            r)   
call_actorApifyWrapper.call_actorC   sU    4 	L&&,,X6;;'%	 < 

 "!"45%=
 	
    c                   #    SSK Jn  U R                  R                  U5      R	                  UUUUS9I Sh  vN nU" US   US9$  N7f)a,  Run an Actor on the Apify platform and wait for results to be ready.
Args:
    actor_id (str): The ID or name of the Actor on the Apify platform.
    run_input (Dict): The input object of the Actor that you're trying to run.
    dataset_mapping_function (Callable): A function that takes a single
        dictionary (an Apify dataset item) and converts it to
        an instance of the Document class.
    build (str, optional): Optionally specifies the actor build to run.
        It can be either a build tag or build number.
    memory_mbytes (int, optional): Optional memory limit for the run,
        in megabytes.
    timeout_secs (int, optional): Optional timeout for the run, in seconds.
Returns:
    ApifyDatasetLoader: A loader that will fetch the records from the
        Actor run's default dataset.
r   r   r3   Nr4   r5   )r7   r   r   r8   r9   r:   s	            r)   acall_actorApifyWrapper.acall_actork   sc     4 	L2288BGG'%	 H 
 

 "!"45%=
 	

   5AAAtask_id
task_inputc                x    SSK Jn  U R                  R                  U5      R	                  UUUUS9nU" US   US9$ )P  Run a saved Actor task on Apify and wait for results to be ready.
Args:
    task_id (str): The ID or name of the task on the Apify platform.
    task_input (Dict): The input object of the task that you're trying to run.
        Overrides the task's saved input.
    dataset_mapping_function (Callable): A function that takes a single
        dictionary (an Apify dataset item) and converts it to an
        instance of the Document class.
    build (str, optional): Optionally specifies the actor build to run.
        It can be either a build tag or build number.
    memory_mbytes (int, optional): Optional memory limit for the run,
        in megabytes.
    timeout_secs (int, optional): Optional timeout for the run, in seconds.
Returns:
    ApifyDatasetLoader: A loader that will fetch the records from the
        task run's default dataset.
r   r   rE   r,   r-   r.   r4   r5   )r7   r   r   taskr9   	r;   rD   rE   r1   r,   r-   r.   r   	task_calls	            r)   call_actor_taskApifyWrapper.call_actor_task   sU    6 	L%%**7388!'%	 9 
	 " !34%=
 	
r?   c                   #    SSK Jn  U R                  R                  U5      R	                  UUUUS9I Sh  vN nU" US   US9$  N7f)rG   r   r   rH   Nr4   r5   )r7   r   r   rI   r9   rJ   s	            r)   acall_actor_taskApifyWrapper.acall_actor_task   sc     6 	L1166w?DD!'%	 E 
 
	 " !34%=
 	

rC    )__name__
__module____qualname____firstlineno____doc__r   __annotations__r   r   strr   classmethodr   r*   r   r	   intr=   rA   rL   rO   __static_attributes__rQ   r?   r)   r   r      s	    %)OXc])(#$ 3   $L  $'+&*&
&
 &
 #+D68+;"<	&
 }&
  }&
 sm&
 
&
\  $'+&*&
&
 &
 #+D68+;"<	&
 }&
  }&
 sm&
 
&
\  $'+&*'
'
 '
 #+D68+;"<	'
 }'
  }'
 sm'
 
'
^  $'+&*'
'
 '
 #+D68+;"<	'
 }'
  }'
 sm'
 
'
 '
r?   r   N)typingr   r   r   r   r   langchain_core._apir   langchain_core.documentsr	   langchain_core.utilsr
   pydanticr   r   r7   r   r   rQ   r?   r)   <module>ra      sM    ? ? * - 5 /G 
	9
 6	M
9 M
	M
r?   