U
    h
                     @  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ddZddd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                      s4   e Zd ZdZdd fddZd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.
  z(llmfn_inputs_source.NormalizedInputsList)normalized_inputsc                   s   t    || _d S N)super__init___normalized_inputs)selfr
   	__class__ L/tmp/pip-unpacked-wheel-doshhd5e/google/generativeai/notebook/input_utils.pyr   &   s    
z _NormalizedInputsSource.__init__zCtuple[llmfn_inputs_source.NormalizedInputsList, Callable[[], None]])returnc                 C  s   | j dd fS )Nc                   S  s   d S r   r   r   r   r   r   <lambda>/       zD_NormalizedInputsSource._to_normalized_inputs_impl.<locals>.<lambda>)r   )r   r   r   r   _to_normalized_inputs_impl,   s    z2_NormalizedInputsSource._to_normalized_inputs_impl)__name__
__module____qualname____doc__r   r   __classcell__r   r   r   r   r	      s   r	   strz%llmfn_inputs_source.LLMFnInputsSource)var_namer   c                 C  s,   t | }t|tjr|S t|}t|S r   )r   Z
get_py_var
isinstancer   LLMFnInputsSourcer   to_normalized_inputsr	   )r   datar
   r   r   r   get_inputs_source_from_py_var2   s
    

r#   Fzparsed_args_lib.ParsedArgsbool)parsed_argssuppress_status_msgsr   c                 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!   Zsheets_input_namesr	   )r%   r&   Zcombined_inputssourcer   r   r   join_inputs_sources=   s    



r*   N)F)r   
__future__r   typingr   r   Zgoogle.generativeai.notebookr   r   Z google.generativeai.notebook.libr   r   r    r	   r#   r*   r   r   r   r   <module>   s    