
    0j[                       d dl mZ d dlmZmZmZmZmZmZm	Z	 d dl
mZ d dlZddlmZmZmZmZmZmZmZ ddlmZmZmZ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# ddl$m%Z%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l0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddgZ< G d de          Z= G d de          Z> G d d          Z? G d d          Z@ G d d          ZA G d  d!          ZBdS )"    )annotations)AnyDictListUnionIterableOptionalcast)chainN   )BodyOmitQueryHeadersNotGivenomit	not_given)is_givenmaybe_transformstrip_not_givenasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_raw_response_wrapperto_streamed_response_wrapperasync_to_raw_response_wrapper"async_to_streamed_response_wrapper)StreamAsyncStream)task_run_create_paramstask_run_result_params)make_request_options)TaskRun)TaskSpecParam)WebhookParam)McpServerParam)ParallelBetaParam)BetaTaskRunResult)SourcePolicy)TaskRunEventsResponseTaskRunResourceAsyncTaskRunResourcec                      e Zd ZdZed0d            Zed1d            Zeeeeeeeedddedd2d&Z	ddded'd3d*Z
eeddded+d4d/ZdS )5r,     The Task API executes web research and extraction tasks.

    Clients submit a natural-language objective with an optional input schema; the service plans retrieval, fetches relevant URLs, and returns outputs that conform to a provided or inferred JSON schema. Supports deep research style queries and can return rich structured JSON outputs. Processors trade-off between cost, latency, and quality. Each processor supports calibrated confidences.
    - Output metadata: citations, excerpts, reasoning, and confidence per field
    returnTaskRunResourceWithRawResponsec                     t          |           S a  
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/parallel-web/parallel-sdk-python#accessing-raw-response-data-eg-headers
        )r1   selfs    h/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/parallel/resources/beta/task_run.pywith_raw_responsez!TaskRunResource.with_raw_response*   s     .d333    $TaskRunResourceWithStreamingResponsec                     t          |           S z
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/parallel-web/parallel-sdk-python#with_streaming_response
        )r9   r4   s    r6   with_streaming_responsez'TaskRunResource.with_streaming_response4   s     4D999r8   Nenable_eventsmcp_serversmetadataprevious_interaction_idsource_policy	task_specwebhookbetasextra_headersextra_query
extra_bodytimeoutinputUnion[str, Dict[str, object]]	processorstrr>   Optional[bool] | Omitr?   )Optional[Iterable[McpServerParam]] | Omitr@   3Optional[Dict[str, Union[str, float, bool]]] | OmitrA   Optional[str] | OmitrB   Optional[SourcePolicy] | OmitrC   Optional[TaskSpecParam] | OmitrD   Optional[WebhookParam] | OmitrE   List[ParallelBetaParam] | OmitrF   Headers | NonerG   Query | NonerH   Body | NonerI   'float | httpx.Timeout | None | NotGivenr$   c               f   i t          dt          |
          r.d                    t          d |
D             dg                    nt          i          |pi }ddi|pi }|                     dt          |||||||||	d	t          j                  t          ||||          t                    S )	[	  
        Initiates a task run.

        Returns immediately with a run object in status 'queued'.

        Beta features can be enabled by setting the 'parallel-beta' header.

        Args:
          input: Input to the task, either text or a JSON object.

          processor: Processor to use for the task.

          enable_events: Controls tracking of task run execution progress. When set to true, progress
              events are recorded and can be accessed via the
              [Task Run events](https://platform.parallel.ai/api-reference) endpoint. When
              false, no progress events are tracked. Note that progress tracking cannot be
              enabled after a run has been created. The flag is set to true by default for
              premium processors (pro and above). To enable this feature in your requests,
              specify `events-sse-2025-07-24` as one of the values in `parallel-beta` header
              (for API calls) or `betas` param (for the SDKs).

          mcp_servers: Optional list of MCP servers to use for the run. To enable this feature in your
              requests, specify `mcp-server-2025-07-17` as one of the values in
              `parallel-beta` header (for API calls) or `betas` param (for the SDKs).

          metadata: User-provided metadata stored with the run. Keys and values must be strings with
              a maximum length of 16 and 512 characters respectively.

          previous_interaction_id: Interaction ID to use as context for this request.

          source_policy: Source policy for web search results.

              This policy governs which sources are allowed/disallowed in results.

          task_spec: Specification for a task.

              Auto output schemas can be specified by setting `output_schema={"type":"auto"}`.
              Not specifying a TaskSpec is the same as setting an auto output schema.

              For convenience bare strings are also accepted as input or output schemas.

          webhook: Webhooks for Task Runs.

          betas: Optional header to specify the beta version(s) to enable.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        parallel-beta,c              3  4   K   | ]}t          |          V  d S NrM   .0es     r6   	<genexpr>z)TaskRunResource.create.<locals>.<genexpr>   (      4K4KSVV4K4K4K4K4K4Kr8   search-extract-2025-10-10/v1/tasks/runs?beta=true	rJ   rL   r>   r?   r@   rA   rB   rC   rD   rF   rG   rH   rI   bodyoptionscast_to)r   r   joinr   r   _postr   r!   TaskRunCreateParamsr#   r$   r5   rJ   rL   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   s                  r6   createzTaskRunResource.create=   s   R	
