
                            S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSKJ
r
  S	 rS
 r\R                  \R                  " \R                  R                   5       " S S\R"                  5      5       5       r\R                  \R                  " \R                  R&                  \R                  R(                  5       " S S\5      5       5       rg)z2Vertex AI endpoints stream direct predict command.    )prediction_streamer)base)	constants)endpoint_util)endpoints_util)flags)region_utilc                 x    [         R                  " U S[        R                  S9  [         R                  " U 5        g )Nz%to do online stream direct prediction)prompt_func)r   AddEndpointResourceArgr	   PromptForOpRegionAddDirectPredictInputsArgparsers    1lib/surface/ai/endpoints/stream_direct_predict.py_AddArgsr      s/    -//
 !!&)    c           	      N   U R                   R                  R                  5       nUR                  5       S   U l        [
        R                  " XR                  SS9   [        R                  " U R                  5      nU[        R                  :X  a  [        R                  " S5      nO[        R                  " S5      nU R                  S5      (       d  SU l        UR!                  UR#                  5       US   UR%                  S	0 5      S
9sSSS5        $ ! , (       d  f       g= f)z.Run Vertex AI online stream direct prediction.locationsIdT)regionis_predictionv1v1beta1formatjsoninputs
parameters)endpointr   r   N)CONCEPTSr   ParseAsDictr   r   AiplatformEndpointOverridesr   ReadInputsFromArgsjson_requestr   
GA_VERSIONr   PredictionStreamerIsSpecifiedr   StreamDirectPredictRelativeNameget)argsversionendpoint_refinputs_jsonstreamers        r   _Runr0   $   s    ''--/,##%m4$+00kk !33D4E4EFK)&&&$77=h$77	BhH%%dk''**,8$??<4 (   s   B0D
D$c                   .    \ rS rSrSr\S 5       rS rSrg)StreamDirectPredictGa;     Run Vertex AI online stream direct prediction.

   `{command}` sends a stream direct prediction request to Vertex AI endpoint
   for the given inputs. The request limit is 10MB.

## EXAMPLES

To stream direct predict against an endpoint ``123'' under project ``example''
in region ``us-central1'', run:

  $ {command} 123 --project=example --region=us-central1
  --json-request=input.json
c                     [        U 5        g N)r   r   s    r   ArgsStreamDirectPredictGa.ArgsL   s
    Vr   c                 6    [        U[        R                  5      $ r6   )r0   r   r%   selfr+   s     r   RunStreamDirectPredictGa.RunP   s    i**++r    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr7   r<   __static_attributes__r>   r   r   r2   r2   ;   s       ,r   r2   c                       \ rS rSrSrS rSrg)StreamDirectPredictBetaT   r4   c                 6    [        U[        R                  5      $ r6   )r0   r   BETA_VERSIONr:   s     r   r<   StreamDirectPredictBeta.Rune   s    i,,--r   r>   N)r?   r@   rA   rB   rC   r<   rE   r>   r   r   rG   rG   T   s    .r   rG   N)rC   #googlecloudsdk.api_lib.ai.endpointsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.air   r   r   r   r	   r   r0   UniverseCompatibleReleaseTracksReleaseTrackGACommandr2   BETAALPHArG   r>   r   r   <module>rV      s    9 D ( 3 7 8 / 5*. D%%((),DLL , * ,. D%%**D,=,=,C,CD.3 . E .r   