o
    پi                     @   s   d dl mZ d dlmZmZ d dlmZmZ d dlm	Z	m
Z
 ee
 fde	defddZeee
 fde	fd	d
Zeee
 fdede	defddZdS )    )singledispatch)SequenceGeneratorAdapterVisionSequenceGeneratorAdapter)OpenAITransformersVision)Samplermultinomialsamplerreturnc                 C   s   t | d|S )a  Generate text with a `Transformer` model.

    Note
    ----
    Python 3.11 allows dispatching on Union types and
    this should greatly simplify the code.

    Arguments
    ---------
    model:
        An instance of `Transformer` that represents a model from the
        `transformers` library.
    sampler:
        The sampling algorithm to use to generate token ids from the logits
        distribution.

    Returns
    -------
    A `SequenceGeneratorAdapter` instance that generates text.

    N)r   modelr	    r   J/home/ubuntu/.local/lib/python3.10/site-packages/outlines/generate/text.pytext   s   r   c                 C   s   t | d |S )N)r   r   r   r   r   text_vision%   s   r   r   c                 C   s   t |ts	td| S )NzZThe OpenAI API does not support any other sampling algorithm than the multinomial sampler.)
isinstancer   NotImplementedErrorr   r   r   r   text_openai*   s
   
r   N)	functoolsr   outlines.generate.apir   r   outlines.modelsr   r   outlines.samplersr   r   r   registerr   r   r   r   r   r   <module>   s    "