#&#SXXe4K4KU4K4K4KNiMj.k.k%l%l%l" 	
 "	
 )*E_-J][]_zz& "!*%2#. (/F%2!*&
 
 ':  )+Q[el   '  
 
 	
r8   ri   run_idStream[TaskRunEventsResponse]c          	         |st          d|          ddi|pi }ddi|pi }|                     d| dt          ||||          t          t          t
                    d	t          t
                   
          S )@  
        Streams events for a task run.

        Returns a stream of events showing progress updates and state changes for the
        task run.

        For task runs that did not have enable_events set to true during creation, the
        frequency of events will be reduced.

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        5Expected a non-empty value for `run_id` but received Accepttext/event-streamr\   rf   /v1beta/tasks/runs//eventsri   Trl   rm   stream
stream_cls)
ValueError_getr#   r
   r   r+   r   r5   rs   rF   rG   rH   rI   s         r6   eventszTaskRunResource.events   s    :  	a_U[__```!#6P=;NBP(*E_-J][]_yy1&111(+Q[el   34434  
 
 	
r8   api_timeoutrE   rF   rG   rH   rI   r   
int | Omitr)   c                  |st          d|          i t          dt          |          r.d                    t	          d |D             dg                    nt
          i          |pi }ddi|pi }|                     d| dt          ||||t          d|it          j
                  	          t          
          S )  
        Retrieves a run result by run_id, blocking until the run is completed.

        Args:
          betas: Optional header to specify the beta version(s) to enable.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        rw   r\   r]   c              3  4   K   | ]}t          |          V  d S r_   r`   ra   s     r6   rd   z)TaskRunResource.result.<locals>.<genexpr>   re   r8   rf   /v1/tasks/runs//result?beta=truer   rF   rG   rH   rI   queryrl   rm   )r   r   r   rn   r   r   r   r#   r   r"   TaskRunResultParamsr)   r5   rs   r   rE   rF   rG   rH   rI   s           r6   resultzTaskRunResource.result   s   6  	a_U[__```	
#&#SXXe4K4KU4K4K4KNiMj.k.k%l%l%l" 	
 "	
 )*E_-J][]_yy7f777(+'%%}k&BDZDnoo   &  

 

 
	
r8   )r0   r1   )r0   r9   rJ   rK   rL   rM   r>   rN   r?   rO   r@   rP   rA   rQ   rB   rR   rC   rS   rD   rT   rE   rU   rF   rV   rG   rW   rH   rX   rI   rY   r0   r$   )rs   rM   rF   rV   rG   rW   rH   rX   rI   rY   r0   rt   rs   rM   r   r   rE   rU   rF   rV   rG   rW   rH   rX   rI   rY   r0   r)   __name__
__module____qualname____doc__r   r7   r<   r   r   rr   r   r    r8   r6   r,   r,   #   s         4 4 4 _4 : : : _: 04AEHL8<7;481504 )-$("&;D%h
 h
 h
 h
 h
 h
` )-$("&;D)
 )
 )
 )
 )
 )
^ #'04 )-$("&;D2
 2
 2
 2
 2
 2
 2
 2
r8   c                      e Zd ZdZed0d            Zed1d            Zeeeeeeeedddedd2d&Z	ddded'd3d*Z
eeddded+d4d/ZdS )5r-   r/   r0   #AsyncTaskRunResourceWithRawResponsec                     t          |           S r3   )r   r4   s    r6   r7   z&AsyncTaskRunResource.with_raw_response  s     34888r8   )AsyncTaskRunResourceWithStreamingResponsec                     t          |           S r;   )r   r4   s    r6   r<   z,AsyncTaskRunResource.with_streaming_response  s     9>>>r8   Nr=   rJ   rK   rL   rM   r>   rN   r?   rO   r@   rP   rA   rQ   rB   rR   rC   rS   rD   rT   rE   rU   rF   rV   rG   rW   rH   rX   rI   rY   r$   c                 K   i t          dt          |
          r.d                    t          d |
D             dg                    nt          i          |pi }ddi|pi }|                     dt          |||||||||	d	t          j                   d{V t          ||||          t          	           d{V S )
r[   r\   r]   c              3  4   K   | ]}t          |          V  d S r_   r`   ra   s     r6   rd   z.AsyncTaskRunResource.create.<locals>.<genexpr>m  re   r8   rf   rg   rh   Nri   rj   )r   r   rn   r   r   ro   r   r!   rp   r#   r$   rq   s                  r6   rr   zAsyncTaskRunResource.create!  sF     R	
#&#SXXe4K4KU4K4K4KNiMj.k.k%l%l%l" 	
 "	
 )*E_-J][]_ZZ&,"!*%2#. (/F%2!*&
 
 ':        )+Q[el   '   
 
 
 
 
 
 
 
 	
