
    rh                        d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 e	j                  Zeeee   f   Zeee	j                  f   Zd	dZ	 	 	 	 d
dZddZy)z'Utilities for handling input variables.    )annotations)AnyMappingSequenceUnion)llmfn_inputs_sourcec                    t        | t              sy| j                         D ]6  }t        |t              s yt        |t              st        |t
              s6 y y)a*  See if inputs is of the form: {"key1": ["val1", "val2", ...]}.

    This is similar to the format produced by:
      pandas.DataFrame.to_dict(orient="list")

    Args:
      inputs: The inputs passed into an LLMFunction.

    Returns:
      Whether `inputs` is a column-ordered list of values.
    FT)
isinstancer   valuesr   strbytes)inputsxs     /var/www/html/ai-insurance-compliance-backend/venv/lib/python3.12/site-packages/google/generativeai/notebook/lib/llmfn_input_utils.py_is_column_order_values_listr      sP     fg&]]_ !X& aAu!5     c                    g }t        | j                               }|rF|d   }t        t        | |               D ]'  }i }|j	                  |       |D ]  }| |   |   ||<    ) |S )z5Transforms prompt inputs into a list of dictionaries.r   )listkeysrangelenappend)r   return_listr   	first_keyrow_numrow_dictkeys          r   #_normalize_column_order_values_listr   8   s     )+KDG	S	!234 	5GHx( 5 &sG 45	5
 r   c                    g }t        | t        j                        r!|j                  | j	                                |S t        |       r|j                  t        |              |S t        dj                  |             )zFHandles the different types of `inputs` and returns a normalized form.zUnsupported input type {!r})	r
   r   LLMFnInputsSourceextendto_normalized_inputsr   r   
ValueErrorformat)r   normalized_inputss     r   r"   r"   H   sw    13&-??@  !<!<!>?
 	 
&f	-  !DV!LM  6==fEFFr   N)r   r   returnbool)r   _ColumnOrderValuesListr&   _NormalizedInputsList)r   LLMFunctionInputsr&   r)   )__doc__
__future__r   typingr   r   r   r    google.generativeai.notebook.libr   NormalizedInputsListr)   r   r(   r    r*   r   r   r"    r   r   <module>r1      so    . " 0 0 @ ,@@  hsm!34 02E2W2WWX 4" 	r   