
    _j^d                       S SK Jr  S SKrS SKJrJrJrJrJrJ	r	J
r
  S SKJr  S SKrSSKJrJrJrJrJrJrJr  SSKJrJrJrJrJr  SSKJr  SS	KJrJ r   SS
K!J"r"J#r#J$r$J%r%  SSK&J'r'J(r(  SSK)J*r*J+r+  SSK,J-r-  SSK.J/r/  SSK0J1r1  SSK2J3r3  SSK4J5r5  SSK6J7r7  SSK8J9r9  SSK:J;r;  SSK<J=r=  SSK>J?r?  SS/r@ " S S\5      rA " S S\ 5      rB " S S5      rC " S S5      rD " S S 5      rE " S! S"5      rFg)#    )annotationsN)AnyDictListUnionIterableOptionalcast)chain   )BodyOmitQueryHeadersNotGivenomit	not_given)is_givenpath_template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)WebhookParam)TaskRunResult)TaskSpecParam)McpServerParam)ParallelBetaParam)SourcePolicy)TaskAdvancedSettingsParam)TaskRunEventsResponseTaskRunResourceAsyncTaskRunResourcec                     \ rS rSrSr\SS j5       r\SS j5       r\R                  " S5      \
\
\
\
\
\
\
\
\
SSS\S.                               SS jj5       r\R                  " S5      SSS\S	.           SS
 jj5       r\R                  " S5      \
\
SSS\S.               SS jj5       rSrg)r.   %     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

