
    BTh                     >    d dl mZ d dlmZ d dlmZ  G d de      Zy)    )List)
Embeddings)EmbeddingsTestsc                   P    e Zd ZdZdeddfdZdeddfdZdeddfdZdeddfdZy)	EmbeddingsIntegrationTestsa  Base class for embeddings integration tests.

    Test subclasses must implement the ``embeddings_class`` property to specify the
    embeddings model to be tested. You can also override the
    ``embedding_model_params`` property to specify initialization parameters.

    Example:

    .. code-block:: python

        from typing import Type

        from langchain_tests.integration_tests import EmbeddingsIntegrationTests
        from my_package.embeddings import MyEmbeddingsModel


        class TestMyEmbeddingsModelIntegration(EmbeddingsIntegrationTests):
            @property
            def embeddings_class(self) -> Type[MyEmbeddingsModel]:
                # Return the embeddings model class to test here
                return MyEmbeddingsModel

            @property
            def embedding_model_params(self) -> dict:
                # Return initialization parameters for the model.
                return {"model": "model-001"}

    .. note::
          API references for individual test methods include troubleshooting tips.
    modelreturnNc                     |j                  d      }t        |t              sJ t        |d   t              sJ |j                  d      }t	        |      dkD  sJ t	        |      t	        |      k(  sJ y)a,  Test embedding a string query.

        .. dropdown:: Troubleshooting

            If this test fails, check that:

            1. The model will generate a list of floats when calling ``.embed_query`` on a string.
            2. The length of the list is consistent across different inputs.
        foor   barN)embed_query
isinstancer   floatlenselfr   embedding_1embedding_2s       ~/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/langchain_tests/integration_tests/embeddings.pytest_embed_queryz+EmbeddingsIntegrationTests.test_embed_query(   ss     ''.+t,,,+a.%000''.;!###;3{#3333    c                    g d}|j                  |      t              t        |      k(  sJ t        d D              sJ t        d D              sJ t        d         dkD  sJ t        fdD              sJ y)a,  Test embedding a list of strings.

        .. dropdown:: Troubleshooting

            If this test fails, check that:

            1. The model will generate a list of lists of floats when calling ``.embed_documents`` on a list of strings.
            2. The length of each list is the same.
        r   r   bazc              3   <   K   | ]  }t        |t                y wNr   r   .0	embeddings     r   	<genexpr>zBEmbeddingsIntegrationTests.test_embed_documents.<locals>.<genexpr>J        K9:i.K   c              3   B   K   | ]  }t        |d    t                ywr   Nr   r   r   s     r   r!   zBEmbeddingsIntegrationTests.test_embed_documents.<locals>.<genexpr>K        Oy:ilE2O   r   c              3   R   K   | ]  }t        |      t        d          k(     ywr%   r   r   r    
embeddingss     r   r!   zBEmbeddingsIntegrationTests.test_embed_documents.<locals>.<genexpr>M   #     TI3y>SA%77T   $'N)embed_documentsr   allr   r   	documentsr,   s      @r   test_embed_documentsz/EmbeddingsIntegrationTests.test_embed_documents<   s     *	**95
:#i.000K
KKKKOJOOOO:a=!A%%%TTTTTr   c                   K   |j                  d       d{   }t        |t              sJ t        |d   t              sJ |j                  d       d{   }t	        |      dkD  sJ t	        |      t	        |      k(  sJ y7 n7 0w)a3  Test embedding a string query async.

        .. dropdown:: Troubleshooting

            If this test fails, check that:

            1. The model will generate a list of floats when calling ``.aembed_query`` on a string.
            2. The length of the list is consistent across different inputs.
        r   Nr   r   )aembed_queryr   r   r   r   r   s       r   test_aembed_queryz,EmbeddingsIntegrationTests.test_aembed_queryO   s      "..u55+t,,,+a.%000!..u55;!###;3{#3333 6
 6s!   B
B?B
B/B
B
c                    K   g d}|j                  |       d{   t              t        |      k(  sJ t        d D              sJ t        d D              sJ t        d         dkD  sJ t        fdD              sJ y7 ow)a3  Test embedding a list of strings async.

        .. dropdown:: Troubleshooting

            If this test fails, check that:

            1. The model will generate a list of lists of floats when calling ``.aembed_documents`` on a list of strings.
            2. The length of each list is the same.
        r   Nc              3   <   K   | ]  }t        |t                y wr   r   r   s     r   r!   zCEmbeddingsIntegrationTests.test_aembed_documents.<locals>.<genexpr>q   r"   r#   c              3   B   K   | ]  }t        |d    t                ywr%   r&   r   s     r   r!   zCEmbeddingsIntegrationTests.test_aembed_documents.<locals>.<genexpr>r   r'   r(   r   c              3   R   K   | ]  }t        |      t        d          k(     ywr%   r*   r+   s     r   r!   zCEmbeddingsIntegrationTests.test_aembed_documents.<locals>.<genexpr>t   r-   r.   )aembed_documentsr   r0   r1   s      @r   test_aembed_documentsz0EmbeddingsIntegrationTests.test_aembed_documentsc   s      *	 11)<<
:#i.000K
KKKKOJOOOO:a=!A%%%TTTTT =s   BBA0B)	__name__
__module____qualname____doc__r   r   r3   r6   r<    r   r   r   r      sY    >4j 4T 4(U* U U&4Z 4D 4(U U Ur   r   N)typingr   langchain_core.embeddingsr   %langchain_tests.unit_tests.embeddingsr   r   rA   r   r   <module>rE      s     0 AlU lUr   