r8   ri   rs   "AsyncStream[TaskRunEventsResponse]c          	       K   |st          d|          ddi|pi }ddi|pi }|                     d| dt          ||||          t          t          t
                    d	t          t
                   
           d{V S )rv   rw   rx   ry   r\   rf   rz   r{   ri   Tr|   N)r   r   r#   r
   r   r+   r    r   s         r6   r   zAsyncTaskRunResource.events  s      :  	a_U[__```!#6P=;NBP(*E_-J][]_YY1&111(+Q[el   344"#89  
 
 
 
 
 
 
 
 	
r8   r   r   r   r)   c                 K   |st          d|          i t          dt          |          r.d                    t	          d |D             dg                    nt
          i          |pi }ddi|pi }|                     d| dt          ||||t          d|it          j
                   d	{V 
          t                     d	{V S )r   rw   r\   r]   c              3  4   K   | ]}t          |          V  d S r_   r`   ra   s     r6   rd   z.AsyncTaskRunResource.result.<locals>.<genexpr>  re   r8   rf   r   r   r   Nr   r   )r   r   r   rn   r   r   r   r#   r   r"   r   r)   r   s           r6   r   zAsyncTaskRunResource.result  sS     6  	a_U[__```	
#&#SXXe4K4KU4K4K4KNiMj.k.k%l%l%l" 	
 "	
 )*E_-J][]_YY7f777(+'%1"K02H2\          &  
 
 
 
 
 
 
 
 	
r8   )r0   r   )r0   r   r   )rs   rM   rF   rV   rG   rW   rH   rX   rI   rY   r0   r   r   r   r   r8   r6   r-   r-     s         9 9 9 _9 ? ? ? _? 04AEHL8<7;481504 )-$("&;D%h
 h
 h
 h
 h
 h
` )-$("&;D)
 )
 )
 )
 )
 )
^ #'04 )-$("&;D4
 4
 4
 4
 4
 4
 4
 4
r8   c                      e Zd ZddZdS )r1   task_runr,   r0   Nonec                    || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        d S r_   )	_task_runr   rr   r   r   r5   r   s     r6   __init__z'TaskRunResourceWithRawResponse.__init__  sS    !-O
 
 .O
 
 .O
 
r8   Nr   r,   r0   r   r   r   r   r   r   r8   r6   r1   r1     (        
 
 
 
 
 
r8   r1   c                      e Zd ZddZdS )r   r   r-   r0   r   c                    || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        d S r_   )r   r   rr   r   r   r   s     r6   r   z,AsyncTaskRunResourceWithRawResponse.__init__  sS    !3O
 
 4O
 
 4O
 
r8   Nr   r-   r0   r   r   r   r8   r6   r   r     r   r8   r   c                      e Zd ZddZdS )r9   r   r,   r0   r   c                    || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        d S r_   )r   r   rr   r   r   r   s     r6   r   z-TaskRunResourceWithStreamingResponse.__init__  sS    !2O
 
 3O
 
 3O
 
r8   Nr   r   r   r8   r6   r9   r9     r   r8   r9   c                      e Zd ZddZdS )r   r   r-   r0   r   c                    || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        d S r_   )r   r   rr   r   r   r   s     r6   r   z2AsyncTaskRunResourceWithStreamingResponse.__init__  sS    !8O
 
 9O
 
 9O
 
r8   Nr   r   r   r8   r6   r   r     r   r8   r   )C
__future__r   typingr   r   r   r   r   r	   r
   	itertoolsr   httpx_typesr   r   r   r   r   r   r   _utilsr   r   r   r   _compatr   	_resourcer   r   	_responser   r   r   r   
_streamingr   r    
types.betar!   r"   _base_clientr#   types.task_runr$   types.task_spec_paramr%   types.beta.webhook_paramr&   types.beta.mcp_server_paramr'   types.beta.parallel_beta_paramr(   types.beta.beta_task_run_resultr)   !types.shared_params.source_policyr*   #types.beta.task_run_events_responser+   __all__r,   r-   r1   r   r9   r   r   r8   r6   <module>r      s   # " " " " " C C C C C C C C C C C C C C C C C C        K K K K K K K K K K K K K K K K K K W W W W W W W W W W W W & & & & & & : : : : : : : :            . - - - - - - - H H H H H H H H 0 0 0 0 0 0 % % % % % % 2 2 2 2 2 2 4 4 4 4 4 4 9 9 9 9 9 9 ? ? ? ? ? ? @ @ @ @ @ @ = = = = = = H H H H H H4
5a
 a
 a
 a
 a
o a
 a
 a
Hc
 c
 c
 c
 c
+ c
 c
 c
L
 
 
 
 
 
 
 

 
 
 
 
 
 
 

 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
r8   