Task Groups enable batch execution of many independent Task runs with group-level monitoring and failure handling.
- Submit hundreds or thousands of Tasks as a single group
- Observe group progress and receive results as they complete
- Real-time updates via Server-Sent Events (SSE)
- Add tasks to an existing group while it is running
- Group-level retry and error aggregation
c                    [        U 5      $ z
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
)TaskRunResourceWithRawResponseselfs    U/home/rurouni/.local/lib/python3.13/site-packages/parallel/resources/beta/task_run.pywith_raw_response!TaskRunResource.with_raw_response3   s     .d33    c                    [        U 5      $ 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
)$TaskRunResourceWithStreamingResponser6   s    r8   with_streaming_response'TaskRunResource.with_streaming_response=   s     4D99r;   Use GA Task Run insteadNadvanced_settingsenable_eventsmcp_serversmetadataprevious_interaction_idsource_policy	task_specwebhookbetasextra_headersextra_query
extra_bodytimeoutc               D   0 [        S[        U5      (       a#  SR                  [        S U 5       S/5      5      O[        05      EU=(       d    0 EnSS0U=(       d    0 EnU R                  S[        UUUUUUUUU	U
S.
[        R                  5      [        XXS9[        S9$ )	)  
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.

  advanced_settings: Advanced search configuration for a task run.

  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://docs.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).

  mcp_servers: Optional list of MCP servers to use for the run.

  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  8   #    U  H  n[        U5      v   M     g 7fNstr.0es     r8   	<genexpr>)TaskRunResource.create.<locals>.<genexpr>        4KUSVVU   search-extract-2025-10-10/v1/tasks/runs
input	processorrC   rD   rE   rF   rG   rH   rI   rJ   rL   rM   rN   rO   bodyoptionscast_to)r   r   joinr   r   _postr   r"   TaskRunCreateParamsr$   r%   r7   rb   rc   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   s                   r8   createTaskRunResource.createF   s    R	
# &)XXe4KU4KNiMj.k%l"	
 "	
 )*E_-J][]_zz "!*):%2#. (/F%2!*& ':: )+Q[ )  
 	
r;   rd   c          
         U(       d  [        SU< 35      eSS0U=(       d    0 EnSS0U=(       d    0 EnU R                  [        SUS9[        X#XES9[	        [
        [        5      S	[        [           S
9$ )  
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-streamrR   r_   "/v1beta/tasks/runs/{run_id}/eventsrun_idrd   Trg   rh   stream
stream_cls)
ValueError_getr   r$   r
   r   r-   r    r7   rv   rL   rM   rN   rO   s         r8   eventsTaskRunResource.events   s    < TU[T^_``!#6P=;NBP(*E_-J][]_yy>vN(+Q[ 3434  
 	
r;   api_timeoutrK   rL   rM   rN   rO   c               r   U(       d  [        SU< 35      e0 [        S[        U5      (       a#  SR                  [	        S U 5       S/5      5      O[
        05      EU=(       d    0 EnSS0U=(       d    0 EnU R                  [        SUS9[        UUUU[        SU0[        R                  5      S	9[        S
9$ )  
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
rq   rR   rS   c              3  8   #    U  H  n[        U5      v   M     g 7frU   rV   rX   s     r8   r[   )TaskRunResource.result.<locals>.<genexpr>   r]   r^   r_   /v1/tasks/runs/{run_id}/resultru   r   rL   rM   rN   rO   queryrg   rh   )rz   r   r   ri   r   r   r{   r   r$   r   r#   TaskRunResultParamsr'   r7   rv   r   rK   rL   rM   rN   rO   s           r8   resultTaskRunResource.result   s    8 TU[T^_``	
# &)XXe4KU4KNiMj.k%l"	
 "	
 )*E_-J][]_yy:6J(+'%%}k&BDZDnDno "  

 
	
r;    )returnr5   )r   r>    rb   zUnion[str, Dict[str, object]]rc   rW   rC   z*Optional[TaskAdvancedSettingsParam] | OmitrD   zOptional[bool] | OmitrE   z)Optional[Iterable[McpServerParam]] | OmitrF   z3Optional[Dict[str, Union[str, float, bool]]] | OmitrG   zOptional[str] | OmitrH   zOptional[SourcePolicy] | OmitrI   zOptional[TaskSpecParam] | OmitrJ   zOptional[WebhookParam] | OmitrK   List[ParallelBetaParam] | OmitrL   Headers | NonerM   Query | NonerN   Body | NonerO   'float | httpx.Timeout | None | NotGivenr   r%   )rv   rW   rL   r   rM   r   rN   r   rO   r   r   zStream[TaskRunEventsResponse]rv   rW   r   z
int | OmitrK   r   rL   r   rM   r   rN   r   rO   r   r   r'   __name__
__module____qualname____firstlineno____doc__r   r9   r?   typing_extensions
deprecatedr   r   rm   r}   r   __static_attributes__r   r;   r8   r.   r.   %   s    4 4 : : !!";< IM/3AEHL8<7;481504 )-$("&;D'h
 -h
 	h

 Fh
 -h
 ?h
 Fh
 "6h
 5h
 2h
 /h
 .h
  &!h
" "#h
$  %h
& 9'h
( 
)h
 =h
T !!";< )-$("&;D)
)
 &)
 ")
  )
 9)
 
')
 =)
V !!";<
 #'04 )-$("&;D2
2
  	2

 .2
 &2
 "2
  2
 92
 
2
 =2
r;   c                     \ rS rSrSr\SS j5       r\SS j5       r\R                  " S5      \
\
\
\
\
\
\
\
\
SSS\S.                               SS jj5       r\R                  " S5      SSS\S	.           SS
 jj5       r\R                  " S5      \
\
SSS\S.               SS jj5       rSrg)r/   i  r2   c                    [        U 5      $ r4   )#AsyncTaskRunResourceWithRawResponser6   s    r8   r9   &AsyncTaskRunResource.with_raw_response!  s     3488r;   c                    [        U 5      $ r=   ))AsyncTaskRunResourceWithStreamingResponser6   s    r8   r?   ,AsyncTaskRunResource.with_streaming_response+  s     9>>r;   rA   NrB   c               t  #    0 [        S[        U5      (       a#  SR                  [        S U 5       S/5      5      O[        05      EU=(       d    0 EnSS0U=(       d    0 EnU R                  S[        UUUUUUUUU	U
S.
[        R                  5      I Sh  vN [        XXS9[        S	9I Sh  vN $  N N7f)
rQ   rR   rS   c              3  8   #    U  H  n[        U5      v   M     g 7frU   rV   rX   s     r8   r[   .AsyncTaskRunResource.create.<locals>.<genexpr>  r]   r^   r_   r`   ra   Nrd   re   )r   r   ri   r   r   rj   r   r"   rk   r$   r%   rl   s                   r8   rm   AsyncTaskRunResource.create4  s     R	
# &)XXe4KU4KNiMj.k%l"	
 "	
 )*E_-J][]_ZZ,"!*):%2#. (/F%2!*& '::  )+Q[ )   
 
 	

s$   BB8B4
B8/B60B86B8rd   c          
       #    U(       d  [        SU< 35      eSS0U=(       d    0 EnSS0U=(       d    0 EnU R                  [        SUS9[        X#XES9[	        [
        [        5      S	[        [           S
9I Sh  vN $  N7f)rp   rq   rr   rs   rR   r_   rt   ru   rd   Trw   N)rz   r{   r   r$   r
   r   r-   r!   r|   s         r8   r}   AsyncTaskRunResource.events  s     < TU[T^_``!#6P=;NBP(*E_-J][]_YY>vN(+Q[ 34"#89  
 
 	
 
s   A8B:A?;Br   c                 #    U(       d  [        SU< 35      e0 [        S[        U5      (       a#  SR                  [	        S U 5       S/5      5      O[
        05      EU=(       d    0 EnSS0U=(       d    0 EnU R                  [        SUS9[        UUUU[        SU0[        R                  5      I S	h  vN S
9[        S9I S	h  vN $  N N7f)r   rq   rR   rS   c              3  8   #    U  H  n[        U5      v   M     g 7frU   rV   rX   s     r8   r[   .AsyncTaskRunResource.result.<locals>.<genexpr>  r]   r^   r_   r   ru   r   Nr   r   )rz   r   r   ri   r   r   r{   r   r$   r   r#   r   r'   r   s           r8   r   AsyncTaskRunResource.result  s     8 TU[T^_``	
# &)XXe4KU4KNiMj.k%l"	
 "	
 )*E_-J][]_YY:6J(+'%1"K02H2\2\  "  
 
 	

s$   B3C5C6CCCCr   )r   r   )r   r   r   )rv   rW   rL   r   rM   r   rN   r   rO   r   r   z"AsyncStream[TaskRunEventsResponse]r   r   r   r;   r8   r/   r/     s    9 9 ? ? !!";< IM/3AEHL8<7;481504 )-$("&;D'h
 -h
 	h

 Fh
 -h
 ?h
 Fh
 "6h
 5h
 2h
 /h
 .h
  &!h
" "#h
$  %h
& 9'h
( 
)h
 =h
T !!";< )-$("&;D)
)
 &)
 ")
  )
 9)
 
,)
 =)
V !!";<
 #'04 )-$("&;D4
4
  	4

 .4
 &4
 "4
  4
 94
 
4
 =4
r;   c                      \ rS rSrSS jrSrg)r5   i  c                    Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        g rU   )	_task_runr   rm   r}   r   r7   task_runs     r8   __init__'TaskRunResourceWithRawResponse.__init__  sO    ! $ 	 $ 	 $ 	r;   r   rm   r}   r   Nr   r.   r   Noner   r   r   r   r   r   r   r;   r8   r5   r5         
r;   r5   c                      \ rS rSrSS jrSrg)r   i  c                    Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        g rU   )r   r   rm   r}   r   r   s     r8   r   ,AsyncTaskRunResourceWithRawResponse.__init__  sO    ! * 	 * 	 * 	r;   r   Nr   r/   r   r   r   r   r;   r8   r   r     r   r;   r   c                      \ rS rSrSS jrSrg)r>   i-  c                    Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        g rU   )r   r   rm   r}   r   r   s     r8   r   -TaskRunResourceWithStreamingResponse.__init__.  sO    ! ) 	 ) 	 ) 	r;   r   Nr   r   r   r;   r8   r>   r>   -  r   r;   r>   c                      \ rS rSrSS jrSrg)r   iB  c                    Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        g rU   )r   r   rm   r}   r   r   s     r8   r   2AsyncTaskRunResourceWithStreamingResponse.__init__C  sO    ! / 	 / 	 / 	r;   r   Nr   r   r   r;   r8   r   r   B  r   r;   r   )G
__future__r   r   typingr   r   r   r   r   r	   r
   	itertoolsr   httpx_typesr   r   r   r   r   r   r   _utilsr   r   r   r   r   _compatr   	_resourcer   r   	_responser   r   r   r   
_streamingr    r!   
types.betar"   r#   _base_clientr$   types.task_runr%   types.webhook_paramr&   types.task_run_resultr'   types.task_spec_paramr(   types.mcp_server_paramr)   types.beta.parallel_beta_paramr*   !types.shared_params.source_policyr+   "types.task_advanced_settings_paramr,   #types.beta.task_run_events_responser-   __all__r.   r/   r5   r   r>   r   r   r;   r8   <module>r      s    #  C C C   K K K f f & :  . H 0 % / 2 2 4 ? = K H4
5k
o k
\m
+ m
`
 
*
 
*
 
*
 
r;   