U
    ”Ê¹j¹  ã                   @   sd   d dl mZmZmZmZ d dlmZmZ ddlm	Z	m
Z
mZmZ G dd„ de	ƒZG dd„ deƒZd	S )
é    )ÚAnyÚDictÚOptionalÚUnion)ÚRequestParametersÚ_as_dicté   )ÚBaseConversationalTaskÚInferenceProviderMappingÚTaskProviderHelperÚfilter_nonec                       s   e Zd Z‡ fdd„Z‡  ZS )ÚScalewayConversationalTaskc                    s   t ƒ jddd� d S )NÚscalewayúhttps://api.scaleway.ai)ÚproviderÚbase_url©ÚsuperÚ__init__©Úself©Ú	__class__© úl/var/www/html/bwave/python/venv/lib/python3.8/site-packages/huggingface_hub/inference/_providers/scaleway.pyr   	   s    z#ScalewayConversationalTask.__init__)Ú__name__Ú
__module__Ú__qualname__r   Ú__classcell__r   r   r   r   r      s   r   c                       sf   e Zd Z‡ fdd„Zeeedœdd„Zeeee	e dœdd„Z
deeef e	e ed
œdd„Z‡  ZS )ÚScalewayFeatureExtractionTaskc                    s   t ƒ jdddd� d S )Nr   r   zfeature-extraction)r   r   Útaskr   r   r   r   r   r      s    z&ScalewayFeatureExtractionTask.__init__)Úmapped_modelÚapi_keyÚreturnc                 C   s   dS )Nz/v1/embeddingsr   )r   r!   r"   r   r   r   Ú_prepare_route   s    z,ScalewayFeatureExtractionTask._prepare_route)ÚinputsÚ
parametersÚprovider_mapping_infor#   c                 C   s   t |ƒ}||jdœ|–S )N)ÚinputÚmodel)r   Zprovider_id)r   r%   r&   r'   r   r   r   Ú_prepare_payload_as_dict   s    z6ScalewayFeatureExtractionTask._prepare_payload_as_dictN)ÚresponseÚrequest_paramsr#   c                 C   s   t |ƒd }dd„ |D ƒS )NÚdatac                 S   s   g | ]}|d  ‘qS )Ú	embeddingr   )Ú.0r.   r   r   r   Ú
<listcomp>   s     z>ScalewayFeatureExtractionTask.get_response.<locals>.<listcomp>)r   )r   r+   r,   Z
embeddingsr   r   r   Úget_response   s    z*ScalewayFeatureExtractionTask.get_response)N)r   r   r   r   Ústrr$   r   r   r
   r   r*   r   Úbytesr   r1   r   r   r   r   r   r      s     þr   N)Útypingr   r   r   r   Z!huggingface_hub.inference._commonr   r   Z_commonr	   r
   r   r   r   r   r   r   r   r   Ú<module>   s   