
                            S r SSKJr  SSKJr  SSKJr  SSK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(                  R0                  \	R(                  R2                  5       " S S\5      5       5       rg)z/Vertex AI endpoints direct raw predict command.    )absolute_import)division)unicode_literalsN)client)base)	constants)endpoint_util)endpoints_util)flags)region_utilc                 x    [         R                  " U S[        R                  S9  [         R                  " U 5        g )Nz"to do online direct raw prediction)prompt_func)r   AddEndpointResourceArgr   PromptForOpRegionAddDirectRawPredictInputArgparsers    .lib/surface/ai/endpoints/direct_raw_predict.py_AddArgsr       s/    *//
 ##F+    c                    U R                   R                  R                  5       nUR                  5       S   U l        [
        R                  " XR                  SS9   [        R                  " US9n[        R                  " U R                  5      n[        R                  " US   5      R                  S5      US'   U[        R                   :X  a  UR#                  X$5      nOUR%                  X$5      n[        R                  " UR&                  5      Ul        U R)                  S5      (       d$  [        R*                  " UR&                  SS	9U l        UsS
S
S
5        $ ! , (       d  f       g
= f)z+Run Vertex AI online direct raw prediction.locationsIdT)regionis_prediction)versioninputzutf-8formatoutput)key_nameN)CONCEPTSendpointParseAsDictr   r	   AiplatformEndpointOverridesr   EndpointsClientr
   ReadInputFromArgsjson_requestbase64	b64decodedecoder   
GA_VERSIONDirectRawPredictDirectRawPredictBetar   IsSpecifiedGetDefaultFormatr   )argsr   endpoint_refendpoints_client
input_jsonresultss         r   _Runr5   )   s   ''--/,##%m4$+00kk --g>  11$2C2CDJ **:g+>?FFwOJw)&&& 11,Kg 55lOg %%gnn5GNH%%"33
..8dk -  s   C7E
E+c                   .    \ rS rSrSr\S 5       rS rSrg)DirectRawPredictGaF   aw  Run Vertex AI online direct raw prediction.

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

## EXAMPLES

To 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DirectRawPredictGa.ArgsW   s
    Vr   c                 6    [        U[        R                  5      $ r:   )r5   r   r+   selfr0   s     r   RunDirectRawPredictGa.Run[   s    i**++r    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr;   r@   __static_attributes__rB   r   r   r7   r7   F   s       ,r   r7   c                       \ rS rSrSrS rSrg)r-   _   a{  Run Vertex AI online direct raw prediction.

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

## EXAMPLES

To direct raw 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                 6    [        U[        R                  5      $ r:   )r5   r   BETA_VERSIONr>   s     r   r@   DirectRawPredictBeta.Runp   s    i,,--r   rB   N)rC   rD   rE   rF   rG   r@   rI   rB   r   r   r-   r-   _   s    .r   r-   )rG   
__future__r   r   r   r(   #googlecloudsdk.api_lib.ai.endpointsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.air   r	   r
   r   r   r   r5   UniverseCompatibleReleaseTracksReleaseTrackGACommandr7   BETAALPHAr-   rB   r   r   <module>rZ      s    6 &  '  6 ( 3 7 8 / 5,: D%%((), , * ,. D%%**D,=,=,C,CD.- . E .r   