Home / File/ test_retriever.py — langchain Source File

test_retriever.py — langchain Source File

Architecture documentation for test_retriever.py, a python file in the langchain codebase. 2 imports, 0 dependents.

File python CoreAbstractions MessageSchema 2 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  5331611e_386c_b307_dabb_82a7248b2004["test_retriever.py"]
  c554676d_b731_47b2_a98f_c1c2d537c0aa["langchain_core.documents"]
  5331611e_386c_b307_dabb_82a7248b2004 --> c554676d_b731_47b2_a98f_c1c2d537c0aa
  a6947a84_a966_127d_d3a6_ed52b7ab3656["langchain_exa"]
  5331611e_386c_b307_dabb_82a7248b2004 --> a6947a84_a966_127d_d3a6_ed52b7ab3656
  style 5331611e_386c_b307_dabb_82a7248b2004 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Integration tests for `ExaSearchRetriever`."""

from langchain_core.documents import (
    Document,  # type: ignore[import-not-found, import-not-found]
)

from langchain_exa import ExaSearchRetriever


def test_exa_retriever() -> None:
    """Test basic functionality of the `ExaSearchRetriever`."""
    retriever = ExaSearchRetriever()
    res = retriever.invoke("best time to visit japan")
    print(res)  # noqa: T201
    assert len(res) == 10  # default k
    assert isinstance(res, list)
    assert isinstance(res[0], Document)


def test_exa_retriever_highlights() -> None:
    """Test highlights feature of the `ExaSearchRetriever`."""
    retriever = ExaSearchRetriever(highlights=True)
    res = retriever.invoke("best time to visit japan")
    print(res)  # noqa: T201
    assert isinstance(res, list)
    assert isinstance(res[0], Document)
    highlights = res[0].metadata["highlights"]
    highlight_scores = res[0].metadata["highlight_scores"]
    assert isinstance(highlights, list)
    assert isinstance(highlight_scores, list)
    assert isinstance(highlights[0], str)
    assert isinstance(highlight_scores[0], float)


def test_exa_retriever_advanced_features() -> None:
    """Test advanced features of the `ExaSearchRetriever`."""
    retriever = ExaSearchRetriever(
        k=3, text_contents_options={"max_characters": 1000}, summary=True, type="auto"
    )
    res = retriever.invoke("best time to visit japan")
    print(res)  # noqa: T201
    assert len(res) == 3  # requested k=3
    assert isinstance(res, list)
    assert isinstance(res[0], Document)
    # Verify summary is in metadata
    assert "summary" in res[0].metadata
    assert isinstance(res[0].metadata["summary"], str)
    # Verify text was limited
    assert len(res[0].page_content) <= 1000

Subdomains

Dependencies

  • langchain_core.documents
  • langchain_exa

Frequently Asked Questions

What does test_retriever.py do?
test_retriever.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_retriever.py?
test_retriever.py defines 3 function(s): test_exa_retriever, test_exa_retriever_advanced_features, test_exa_retriever_highlights.
What does test_retriever.py depend on?
test_retriever.py imports 2 module(s): langchain_core.documents, langchain_exa.
Where is test_retriever.py in the architecture?
test_retriever.py is located at libs/partners/exa/tests/integration_tests/test_retriever.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/exa/tests/integration_tests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free