
                            d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 ddl
mZ dd	l
mZ dd
l
mZ ddl
mZ ddl
mZ d Zd Ze	j$                   e	j&                  e	j(                  j*                         G d de	j,                                      Ze	j$                   e	j&                  e	j(                  j0                  e	j(                  j2                         G d de                    Zy)z/Vertex AI endpoints direct raw predict command.    )absolute_import)division)unicode_literalsN)client)base)	constants)endpoint_util)endpoints_util)flags)region_utilc                 z    t        j                  | dt        j                         t        j                  |        y )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                    | j                   j                  j                         }|j                         d   | _        t        j                  || j                  d      5  t        j                  |      }t        j                  | j                        }t        j                  |d         j                  d      |d<   |t        j                   k(  r|j#                  ||      }n|j%                  ||      }t        j                  |j&                        |_        | j)                  d      s&t        j*                  |j&                  d	      | _        |cd
d
d
       S # 1 sw Y   y
xY w)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dkk --g>  11$2C2CDJ **:g+>?FFwOJw)&&& 11,
Kg 55lJOg %%gnn5GNH%"33
..8dk -  s   C4EE&c                   &    e Zd ZdZed        Zd Zy)DirectRawPredictGaa  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                     t        |        y N)r   r   s    r   ArgszDirectRawPredictGa.ArgsW   s
    Vr   c                 6    t        |t        j                        S r9   )r5   r   r+   selfr0   s     r   RunzDirectRawPredictGa.Run[   s    i**++r   N)__name__
__module____qualname____doc__staticmethodr:   r>    r   r   r7   r7   F   s       ,r   r7   c                       e Zd ZdZd Zy)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    t        |t        j                        S r9   )r5   r   BETA_VERSIONr<   s     r   r>   zDirectRawPredictBeta.Runp   s    i,,--r   N)r?   r@   rA   rB   r>   rD   r   r   r-   r-   _   s    .r   r-   )rB   
__future__r   r   r   r(   #googlecloudsdk.api_lib.ai.endpointsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.air   r	   r
   r   r   r   r5   DefaultUniverseOnlyReleaseTracksReleaseTrackGACommandr7   BETAALPHAr-   rD   r   r   <module>rS      s    6 &  '  6 ( 3 7 8 / 5,: D%%((), , * ,. D%%**D,=,=,C,CD.- . E .r   