o
    j6h                     @  s~   d Z ddlmZ ddlmZmZ ddlmZ ddlmZ ddl	m
Z
 ddl	mZ G dd	 d	ejZdddZ	ddddZdS )z'Utilities for handling input variables.    )annotations)CallableMapping)parsed_args_lib)py_utils)llmfn_input_utils)llmfn_inputs_sourcec                      s,   e Zd ZdZd
 fddZddd	Z  ZS )_NormalizedInputsSourcea  Wrapper around NormalizedInputsList.

    By design LLMFunction does not take NormalizedInputsList as input because
    NormalizedInputsList is an internal representation so we want to minimize
    exposure to the caller.

    When we have inputs already in normalized format (e.g. from
    join_prompt_inputs()) we can wrap it as an LLMFnInputsSource to pass as an
    input to LLMFunction.
    normalized_inputs(llmfn_inputs_source.NormalizedInputsListc                   s   t    || _d S N)super__init___normalized_inputs)selfr
   	__class__ w/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/google/generativeai/notebook/input_utils.pyr   &   s   

z _NormalizedInputsSource.__init__returnCtuple[llmfn_inputs_source.NormalizedInputsList, Callable[[], None]]c                 C  s   | j dd fS )Nc                   S  s   d S r   r   r   r   r   r   <lambda>-   s    zD_NormalizedInputsSource._to_normalized_inputs_impl.<locals>.<lambda>)r   )r   r   r   r   _to_normalized_inputs_impl*   s   z2_NormalizedInputsSource._to_normalized_inputs_impl)r
   r   )r   r   )__name__
__module____qualname____doc__r   r   __classcell__r   r   r   r   r	      s    r	   var_namestrr   %llmfn_inputs_source.LLMFnInputsSourcec                 C  s,   t | }t|tjr|S t|}t|S r   )r   
get_py_var
isinstancer   LLMFnInputsSourcer   to_normalized_inputsr	   )r   datar
   r   r   r   get_inputs_source_from_py_var0   s
   

r&   Fparsed_argsparsed_args_lib.ParsedArgssuppress_status_msgsboolc                 C  sH   g }| j D ]}||j|d q| jD ]}||j|d qt|S )z5Get a single combined input source from `parsed_args.)r)   )inputsextendr$   sheets_input_namesr	   )r'   r)   combined_inputssourcer   r   r   join_inputs_sources;   s   



r0   N)r   r   r   r    )F)r'   r(   r)   r*   r   r    )r   
__future__r   typingr   r   google.generativeai.notebookr   r    google.generativeai.notebook.libr   r   r#   r	   r&   r0   r   r   r   r   <module>   s   
