Home / Function/ test_custom_encoder() — langchain Function Reference

test_custom_encoder() — langchain Function Reference

Architecture documentation for the test_custom_encoder() function in test_caching.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  5274b871_faca_3fcc_a18d_f93b25bf4421["test_custom_encoder()"]
  6b1a1e58_d1bc_2756_cc7d_9c01f64a73a2["test_caching.py"]
  5274b871_faca_3fcc_a18d_f93b25bf4421 -->|defined in| 6b1a1e58_d1bc_2756_cc7d_9c01f64a73a2
  612e991b_9f93_9ffa_30df_6f17578ea52c["embed_documents()"]
  5274b871_faca_3fcc_a18d_f93b25bf4421 -->|calls| 612e991b_9f93_9ffa_30df_6f17578ea52c
  style 5274b871_faca_3fcc_a18d_f93b25bf4421 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/embeddings/test_caching.py lines 241–253

def test_custom_encoder() -> None:
    """Test that a custom encoder can be used to encode keys in the cache store."""
    store = InMemoryStore()
    emb = MockEmbeddings()

    def custom_upper(text: str) -> str:  # very simple demo encoder
        return "CUSTOM_" + text.upper()

    cbe = CacheBackedEmbeddings.from_bytes_store(emb, store, key_encoder=custom_upper)
    txt = "x"
    cbe.embed_documents([txt])

    assert list(cbe.document_embedding_store.yield_keys()) == ["CUSTOM_X"]

Domain

Subdomains

Frequently Asked Questions

What does test_custom_encoder() do?
test_custom_encoder() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/embeddings/test_caching.py.
Where is test_custom_encoder() defined?
test_custom_encoder() is defined in libs/langchain/tests/unit_tests/embeddings/test_caching.py at line 241.
What does test_custom_encoder() call?
test_custom_encoder() calls 1 function(s): embed_documents.

Analyze Your Own Codebase

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

Try Supermodel Free