
    _j                       S SK J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  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.  SSK/J0r0  SSK1J2r2  SSK3J4r4  SSK5J6r6  SSK7J8r8  SSK9J:r:  SSK;J<r<  SSK=J>r>  SS/r? " S S\#5      r@ " S S\$5      rA " S S5      rB " S S5      rC " S S5      rD " S  S!5      rEg)"    )annotations)AnyDictListUnionIterableOptionalcast)LiteralN   )task_group_create_paramstask_group_events_paramstask_group_add_runs_paramstask_group_get_runs_params)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)make_request_options)TaskRun)	TaskGroup)RunInputParam)TaskSpecParam)TaskGroupRunResponse)ParallelBetaParam)TaskGroupEventsResponse)TaskGroupGetRunsResponseTaskGroupResourceAsyncTaskGroupResourcec            	         \ rS rSrSr\SS j5       r\SS j5       r\SSS\	S.           SS jjr
SSS\	S.           SS	 jjr\\\SSS\	S
.                   SS jjr\\SSS\	S.               SS jjr\\\\SSS\	S.                   SS jjrSSS\	S.             SS jj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
) TaskGroupResourceWithRawResponseselfs    R/home/rurouni/.local/lib/python3.13/site-packages/parallel/resources/task_group.pywith_raw_response#TaskGroupResource.with_raw_response6   s     055    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
)&TaskGroupResourceWithStreamingResponser7   s    r9   with_streaming_response)TaskGroupResource.with_streaming_response@   s     6d;;r<   Nmetadataextra_headersextra_query
extra_bodytimeoutc               r    U R                  S[        SU0[        R                  5      [	        X#XES9[
        S9$ )s  
Initiates a TaskGroup to group and track multiple runs.

Args:
  metadata: User-provided metadata stored with the task group.

  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
/v1/tasks/groupsrC   rD   rE   rF   rG   bodyoptionscast_to)_postr   r   TaskGroupCreateParamsr&   r(   r8   rC   rD   rE   rF   rG   s         r9   createTaskGroupResource.createI   sF    2 zz *h!79Q9g9gh(+Q[   
 	
r<   rK   c          
     x    U(       d  [        SU< 35      eU R                  [        SUS9[        X#XES9[        S9$ )3  
Retrieves aggregated status across runs in a TaskGroup.

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
<Expected a non-empty value for `task_group_id` but received  /v1/tasks/groups/{task_group_id}task_group_idrK   rN   rO   
ValueError_getr   r&   r(   r8   rZ   rD   rE   rF   rG   s         r9   retrieveTaskGroupResource.retrievek   sP    . [\i[lmnnyy<MZ(+Q[   
 	
r<   refresh_statusdefault_task_specbetasrD   rE   rF   rG   c               v   U(       d  [        SU< 35      e0 [        S[        U5      (       a  SR                  S U 5       5      O[        05      EU=(       d    0 EnU R                  [        SUS9[        UUS.[        R                  5      [        UUUU	[        SU0[        R                  5      S	9[        S
9$ )J  
Initiates multiple task runs within a TaskGroup.

Args:
  inputs: List of task runs to execute. Up to 1,000 runs can be specified per request. If
      you'd like to add more runs, split them across multiple TaskGroup POST requests.

  default_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.

  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   parallel-beta,c              3  8   #    U  H  n[        U5      v   M     g 7fNstr.0es     r9   	<genexpr>-TaskGroupResource.add_runs.<locals>.<genexpr>        8OAQ   %/v1/tasks/groups/{task_group_id}/runsrY   inputsrd   rc   rD   rE   rF   rG   queryrL   )r]   r   r   joinr   rP   r   r   r   TaskGroupAddRunsParamsr&   r+   
r8   rZ   rw   rc   rd   re   rD   rE   rF   rG   s
             r9   add_runsTaskGroupResource.add_runs   s    N [\i[lmnn
S[\aSbSb8O8O0Ohqrs
"
 zzAQ^_ $): +AA )+'%%%~68R8i8i )%  
 	
r<   last_event_idapi_timeoutrD   rE   rF   rG   c                  U(       d  [        SU< 35      eSS0U=(       d    0 EnU R                  [        SUS9[        UUUU[	        UUS.[
        R                  5      S9[        [        [        5      S[        [           S	9$ )
  
Streams events from a TaskGroup: status updates and run completions.

The connection will remain open for up to an hour as long as at least one run in
the group is still active.

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
rW   Accepttext/event-stream'/v1/tasks/groups/{task_group_id}/eventsrY   r   r   rx   TrN   rO   stream
stream_cls)r]   r^   r   r&   r   r   TaskGroupEventsParamsr
   r   r-   r$   r8   rZ   r   r   rD   rE   rF   rG   s           r9   eventsTaskGroupResource.events   s    8 [\i[lmnn!#6P=;NBPyyCS`a(+'%%)6'2 -BB , 56'  
 	
r<   include_inputinclude_outputr   statusrD   rE   rF   rG   c                  U(       d  [        SU< 35      eSS0U=(       d    0 EnU R                  [        SUS9[        UUUU	[	        UUUUS.[
        R                  5      S9[        [        [        5      S[        [           S	9$ )
  
Retrieves task runs in a TaskGroup and optionally their inputs and outputs.

All runs within a TaskGroup are returned as a stream. To get the inputs and/or
outputs back in the stream, set the corresponding `include_input` and
`include_output` parameters to `true`.

The stream is resumable using the `event_id` as the cursor. To resume a stream,
specify the `last_event_id` parameter with the `event_id` of the last event in
the stream. The stream will resume from the next event after the
`last_event_id`.

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
rW   r   r   ru   rY   r   r   r   r   rx   Tr   )r]   r^   r   r&   r   r   TaskGroupGetRunsParamsr
   r   r.   r$   
r8   rZ   r   r   r   r   rD   rE   rF   rG   s
             r9   get_runsTaskGroupResource.get_runs  s    N [\i[lmnn!#6P=;NBPyyAQ^_(+'%%)6*8)6"(	 /EE - 67+  
 	
r<   c          
         U(       d  [        SU< 35      eU(       d  [        SU< 35      eU R                  [        SX!S9[        X4XVS9[        S9$ )  
Retrieves run status by run_id.

This endpoint is equivalent to fetching run status directly using the
`retrieve()` method or the `tasks/runs` GET endpoint.

The run result is available from the `/result` endpoint.

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
rW   5Expected a non-empty value for `run_id` but received ./v1/tasks/groups/{task_group_id}/runs/{run_id}rZ   run_idrK   r[   r]   r^   r   r&   r'   r8   r   rZ   rD   rE   rF   rG   s          r9   retrieve_runTaskGroupResource.retrieve_runE  si    : [\i[lmnnTU[T^_``yyJZgw(+Q[   
 	
r<    )returnr6   )r   r?   rC   z3Optional[Dict[str, Union[str, float, bool]]] | OmitrD   Headers | NonerE   Query | NonerF   Body | NonerG   'float | httpx.Timeout | None | NotGivenr   r(   rZ   rm   rD   r   rE   r   rF   r   rG   r   r   r(   rZ   rm   rw   zIterable[RunInputParam]rc   bool | Omitrd   zOptional[TaskSpecParam] | Omitre   zList[ParallelBetaParam] | OmitrD   r   rE   r   rF   r   rG   r   r   r+   )rZ   rm   r   Optional[str] | Omitr   Optional[float] | OmitrD   r   rE   r   rF   r   rG   r   r   zStream[TaskGroupEventsResponse])rZ   rm   r   r   r   r   r   r   r   rOptional[Literal['queued', 'action_required', 'running', 'completed', 'failed', 'cancelling', 'cancelled']] | OmitrD   r   rE   r   rF   r   rG   r   r   z Stream[TaskGroupGetRunsResponse]r   rm   rZ   rm   rD   r   rE   r   rF   r   rG   r   r   r'   __name__
__module____qualname____firstlineno____doc__r   r:   r@   r   r   rS   r`   r}   r   r   r   __static_attributes__r   r<   r9   r/   r/   (   s    6 6 < < IM )-$("&;D 
 F 
 & 
 " 
   
 9 
 
 
P )-$("&;D

 &
 "
  
 9
 

L '+<@04 )-$("&;D@
@
 (	@

 $@
 :@
 .@
 &@
 "@
  @
 9@
 
@
L /3.2 )-$("&;D3
3
 ,	3

 ,3
 &3
 "3
  3
 93
 
)3
r &*&*.2  )-$("&;D!@
@
 #	@

 $@
 ,@
@
 &@
 "@
  @
  9!@
" 
*#@
R )-$("&;D'
'
 	'
 &'
 "'
  '
 9'
 
'
 '
r<   c            	         \ rS rSrSr\SS j5       r\SS j5       r\SSS\	S.           SS jjr
SSS\	S.           SS	 jjr\\\SSS\	S
.                   SS jjr\\SSS\	S.               SS jjr\\\\SSS\	S.                   SS jjrSSS\	S.             SS jjrSrg)r0   io  r3   c                    [        U 5      $ r5   )%AsyncTaskGroupResourceWithRawResponser7   s    r9   r:   (AsyncTaskGroupResource.with_raw_response}  s     5T::r<   c                    [        U 5      $ r>   )+AsyncTaskGroupResourceWithStreamingResponser7   s    r9   r@   .AsyncTaskGroupResource.with_streaming_response  s     ;4@@r<   NrB   c                  #    U R                  S[        SU0[        R                  5      I Sh  vN [	        X#XES9[
        S9I Sh  vN $  N N7f)rI   rJ   rC   NrK   rL   )rP   r   r   rQ   r&   r(   rR   s         r9   rS   AsyncTaskGroupResource.create  sY     2 ZZ,j(-CE]EsEstt(+Q[    
 
 	
t
s!   ,AA
AAAArK   c          
        #    U(       d  [        SU< 35      eU R                  [        SUS9[        X#XES9[        S9I Sh  vN $  N7f)rV   rW   rX   rY   rK   r[   Nr\   r_   s         r9   r`   AsyncTaskGroupResource.retrieve  s]     . [\i[lmnnYY<MZ(+Q[   
 
 	
 
s   ?AAArb   c                 #    U(       d  [        SU< 35      e0 [        S[        U5      (       a  SR                  S U 5       5      O[        05      EU=(       d    0 EnU R                  [        SUS9[        UUS.[        R                  5      I Sh  vN [        UUUU	[        S	U0[        R                  5      I Sh  vN S
9[        S9I Sh  vN $  NA N N7f)rg   rW   rh   ri   c              3  8   #    U  H  n[        U5      v   M     g 7frk   rl   rn   s     r9   rq   2AsyncTaskGroupResource.add_runs.<locals>.<genexpr>  rs   rt   ru   rY   rv   Nrc   rx   rL   )r]   r   r   rz   r   rP   r   r   r   r{   r&   r+   r|   s
             r9   r}   AsyncTaskGroupResource.add_runs  s     N [\i[lmnn
S[\aSbSb8O8O0Ohqrs
"
 ZZAQ^_,$): +AA  )+'%1%~68R8i8i  )%   
 
 	

s6   BCC
+C?C CCCCCr   c               8  #    U(       d  [        SU< 35      eSS0U=(       d    0 EnU R                  [        SUS9[        UUUU[	        UUS.[
        R                  5      I Sh  vN S9[        [        [        5      S	[        [           S
9I Sh  vN $  N0 N7f)r   rW   r   r   r   rY   r   Nrx   Tr   )r]   r^   r   r&   r   r   r   r
   r   r-   r%   r   s           r9   r   AsyncTaskGroupResource.events  s     8 [\i[lmnn!#6P=;NBPYYCS`a(+'%1)6'2 -BB  , "#:;'  
 
 	

s$   A#B%B&+BBBBr   c               <  #    U(       d  [        SU< 35      eSS0U=(       d    0 EnU R                  [        SUS9[        UUUU	[	        UUUUS.[
        R                  5      I Sh  vN S9[        [        [        5      S	[        [           S
9I Sh  vN $  N0 N7f)r   rW   r   r   ru   rY   r   Nrx   Tr   )r]   r^   r   r&   r   r   r   r
   r   r.   r%   r   s
             r9   r   AsyncTaskGroupResource.get_runsJ  s     N [\i[lmnn!#6P=;NBPYYAQ^_(+'%1)6*8)6"(	 /EE  - "#;<+  
 
 	

s$   A%B'B(+BBBBc          
        #    U(       d  [        SU< 35      eU(       d  [        SU< 35      eU R                  [        SX!S9[        X4XVS9[        S9I Sh  vN $  N7f)r   rW   r   r   r   rK   r[   Nr   r   s          r9   r   #AsyncTaskGroupResource.retrieve_run  sv     : [\i[lmnnTU[T^_``YYJZgw(+Q[   
 
 	
 
s   AAAAr   )r   r   )r   r   r   r   r   )rZ   rm   r   r   r   r   rD   r   rE   r   rF   r   rG   r   r   z$AsyncStream[TaskGroupEventsResponse])rZ   rm   r   r   r   r   r   r   r   r   rD   r   rE   r   rF   r   rG   r   r   z%AsyncStream[TaskGroupGetRunsResponse]r   r   r   r<   r9   r0   r0   o  s    ; ; A A IM )-$("&;D 
 F 
 & 
 " 
   
 9 
 
 
P )-$("&;D

 &
 "
  
 9
 

L '+<@04 )-$("&;D@
@
 (	@

 $@
 :@
 .@
 &@
 "@
  @
 9@
 
@
L /3.2 )-$("&;D3
3
 ,	3

 ,3
 &3
 "3
  3
 93
 
.3
r &*&*.2  )-$("&;D!@
@
 #	@

 $@
 ,@
@
 &@
 "@
  @
  9!@
" 
/#@
R )-$("&;D'
'
 	'
 &'
 "'
  '
 9'
 
'
 '
r<   c                      \ rS rSrSS jrSrg)r6   i  c                H   Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        [        UR
                  5      U l        [        UR                  5      U l        [        UR                  5      U l        g rk   )_task_groupr    rS   r`   r}   r   r   r   r8   
task_groups     r9   __init__)TaskGroupResourceWithRawResponse.__init__  s    %-
 0
 0
 .
 0
 4##
r<   r   r}   rS   r   r   r`   r   Nr   r/   r   Noner   r   r   r   r   r   r   r<   r9   r6   r6         
r<   r6   c                      \ rS rSrSS jrSrg)r   i  c                H   Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        [        UR
                  5      U l        [        UR                  5      U l        [        UR                  5      U l        g rk   )r   r"   rS   r`   r}   r   r   r   r   s     r9   r   .AsyncTaskGroupResourceWithRawResponse.__init__  s    %3
 6
 6
 4
 6
 :##
r<   r   Nr   r0   r   r   r   r   r<   r9   r   r     r   r<   r   c                      \ rS rSrSS jrSrg)r?   i  c                H   Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        [        UR
                  5      U l        [        UR                  5      U l        [        UR                  5      U l        g rk   )r   r!   rS   r`   r}   r   r   r   r   s     r9   r   /TaskGroupResourceWithStreamingResponse.__init__  s    %2
 5
 5
 3
 5
 9##
r<   r   Nr   r   r   r<   r9   r?   r?     r   r<   r?   c                      \ rS rSrSS jrSrg)r   i  c                H   Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        [        UR
                  5      U l        [        UR                  5      U l        [        UR                  5      U l        g rk   )r   r#   rS   r`   r}   r   r   r   r   s     r9   r   4AsyncTaskGroupResourceWithStreamingResponse.__init__  s    %8
 ;
 ;
 9
 ;
 ?##
r<   r   Nr   r   r   r<   r9   r   r     r   r<   r   )F
__future__r   typingr   r   r   r   r   r	   r
   typing_extensionsr   httpxtypesr   r   r   r   _typesr   r   r   r   r   r   r   _utilsr   r   r   r   r   _compatr   	_resourcer   r   	_responser    r!   r"   r#   
_streamingr$   r%   _base_clientr&   types.task_runr'   types.task_groupr(   types.run_input_paramr)   types.task_spec_paramr*   types.task_group_run_responser+   types.beta.parallel_beta_paramr,    types.task_group_events_responser-   "types.task_group_get_runs_responser.   __all__r/   r0   r6   r   r?   r   r   r<   r9   <module>r      s    # C C C %   K J J e e % 9  - / $ ( 1 1 @ > F I 8
9D
 D
N
D
- D
N

 
0
 
0
 
0
 
r<   