U
    “öhC  ã                   @  s`   d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z
 G dd„ dejƒZG d	d
„ d
ƒZdS )z=Maintains set of LLM models that can be instantiated by name.é    )ÚannotationsN)ÚCallable)Ú
text_model)Úmodelc                   @  s   e Zd ZdZdZdS )Ú	ModelNameZechoÚtextN)Ú__name__Ú
__module__Ú__qualname__Ú
ECHO_MODELÚ
TEXT_MODEL© r   r   úO/tmp/pip-unpacked-wheel-doshhd5e/google/generativeai/notebook/model_registry.pyr      s   r   c                   @  s.   e Zd ZdZejZdd„ Zdddœdd„Zd	S )
ÚModelRegistryz-Registry that instantiates and caches models.c                 C  s    i | _ tjtjtjtji| _d S )N)	Ú_model_cacher   r   Ú	model_libZ	EchoModelr   r   Z	TextModelÚ_model_constructors)Úselfr   r   r   Ú__init__#   s      þþzModelRegistry.__init__r   zmodel_lib.AbstractModel)Ú
model_nameÚreturnc                 C  s&   || j kr| j| ƒ | j |< | j | S )a  Given `model_name`, return the corresponding Model instance.

    Model instances are cached and reused for the same `model_name`.

    Args:
      model_name: The name of the model.

    Returns:
      The corresponding model instance for `model_name`.
    )r   r   )r   r   r   r   r   Ú	get_model,   s    
zModelRegistry.get_modelN)	r   r	   r
   Ú__doc__r   r   ZDEFAULT_MODELr   r   r   r   r   r   r      s   	r   )r   Ú
__future__r   ÚenumÚtypingr   Zgoogle.generativeai.notebookr   Z google.generativeai.notebook.libr   r   ÚEnumr   r   r   r   r   r   Ú<module>   s   