test_embed_documents_with_custom_chunk_size() — langchain Function Reference
Architecture documentation for the test_embed_documents_with_custom_chunk_size() function in test_base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 4256ac5a_ccd0_2931_d192_82043fec82c1["test_embed_documents_with_custom_chunk_size()"] 1b2604cc_dec7_a9eb_ce6b_1cbab7a6dc2e["test_base.py"] 4256ac5a_ccd0_2931_d192_82043fec82c1 -->|defined in| 1b2604cc_dec7_a9eb_ce6b_1cbab7a6dc2e style 4256ac5a_ccd0_2931_d192_82043fec82c1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/tests/unit_tests/embeddings/test_base.py lines 24–41
def test_embed_documents_with_custom_chunk_size() -> None:
embeddings = OpenAIEmbeddings(chunk_size=2)
texts = ["text1", "text2", "text3", "text4"]
custom_chunk_size = 3
with patch.object(embeddings.client, "create") as mock_create:
mock_create.side_effect = [
{"data": [{"embedding": [0.1, 0.2]}, {"embedding": [0.3, 0.4]}]},
{"data": [{"embedding": [0.5, 0.6]}, {"embedding": [0.7, 0.8]}]},
]
result = embeddings.embed_documents(texts, chunk_size=custom_chunk_size)
_, tokens, __, ___ = embeddings._tokenize(texts, custom_chunk_size)
mock_create.call_args
mock_create.assert_any_call(input=tokens[0:3], **embeddings._invocation_params)
mock_create.assert_any_call(input=tokens[3:4], **embeddings._invocation_params)
assert result == [[0.1, 0.2], [0.3, 0.4], [0.5, 0.6], [0.7, 0.8]]
Domain
Subdomains
Source
Frequently Asked Questions
What does test_embed_documents_with_custom_chunk_size() do?
test_embed_documents_with_custom_chunk_size() is a function in the langchain codebase, defined in libs/partners/openai/tests/unit_tests/embeddings/test_base.py.
Where is test_embed_documents_with_custom_chunk_size() defined?
test_embed_documents_with_custom_chunk_size() is defined in libs/partners/openai/tests/unit_tests/embeddings/test_base.py at line 24.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free