
    d
                     V    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\5      r	g)	zTA library for streaming prediction results from the Vertex AI PredictionService API.    )absolute_import)division)unicode_literalsN)apisc                   *    \ rS rSrSrS rS rS rSrg)PredictionStreamer   z(Streams prediction responses using gRPC.c                 <    [         R                  " SU5      U l        g )N
aiplatform)r   GetGapicClientInstanceclient)selfversions     >lib/googlecloudsdk/api_lib/ai/endpoints/prediction_streamer.py__init__PredictionStreamer.__init__   s    --lGDDK    c              #      #    U R                   R                  R                  US9nU H_  nUR                  R	                  U R                   R                  R
                  R                  [        R                  " U5      5      5        Ma     U R                   R                  R
                  R                  [        R                  " U5      5      Ul	        U R                   R                  R                  [        U/5      5       H  nUv   M	     g7f)a  Streams prediction results from the Cloud Vertex AI PredictionService API.

Args:
  endpoint: The name of the endpoint to stream predictions from.
  inputs: The inputs to send to the endpoint.
  parameters: The parameters to send to the endpoint.

Yields:
  Streamed prediction results.
)endpointN)r   typesStreamDirectPredictRequestinputsappendTensor	from_jsonjsondumps
parameters
predictionstream_direct_predictiter)r   r   r   r   request
curr_inputr   s          r   StreamDirectPredict&PredictionStreamer.StreamDirectPredict    s     " kk::H:MG
nn
++


"
"
,
,TZZ
-C
D  **11;;

:G kk,,BBgY
 s   DDc              #      #    U R                   R                  R                  XUS9nU R                   R                  R	                  [        U/5      5       H  nUv   M	     g7f)a  Streams prediction results from the Cloud Vertex AI PredictionService API.

Args:
  endpoint: The name of the endpoint to stream predictions from.
  method_name: The name of the method to call.
  input: The input bytes to send to the endpoint.

Yields:
  Streamed prediction results.
)r   method_nameinputN)r   r   StreamDirectRawPredictRequestr   stream_direct_raw_predictr!   )r   r   r'   r(   r"   r   s         r   StreamDirectRawPredict)PredictionStreamer.StreamDirectRawPredict?   s]     " kk==% > G kk,,FFgY
 s   A A")r   N)	__name__
__module____qualname____firstlineno____doc__r   r$   r+   __static_attributes__ r   r   r   r      s    0E>r   r   )
r1   
__future__r   r   r   r   googlecloudsdk.api_lib.utilr   objectr   r3   r   r   <module>r7      s&    [ &  '  ,= =r   