
    _jk                    (   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
JrJr  S SKrS SKJr  SSK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K0J1r1  SSK2J3r3  SSK4J5r5  SSK6J7r7  SSK8J9r9J:r:J;r;  SSK<J=r=  SSK>J?r?  SSK@JArA  SSKBJCrDJErFJGrG  SSKHJIrI  SSKJJKrK  SSKLJMrM  SSKNJOrO  SS/rP " S S\$5      rQ " S S\%5      rR " S S 5      rS " S! S"5      rT " S# S$5      rU " S% S&5      rVg)'    )annotationsN)	AnyDictListTypeUnionIterableOptionalcastoverload)prepare_timeout_float   )task_run_create_paramstask_run_result_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)RunInput)WebhookParam)TaskRunResult)OutputTOutputSchemaTaskSpecParam)McpServerParam)build_task_spec_param)ParsedTaskRunResult)wait_for_resultwait_for_result_asynctask_run_result_parser)ParallelBetaParam)TaskRunEventsResponse)SourcePolicy)TaskAdvancedSettingsParamTaskRunResourceAsyncTaskRunResourcec                  j   \ 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SS\	S.                 SS jj5       r\\SSS\	S.                 SS jj5       r\\SSS\	S.                 S S jjrSrg)!r8   .     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    P/home/rurouni/.local/lib/python3.13/site-packages/parallel/resources/task_run.pywith_raw_response!TaskRunResource.with_raw_response<   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
)$TaskRunResourceWithStreamingResponser@   s    rB   with_streaming_response'TaskRunResource.with_streaming_responseF   s     4D99rE   Nadvanced_settingsenable_eventsmcp_serversmetadataprevious_interaction_idsource_policy	task_specwebhookbetasextra_headersextra_query
extra_bodytimeoutc                  0 [        S[        U5      (       a  SR                  S U 5       5      O[        05      E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     rB   	<genexpr>)TaskRunResource.create.<locals>.<genexpr>        8OAQ   /v1/tasks/runs
input	processorrL   rM   rN   rO   rP   rQ   rR   rS   rU   rV   rW   rX   bodyoptionscast_to)
r   r   joinr   _postr   r   TaskRunCreateParamsr&   r'   rA   rj   rk   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   s                   rB   createTaskRunResource.createO   s    P
S[\aSbSb8O8O0Ohqrs
"
 zz "!*):%2#. (/F%2!*& ':: )+Q[ )  
 	
rE   rl   c          
     x    U(       d  [        SU< 35      eU R                  [        SUS9[        X#XES9[        S9$ )U  
Retrieves run status by run_id.

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
5Expected a non-empty value for `run_id` but received /v1/tasks/runs/{run_id}run_idrl   ro   rp   
ValueError_getr   r&   r'   rA   r|   rU   rV   rW   rX   s         rB   retrieveTaskRunResource.retrieve   sP    2 TU[T^_``yy3FC(+Q[   
 	
rE   c          
         U(       d  [        SU< 35      e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
ry   Accepttext/event-stream/v1/tasks/runs/{run_id}/eventsr{   rl   Tro   rp   stream
stream_cls)r   r   r   r&   r   r   r5   r$   r   s         rB   eventsTaskRunResource.events   sy    : TU[T^_``!#6P=;NBPyy:6J(+Q[ 3434  
 	
rE   api_timeoutrT   rU   rV   rW   rX   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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
ry   r[   r\   c              3  8   #    U  H  n[        U5      v   M     g 7fr^   r_   ra   s     rB   rd   )TaskRunResource.result.<locals>.<genexpr>  rf   rg   /v1/tasks/runs/{run_id}/resultr{   r   rU   rV   rW   rX   queryr}   )r   r   r   rq   r   r   r   r&   r   r   TaskRunResultParamsr*   rA   r|   r   rT   rU   rV   rW   rX   s           rB   resultTaskRunResource.result   s    6 TU[T^_``
S[\aSbSb8O8O0Ohqrs
"
 yy:6J(+'%%}k&BDZDnDno "  

 
	
rE   c          
     x    U(       d  [        SU< 35      eU R                  [        SUS9[        X#XES9[        S9$ )#  
Retrieves the input of a run by run_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
ry   /v1/tasks/runs/{run_id}/inputr{   rl   r}   r   r   r   r&   r(   r   s         rB   retrieve_inputTaskRunResource.retrieve_input,  sP    . TU[T^_``yy9&I(+Q[   
 	
rE   outputrU   rV   rW   c               8   ^ ^^^^ SUUUUU 4S jjn[        XUS9$ )9Wait for a task run to complete within the given timeout.c                r   > U[         R                  " 5       -
  nTR                  U TTTUS9n[        UT5      $ Nrl   time	monotonicr   r3   	r|   deadlinerX   task_run_resultrW   rU   rV   r   rA   s	       rB   _fetcher2TaskRunResource._wait_for_result.<locals>._fetcher[  sE    !11G"kk+'% * O */6BBrE   r|   r   callabler|   r`   r   floatreturn,TaskRunResult | ParsedTaskRunResult[OutputT])_wait_for_resultrA   r|   r   r   rU   rV   rW   r   s   `  ```` rB   r    TaskRunResource._wait_for_resultM  s    		C 		C  v8TTrE   rO   r   rU   rV   rW   rX   c                   g r^    	rA   rj   rk   rO   r   rU   rV   rW   rX   s	            rB   executeTaskRunResource.executeh  s     rE   rO   rU   rV   rW   rX   c                   g r^   r   r   s	            rB   r   r   w  s     (+rE   c                   SS0U=(       d    0 En[        U5      n[        R                  " 5       U-   n	U R                  UUU[	        XA5      UUUUS9n
U R                  U
R                  U	UUUUS9$ )  
Convenience method to create and execute a task run in a single call.

Awaits run completion. If the run is successful, a `ParsedTaskRunResult`
is returned when a pydantic was specified in `output`. Otherwise, a
`TaskRunResult` is returned.

Possible errors:
- `TimeoutError`: If the run does not finish within the specified timeout.
- `APIStatusError`: If the API returns a non-200-range status code.
- `APIConnectionError`: If the connection to the API fails.

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

  processor: Processor to use for the task.

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

  output: Optional output schema or pydantic type. If pydantic is provided,
    the response will have a parsed field.

  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.
    If the result is not available within the timeout, a `TimeoutError` is raised.
X-Stainless-Poll-Helpertruerj   rk   rO   rR   rU   rV   rW   rX   r|   r   r   rU   rV   rW   r   r   r   ru   r/   r   r|   rA   rj   rk   rO   r   rU   rV   rW   rX   r   task_runs              rB   r   r     s    \ 3FT}?RPRT'0>>#g-;;+F:'#!  	
 $$??'#! % 
 	
rE   r   )r   r?   )r   rH    rj   Union[str, Dict[str, object]]rk   r`   rL   z*Optional[TaskAdvancedSettingsParam] | OmitrM   zOptional[bool] | OmitrN   z)Optional[Iterable[McpServerParam]] | OmitrO   3Optional[Dict[str, Union[str, float, bool]]] | OmitrP   zOptional[str] | OmitrQ   zOptional[SourcePolicy] | OmitrR   zOptional[TaskSpecParam] | OmitrS   zOptional[WebhookParam] | OmitrT   List[ParallelBetaParam] | OmitrU   Headers | NonerV   Query | NonerW   Body | NonerX   'float | httpx.Timeout | None | NotGivenr   r'   r|   r`   rU   r   rV   r   rW   r   rX   r   r   r'   )r|   r`   rU   r   rV   r   rW   r   rX   r   r   zStream[TaskRunEventsResponse]r|   r`   r   z
int | OmitrT   r   rU   r   rV   r   rW   r   rX   r   r   r*   r|   r`   rU   r   rV   r   rW   r   rX   r   r   r(   r|   r`   r   r   r   -Optional[OutputSchema] | Type[OutputT] | OmitrU   r   rV   r   rW   r   r   r   rj   r   rk   r`   rO   r   r   zOptional[OutputSchema] | OmitrU   r   rV   r   rW   r   rX   r   r   r*   rj   r   rk   r`   rO   r   r   zType[OutputT]rU   r   rV   r   rW   r   rX   r   r   zParsedTaskRunResult[OutputT]rj   r   rk   r`   rO   r   r   r   rU   r   rV   r   rW   r   rX   r   r   r   __name__
__module____qualname____firstlineno____doc__r   rC   rI   r   r   ru   r   r   r   r   r   r   r   __static_attributes__r   rE   rB   r8   r8   .   sa    4 4 : : IM/3AEHL8<7;481504 )-$("&;D'a
 -a
 	a

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

 .+
 &+
 "+
  +
 9+
 
+
f )-$("&;D

 &
 "
  
 9
 

L AE )-$("&U U 	U
 >U &U "U  U 
6U6  IM04 )-$("&;D - 	
 F . & "   9 
   IM )-$("&;D+ -+ 	+
 F+ + &+ "+  + 9+ 
&+ +& IM@D )-$("&;DE
 -E
 	E

 FE
 >E
 &E
 "E
  E
 9E
 
6E
 E
rE   c                  j   \ 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SS\	S.                 SS jj5       r\\SSS\	S.                 SS jj5       r\\SSS\	S.                 S S jjrSrg)!r9   i  r<   c                    [        U 5      $ r>   )#AsyncTaskRunResourceWithRawResponser@   s    rB   rC   &AsyncTaskRunResource.with_raw_response  s     3488rE   c                    [        U 5      $ rG   ))AsyncTaskRunResourceWithStreamingResponser@   s    rB   rI   ,AsyncTaskRunResource.with_streaming_response  s     9>>rE   NrK   c               @  #    0 [        S[        U5      (       a  SR                  S U 5       5      O[        05      E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)	rZ   r[   r\   c              3  8   #    U  H  n[        U5      v   M     g 7fr^   r_   ra   s     rB   rd   .AsyncTaskRunResource.create.<locals>.<genexpr>7  rf   rg   rh   ri   Nrl   rm   )
r   r   rq   r   rr   r   r   rs   r&   r'   rt   s                   rB   ru   AsyncTaskRunResource.create  s     P
S[\aSbSb8O8O0Ohqrs
"
 ZZ,"!*):%2#. (/F%2!*& '::  )+Q[ )   
 
 	

s$   A;B=B
>BBBBrl   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)rx   ry   rz   r{   rl   r}   Nr~   r   s         rB   r   AsyncTaskRunResource.retrieveQ  s]     2 TU[T^_``YY3FC(+Q[   
 
 	
 
   ?AAAc          
        #    U(       d  [        SU< 35      e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)
r   ry   r   r   r   r{   rl   Tr   N)r   r   r   r&   r   r   r5   r%   r   s         rB   r   AsyncTaskRunResource.eventst  s     : TU[T^_``!#6P=;NBPYY:6J(+Q[ 34"#89  
 
 	
 
s   A)A2+A0,A2r   c               n  #    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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   ry   r[   r\   c              3  8   #    U  H  n[        U5      v   M     g 7fr^   r_   ra   s     rB   rd   .AsyncTaskRunResource.result.<locals>.<genexpr>  rf   rg   r   r{   r   Nr   r}   )r   r   r   rq   r   r   r   r&   r   r   r   r*   r   s           rB   r   AsyncTaskRunResource.result  s     6 TU[T^_``
S[\aSbSb8O8O0Ohqrs
"
 YY:6J(+'%1"K02H2\2\  "  
 
 	

s$   BB5B1B5,B3-B53B5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)r   ry   r   r{   rl   r}   Nr   r   s         rB   r   #AsyncTaskRunResource.retrieve_input  s]     . TU[T^_``YY9&I(+Q[   
 
 	
 
r   r   c               T   ^ ^^^^#    SUUUUU 4S jjn[        XUS9I Sh  vN $  N7f)r   c                   >#    U[         R                  " 5       -
  nTR                  U TTTUS9I S h  vN n[        UT5      $  N7fr   r   r   s	       rB   r   7AsyncTaskRunResource._wait_for_result.<locals>._fetcher  sR     !11G$(KK+'% %0 % O */6BBs   /AAAr   Nr   )_wait_for_result_asyncr   s   `  ```` rB   r   %AsyncTaskRunResource._wait_for_result  s(     		C 		C ,6W_````s   (&(r   c                  #    g 7fr^   r   r   s	            rB   r   AsyncTaskRunResource.execute	  s
         r   c                  #    g 7fr^   r   r   s	            rB   r   r     s
      (+r   c                 #    SS0U=(       d    0 En[        U5      n[        R                  " 5       U-   n	U R                  UUU[	        XA5      UUUUS9I Sh  vN n
U R                  U
R                  U	UUUUS9I Sh  vN $  N* N7f)r   r   r   r   Nr   r   r   s              rB   r   r   #  s     \ 3FT}?RPRT'0>>#g-+F:'#! % 	
 	
 **??'#! + 
 
 	
	

s$   ABB%B=B>BBr   )r   r   )r   r   r   r   )r|   r`   rU   r   rV   r   rW   r   rX   r   r   z"AsyncStream[TaskRunEventsResponse]r   r   r   r   r   r   r   r   rE   rB   r9   r9     s]    9 9 ? ? IM/3AEHL8<7;481504 )-$("&;D'a
 -a
 	a

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

 .-
 &-
 "-
  -
 9-
 
-
j )-$("&;D

 &
 "
  
 9
 

L AE )-$("&a a 	a
 >a &a "a  a 
6a6  IM04(,$("&;D - 	
 F . & "   9 
   IM(,$("&;D+ -+ 	+
 F+ + &+ "+  + 9+ 
&+ +" IM@D )-$("&;DE
 -E
 	E

 FE
 >E
 &E
 "E
  E
 9E
 
6E
 E
rE   c                      \ rS rSrSS jrSrg)r?   ij  c                   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        g r^   )	_task_runr    ru   r   r   r   r   rA   r   s     rB   __init__'TaskRunResourceWithRawResponse.__init__k  ss    !-OO
 0
 .OO
 .OO
 6##
rE   r  ru   r   r   r   r   Nr   r8   r   Noner   r   r   r   r  r   r   rE   rB   r?   r?   j      
rE   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        [        UR
                  5      U l        [        UR                  5      U l        g r^   )r  r"   ru   r   r   r   r   r  s     rB   r  ,AsyncTaskRunResourceWithRawResponse.__init__  ss    !3OO
 6
 4OO
 4OO
 <##
rE   r  Nr   r9   r   r  r	  r   rE   rB   r   r     r
  rE   r   c                      \ rS rSrSS jrSrg)rH   i  c                   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        g r^   )r  r!   ru   r   r   r   r   r  s     rB   r  -TaskRunResourceWithStreamingResponse.__init__  ss    !2OO
 5
 3OO
 3OO
 ;##
rE   r  Nr  r	  r   rE   rB   rH   rH     r
  rE   rH   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        [        UR
                  5      U l        [        UR                  5      U l        g r^   )r  r#   ru   r   r   r   r   r  s     rB   r  2AsyncTaskRunResourceWithStreamingResponse.__init__  st    !8OO
 ;
 9OO
 9OO
 A##
rE   r  Nr  r	  r   rE   rB   r   r     r
  rE   r   )W
__future__r   r   typingr   r   r   r   r   r	   r
   r   r   httpxparallel.lib._timer   typesr   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.run_inputr(   types.webhook_paramr)   types.task_run_resultr*   types.task_spec_paramr+   r,   r-   types.mcp_server_paramr.   lib._parsing._task_specr/   types.parsed_task_run_resultr0   lib._parsing._task_run_resultr1   r   r2   r   r3   types.beta.parallel_beta_paramr4   types.task_run_events_responser5   !types.shared_params.source_policyr6   "types.task_advanced_settings_paramr7   __all__r8   r9   r?   r   rH   r   r   rE   rB   <module>r/     s    #  S S S  4 B J J J e e % 9  - / $ & . 1 H H 3 ; > 
 ? B < J4
5]
o ]
~[
+ [
z
 
*
 
*
 
*
 
rE   