U
    h                     @  s   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl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S )zThe compile command.    )annotations)Sequence)command)command_utils)ipython_env)model_registry)parsed_args_lib)post_process_utils)py_utilsc                      sN   e Zd ZdZdddd fddZdd	d
d	dddZdd
dddZ  ZS )CompileCommandz(Implementation of the "compile" command.Nzmodel_registry.ModelRegistryzipython_env.IPythonEnv | None)modelsenvc                   s   t    || _|| _dS )ziConstructor.

    Args:
      models: ModelRegistry instance.
      env: The IPythonEnv environment.
    N)super__init___models_ipython_env)selfr   r   	__class__ L/tmp/pip-unpacked-wheel-doshhd5e/google/generativeai/notebook/compile_cmd.pyr      s    
zCompileCommand.__init__zparsed_args_lib.ParsedArgsstrz2Sequence[post_process_utils.ParsedPostProcessExpr])parsed_argscell_contentpost_processing_fnsreturnc                 C  s2   t j| j| j|||d}t|j| d|jS )N)r   r   r   r   r   z%Saved function to Python variable: {})r   Zcreate_llm_functionr   r   r
   Z
set_py_varZcompile_save_nameformat)r   r   r   r   Zllm_fnr   r   r   execute.   s    zCompileCommand.executezSequence[Sequence[str]])tokensr   c                 C  s
   t |S )N)r	   Zresolve_post_processing_tokens)r   r   r   r   r   parse_post_processing_tokensA   s    z+CompileCommand.parse_post_processing_tokens)N)__name__
__module____qualname____doc__r   r   r   __classcell__r   r   r   r   r      s
    r   N)r#   
__future__r   typingr   Zgoogle.generativeai.notebookr   r   r   r   r   r	   r
   Commandr   r   r   r   r   <module>   s   