
    dh_	                     L    S SK JrJr  S SKJr  S SKJrJr  Sr " S S\\5      r	g)    )AnyList)
Embeddings)	BaseModel
ConfigDictzBhttps://tfhub.dev/google/universal-sentence-encoder-multilingual/3c                      ^  \ rS rSr% SrSr\\S'   \r	\
\S'    S\4U 4S jjr\" SS	S
9rS\\
   S\\\      4S jrS\
S\\   4S jrSrU =r$ )TensorflowHubEmbeddings	   ac  TensorflowHub embedding models.

To use, you should have the ``tensorflow_text`` python package installed.

Example:
    .. code-block:: python

        from langchain_community.embeddings import TensorflowHubEmbeddings
        url = "https://tfhub.dev/google/universal-sentence-encoder-multilingual/3"
        tf = TensorflowHubEmbeddings(model_url=url)
Nembed	model_urlkwargsc                    > [         TU ]  " S0 UD6   SSKn SSKnUR                  U R                  5      U l        g! [         a    [        S5      ef = f! [         a    [        S5      ef = f)z2Initialize the tensorflow_hub and tensorflow_text.r   NzeCould not import tensorflow-hub python package. Please install it with `pip install tensorflow-hub``.zgCould not import tensorflow_text python package. Please install it with `pip install tensorflow_text``. )super__init__tensorflow_hubImportErrortensorflow_textloadr   r   )selfr   r   r   	__class__s       e/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/embeddings/tensorflow_hub.pyr    TensorflowHubEmbeddings.__init__   s    "6"	!	" $((8
  	H 	  	I 	s   = A AA,forbidr   )extraprotected_namespacestextsreturnc                     [        [        S U5      5      nU R                  U5      R                  5       nUR	                  5       $ )zCompute doc embeddings using a TensorflowHub embedding model.

Args:
    texts: The list of texts to embed.

Returns:
    List of embeddings, one for each text.
c                 &    U R                  SS5      $ )N
 )replace)xs    r   <lambda>9TensorflowHubEmbeddings.embed_documents.<locals>.<lambda><   s    199T3#7    )listmapr   numpytolist)r   r   
embeddingss      r   embed_documents'TensorflowHubEmbeddings.embed_documents3   s<     S7?@ZZ&,,.
  ""r'   textc                     UR                  SS5      nU R                  U/5      R                  5       S   nUR                  5       $ )zCompute query embeddings using a TensorflowHub embedding model.

Args:
    text: The text to embed.

Returns:
    Embeddings for the text.
r!   r"   r   )r#   r   r*   r+   )r   r/   	embeddings      r   embed_query#TensorflowHubEmbeddings.embed_query@   sA     ||D#&JJv&,,.q1	!!r'   )r   )__name__
__module____qualname____firstlineno____doc__r   r   __annotations__DEFAULT_MODEL_URLr   strr   r   model_configr   floatr-   r2   __static_attributes____classcell__)r   s   @r   r	   r	   	   s{    
 E3&Is&9 9( L
#T#Y #4U3D #" "U " "r'   r	   N)
typingr   r   langchain_core.embeddingsr   pydanticr   r   r:   r	   r   r'   r   <module>rC      s$     0 *X B"i B"r'   