
                            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S	K	Jr  SS
K	Jr  SSK	Jr  SSKJr  S r\R$                  " \R&                  R(                  5      \R*                   " S S\R,                  5      5       5       r\R$                  " \R&                  R0                  \R&                  R2                  5      \R*                   " S S\5      5       5       rg)z$Vertex AI endpoints explain command.    )absolute_import)division)unicode_literals)client)base)	constants)endpoint_util)endpoints_util)flags)region_util)logc                    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U[        R                  :X  a  UR                  X$U 5      nOUR                  X$U 5      n[!        US5      b8  ["        R$                  R'                  SR)                  UR*                  5      5        U R-                  S5      (       d  [        R.                  " US	S
9U l        UsSSS5        $ ! , (       d  f       g= f)z!Run Vertex AI online explanation.locationsIdT)regionis_prediction)versiondeployedModelIdNz0Deployed model id to be used for explanation: {}formatexplanations)key_name)CONCEPTSendpointParseAsDictr   r	   AiplatformEndpointOverridesr   EndpointsClientr
   ReadInstancesFromArgsjson_requestr   
GA_VERSIONExplainExplainBetagetattrr   statusPrintr   r   IsSpecifiedGetDefaultFormat)argsr   endpoint_refendpoints_clientinstances_jsonresultss         #lib/surface/ai/endpoints/explain.py_Runr-      s   ''--/,##%m4$+00kk7--g>#99$:K:KLN)&&& ((tLg ,,\4Pgw)*6	jj
<
C
C%%'( H%%"33
N,dk%7 7 7s   C$E


Ec                   .    \ rS rSrSr\S 5       rS rSrg)	ExplainGa8     Request an online explanation from an Vertex AI endpoint.

`{command}` sends an explanation request to the Vertex AI endpoint for
the given instances. This command reads up to 100 instances, though the
service itself accepts instances up to the payload limit size
(currently, 1.5MB).

## EXAMPLES

To send an explanation request to the endpoint for the json file,
input.json, run:

$ {command} ENDPOINT_ID --region=us-central1 --json-request=input.json
c                     [         R                  " U S[        R                  S9  [         R                  " U 5        [         R
                  " SS9R                  U 5        g )Nz to request an online explanation)prompt_funcF)required)r   AddEndpointResourceArgr   PromptForOpRegionAddPredictInstanceArgGetDeployedModelIdAddToParser)parsers    r,   ArgsExplainGa.ArgsJ   sH    	  *113 
'	e,88@    c                 6    [        U[        R                  5      $ N)r-   r   r   selfr'   s     r,   RunExplainGa.RunS   s    i**++r=    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr;   rB   __static_attributes__rD   r=   r,   r/   r/   8   s"     A A,r=   r/   c                       \ rS rSrSrS rSrg)r!   W   r1   c                 6    [        U[        R                  5      $ r?   )r-   r   BETA_VERSIONr@   s     r,   rB   ExplainBeta.Runi   s    i,,--r=   rD   N)rE   rF   rG   rH   rI   rB   rK   rD   r=   r,   r!   r!   W   s    .r=   r!   N)rI   
__future__r   r   r   #googlecloudsdk.api_lib.ai.endpointsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.air   r	   r
   r   r   googlecloudsdk.corer   r-   ReleaseTracksReleaseTrackGAUniverseCompatibleCommandr/   BETAALPHAr!   rD   r=   r,   <module>r]      s    + &  ' 6 ( 3 7 8 / 5 #2 D%%((), ,  *,: D%%**D,=,=,C,CD.) .  E.r=   