repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
chonkie-inc/chonkie | from typing import Any, Callable
import pytest
import tiktoken
from tokenizers import Tokenizer as HFTokenizer
from transformers import AutoTokenizer as HFAutoTokenizer
from transformers import PreTrainedTokenizerFast
from chonkie.tokenizer import (
AutoTokenizer,
ByteTokenizer,
CharacterTokenizer,
Wo... | 3 | assert | numeric_literal | tests/test_tokenizer.py | test_tokenizer_with_non_standard_callable | 836 | null | |
chonkie-inc/chonkie | from unittest.mock import MagicMock, patch
import pytest
from chonkie import Chunk
from chonkie.cloud.refineries.base import BaseRefinery
from chonkie.cloud.refineries.embeddings import EmbeddingsRefinery
from chonkie.cloud.refineries.overlap import OverlapRefinery
def make_chunks(n: int = 3) -> list[Chunk]:
"""... | "token" | assert | string_literal | tests/cloud/test_cloud_refineries.py | test_overlap_refinery_stores_all_parameters | 105 | null | |
chonkie-inc/chonkie | from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import TokenChunker
from chonkie.types import Chunk
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, str):
if not text_input.strip()... | len(texts) | assert | func_call | tests/cloud/test_cloud_token_chunker.py | test_cloud_token_chunker_batch | 179 | null | |
chonkie-inc/chonkie | from __future__ import annotations
from pathlib import Path
import pytest
from chonkie.pipeline import Pipeline
from chonkie.types import Document
def temp_file(tmp_path: Path) -> Path:
"""Fixture that creates a temporary file."""
file_path = tmp_path / "file.txt"
file_path.write_text("This is test cont... | 0 | assert | numeric_literal | tests/test_pipeline.py | test_pipeline_with_direct_text_input | TestPipelineBasics | 58 | null |
chonkie-inc/chonkie | from __future__ import annotations
import pytest
from chonkie import Chunk
pytestmark = pytest.mark.skipif(not MEMCHUNK_AVAILABLE, reason="memchunk not installed")
def sample_text() -> str:
"""Fixture that returns a sample text for testing the FastChunker."""
text = """According to all known laws of aviatio... | 1 | assert | numeric_literal | tests/chunkers/test_fast_chunker.py | test_fast_chunker_single_word | 131 | null | |
chonkie-inc/chonkie | from pathlib import Path
from unittest.mock import mock_open, patch
import pytest
from chonkie.chef import TextChef
from chonkie.types import Document
class TestTextChef:
def text_chef(self) -> TextChef:
"""Fixture that returns a TextChef instance."""
return TextChef()
def sample_text(self)... | 2 | assert | numeric_literal | tests/chef/test_chef.py | test_call_list_of_strings | TestTextChef | 135 | null |
chonkie-inc/chonkie | import pytest
from chonkie import RecursiveLevel, RecursiveRules
requires_hf_hub = pytest.mark.skipif(not HF_HUB_AVAILABLE, reason="huggingface_hub not installed")
def test_recursive_level_init() -> None:
"""Test RecursiveLevel initialization."""
level = RecursiveLevel(delimiters=["\n", "."])
assert leve... | "prev" | assert | string_literal | tests/types/test_recursive.py | test_recursive_level_init | 22 | null | |
chonkie-inc/chonkie | import html
import logging
import os
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from chonkie.types import Chunk
from chonkie.utils.viz import (
BODY_BACKGROUND_COLOR_DARK,
BODY_BACKGROUND_COLOR_LIGHT,
CONTENT_BACKGROUND_COLOR_DARK,
CONTENT_BACKGROUND_COLOR_LIGHT,... | 2 | assert | numeric_literal | tests/test_viz.py | test_print_strings_indices_with_gaps | TestVisualizerStringInput | 589 | null |
chonkie-inc/chonkie | import json
import os
from pathlib import Path
import pytest
from chonkie import Chunk
from chonkie.porters.json import JSONPorter
def sample_chunks() -> list[Chunk]:
"""Create sample chunks for testing."""
return [
Chunk(
text="This is the first chunk.",
start_index=0,
... | content | assert | variable | tests/porters/test_json_porter.py | test_json_porter_indentation | 224 | null | |
chonkie-inc/chonkie | import os
from unittest.mock import MagicMock, patch
import numpy as np
import pytest
from chonkie.embeddings.gemini import GeminiEmbeddings
def mock_catsu_client():
"""Mock Catsu client for testing."""
mock_client = MagicMock()
mock_embed_response = MagicMock()
mock_embed_response.to_numpy.return_v... | repr_str | assert | variable | tests/embeddings/test_gemini_embeddings.py | test_repr | 148 | null | |
chonkie-inc/chonkie | from pathlib import Path
import pytest
from chonkie.fetcher import BaseFetcher, FileFetcher
class TestFileFetcher:
def file_fetcher(self):
"""Fixture that returns a FileFetcher instance."""
return FileFetcher()
def temp_dir_with_files(self, tmp_path) -> Path:
"""Fixture that creates... | [] | assert | collection | tests/fetcher/test_fetcher.py | test_fetch_with_non_matching_extension | TestFileFetcher | 134 | null |
chonkie-inc/chonkie | import os
from unittest.mock import Mock, patch
import pytest
from pytest import MonkeyPatch
from chonkie.cloud import SlumberChunker
from chonkie.types import Chunk
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, ... | len(texts) | assert | func_call | tests/cloud/test_cloud_slumber_chunker.py | test_cloud_slumber_chunker_batch | 150 | null | |
chonkie-inc/chonkie | from pathlib import Path
from unittest.mock import mock_open, patch
import pytest
from chonkie.chef import TextChef
from chonkie.types import Document
class TestTextChef:
def text_chef(self) -> TextChef:
"""Fixture that returns a TextChef instance."""
return TextChef()
def sample_text(self)... | 3 | assert | numeric_literal | tests/chef/test_chef.py | test_process_batch_string_paths | TestTextChef | 68 | null |
chonkie-inc/chonkie | from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import RecursiveChunker
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, str):
if not text_input.strip():
return []
... | "gpt2" | assert | string_literal | tests/cloud/test_cloud_recursive_chunker.py | test_cloud_recursive_chunker_initialization | 81 | null | |
chonkie-inc/chonkie | from chonkie import Chunk
from chonkie.types import Document
def test_document_default_metadata_are_independent():
"""Two Documents created with defaults have independent metadata dicts."""
doc1 = Document()
doc2 = Document()
doc1.metadata["k"] = "v"
assert "k" not in | doc2.metadata | assert | complex_expr | tests/types/test_document.py | test_document_default_metadata_are_independent | 87 | null | |
chonkie-inc/chonkie | from chonkie.types.code import LanguageConfig, MergeRule, SplitRule
def test_merge_rule_multiple_node_types():
"""MergeRule stores all provided node type strings."""
types = ["a", "b", "c", "d"]
rule = MergeRule(name="multi", node_types=types)
assert rule.node_types == | types | assert | variable | tests/types/test_code.py | test_merge_rule_multiple_node_types | 51 | null | |
chonkie-inc/chonkie | from __future__ import annotations
import pytest
from tokenizers import Tokenizer
from chonkie import Chunk, SentenceChunker
def tokenizer() -> Tokenizer:
"""Return a tokenizer instance."""
return Tokenizer.from_pretrained("gpt2")
def sample_text() -> str:
"""Return a sample text."""
text = """# Chu... | 1 | assert | numeric_literal | tests/chunkers/test_sentence_chunker.py | test_sentence_chunker_initialization | 63 | null | |
chonkie-inc/chonkie | import uuid
from unittest.mock import Mock, patch
import pytest
import chromadb
from chonkie import ChromaHandshake
from chonkie.handshakes.chroma import ChromaEmbeddingFunction
from chonkie.types import Chunk
pytestmark = pytest.mark.skipif(chromadb is None, reason="chromadb not installed")
def mock_embeddings():... | "Client" | assert | string_literal | tests/handshakes/test_chroma_handshake.py | test_chroma_handshake_init_default | 72 | null | |
chonkie-inc/chonkie | import os
from typing import List
from unittest.mock import MagicMock, patch
import numpy as np
import pytest
from tests.embeddings.utils import make_mock_catsu_client
def mock_catsu_client():
return make_mock_catsu_client(dimension=1024, model_name="voyage-3")
def embedding_model(mock_catsu_client):
"""Fix... | 1 | assert | numeric_literal | tests/embeddings/test_catsu_embeddings.py | test_embed_single_text | 100 | null | |
chonkie-inc/chonkie | from chonkie.types import Document
from chonkie.types.markdown import MarkdownCode, MarkdownDocument, MarkdownImage, MarkdownTable
def test_markdown_table_default_values():
"""MarkdownTable defaults to empty content and zero indices."""
table = MarkdownTable()
assert table.content == | "" | assert | string_literal | tests/types/test_markdown.py | test_markdown_table_default_values | 27 | null | |
chonkie-inc/chonkie | from __future__ import annotations
import pytest
from chonkie import Chunk, RecursiveChunker, TableChunker
from chonkie.types import Document, MarkdownDocument, MarkdownTable
def sample_table() -> str:
"""Fixture that returns a sample markdown table for testing."""
table = """| Name | Age | City | Country | ... | 2 | assert | numeric_literal | tests/chunkers/test_table_chunker.py | test_table_chunker_exact_chunk_size | 199 | null | |
chonkie-inc/chonkie | from unittest.mock import MagicMock, patch
import pytest
from chonkie import Chunk
from chonkie.cloud.refineries.base import BaseRefinery
from chonkie.cloud.refineries.embeddings import EmbeddingsRefinery
from chonkie.cloud.refineries.overlap import OverlapRefinery
def make_chunks(n: int = 3) -> list[Chunk]:
"""... | 1 | assert | numeric_literal | tests/cloud/test_cloud_refineries.py | test_overlap_refinery_call_invokes_refine | 188 | null | |
chonkie-inc/chonkie | from unittest.mock import MagicMock, patch
import pytest
from chonkie import Chunk
from chonkie.cloud.refineries.base import BaseRefinery
from chonkie.cloud.refineries.embeddings import EmbeddingsRefinery
from chonkie.cloud.refineries.overlap import OverlapRefinery
def make_chunks(n: int = 3) -> list[Chunk]:
"""... | "my-key" | assert | string_literal | tests/cloud/test_cloud_refineries.py | test_embeddings_refinery_explicit_api_key | 214 | null | |
chonkie-inc/chonkie | from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import TokenChunker
from chonkie.types import Chunk
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, str):
if not text_input.strip()... | 0 | assert | numeric_literal | tests/cloud/test_cloud_token_chunker.py | test_cloud_token_chunker_initialization | 79 | null | |
chonkie-inc/chonkie | from typing import Any, Callable
import pytest
import tiktoken
from tokenizers import Tokenizer as HFTokenizer
from transformers import AutoTokenizer as HFAutoTokenizer
from transformers import PreTrainedTokenizerFast
from chonkie.tokenizer import (
AutoTokenizer,
ByteTokenizer,
CharacterTokenizer,
Wo... | 0 | assert | numeric_literal | tests/test_tokenizer.py | test_encode_decode | 160 | null | |
chonkie-inc/chonkie | import os
from unittest.mock import MagicMock, patch
import numpy as np
import pytest
from chonkie.embeddings.gemini import GeminiEmbeddings
def mock_catsu_client():
"""Mock Catsu client for testing."""
mock_client = MagicMock()
mock_embed_response = MagicMock()
mock_embed_response.to_numpy.return_v... | [] | assert | collection | tests/embeddings/test_gemini_embeddings.py | test_embed_batch_empty | 121 | null | |
chonkie-inc/chonkie | import sys
from unittest.mock import Mock, patch
import pytest
from chonkie import BaseGenie
from chonkie.genie.azure_openai import AzureOpenAIGenie
class TestAzureAIGenieMocked:
def test_repr(self):
"""Test AzureOpenAIGenie string representation."""
mock_openai = Mock()
with (
... | rep | assert | variable | tests/genie/test_azure_openai_genie.py | test_repr | TestAzureAIGenieMocked | 111 | null |
chonkie-inc/chonkie | import importlib.util as importutil
import pytest
from chonkie import NeuralChunker
def sample_text() -> str:
"""Sample text for testing the NeuralChunker.
Returns:
str: A paragraph of text about machine learning chunking.
"""
text = """The process of neural text chunking represents a break... | 5 | assert | numeric_literal | tests/chunkers/test_neural_chunker.py | test_different_min_characters | TestNeuralChunkerParameterVariations | 357 | null |
chonkie-inc/chonkie | import pytest
from chonkie import SemanticChunker
from chonkie.embeddings import BaseEmbeddings, Model2VecEmbeddings
from chonkie.types import Chunk
def sample_text() -> str:
"""Sample text for testing the SemanticChunker."""
text = """The process of text chunking in RAG applications represents a delicate bal... | 0 | assert | numeric_literal | tests/chunkers/test_semantic_chunker.py | test_semantic_chunker_chunking | 69 | null | |
chonkie-inc/chonkie | from __future__ import annotations
import pytest
from chonkie import Chunk
pytestmark = pytest.mark.skipif(not MEMCHUNK_AVAILABLE, reason="memchunk not installed")
def sample_text() -> str:
"""Fixture that returns a sample text for testing the FastChunker."""
text = """According to all known laws of aviatio... | None | assert | none_literal | tests/chunkers/test_fast_chunker.py | test_fast_chunker_initialization | 63 | null | |
chonkie-inc/chonkie | import os
import numpy as np
import pytest
from chonkie.embeddings.azure_openai import AzureOpenAIEmbeddings
def azure_embedding_model() -> AzureOpenAIEmbeddings:
"""Fixture to create an AzureOpenAIEmbeddings instance."""
return AzureOpenAIEmbeddings(
model="text-embedding-3-small",
azure_end... | len(sample_texts) | assert | func_call | tests/embeddings/test_azure_openai_embeddings.py | test_embed_batch_texts | 72 | null | |
chonkie-inc/chonkie | import contextlib
import dataclasses
from unittest.mock import patch
import numpy as np
import pytest
from chonkie.embeddings.base import BaseEmbeddings
from chonkie.embeddings.cloudflare import CloudflareEmbeddings
from chonkie.embeddings.deepinfra import DeepInfraEmbeddings
from chonkie.embeddings.mistral import Mi... | [] | assert | collection | tests/embeddings/test_new_providers.py | test_embed_batch_empty | TestNewProviderEmbeddings | 116 | null |
chonkie-inc/chonkie | from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import SentenceChunker
from chonkie.types import Chunk
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, str):
if not text_input.stri... | 0 | assert | numeric_literal | tests/cloud/test_cloud_sentence_chunker.py | test_cloud_sentence_chunker_initialization | 124 | null | |
chonkie-inc/chonkie | import os
from unittest.mock import Mock, patch
import pytest
from pytest import MonkeyPatch
from chonkie.cloud import SlumberChunker
from chonkie.types import Chunk
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, ... | "gpt2" | assert | string_literal | tests/cloud/test_cloud_slumber_chunker.py | test_cloud_slumber_chunker_initialization | 95 | null | |
chonkie-inc/chonkie | import uuid
from unittest.mock import Mock, patch
import pytest
import chromadb
from chonkie import ChromaHandshake
from chonkie.handshakes.chroma import ChromaEmbeddingFunction
from chonkie.types import Chunk
pytestmark = pytest.mark.skipif(chromadb is None, reason="chromadb not installed")
def mock_embeddings():... | chunk.text | assert | complex_expr | tests/handshakes/test_chroma_handshake.py | test_chroma_handshake_write_single_chunk | 196 | null | |
chonkie-inc/chonkie | from typing import TYPE_CHECKING, Callable
from unittest.mock import patch
import pytest
from chonkie.embeddings import BaseEmbeddings
from chonkie.refinery import EmbeddingsRefinery
from chonkie.types import Chunk
def sample_chunks() -> list[Chunk]:
"""Fixture to create sample chunks."""
return [
Ch... | [] | assert | collection | tests/refinery/test_embedding_refinery.py | test_embeddings_refinery_refine_empty_list | 146 | null | |
chonkie-inc/chonkie | from typing import Any, Callable, Union
from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import CodeChunker
from chonkie.types import Chunk
def python_code() -> str:
"""Return a sample Python code snippet."""
return """
import os
import sys
def hello_world(name: str):
\"\"\"Prints ... | 0 | assert | numeric_literal | tests/cloud/test_cloud_code_chunker.py | test_cloud_code_chunker_empty_text | 405 | null | |
chonkie-inc/chonkie | import os
from unittest.mock import Mock, patch
import pytest
from pytest import MonkeyPatch
from chonkie.cloud import SlumberChunker
from chonkie.types import Chunk
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, ... | None | assert | none_literal | tests/cloud/test_cloud_slumber_chunker.py | test_cloud_slumber_chunker_from_recipe | 172 | null | |
chonkie-inc/chonkie | from chonkie.handshakes.utils import ADJECTIVES, NOUNS, VERBS, generate_random_collection_name
def test_generate_name_is_lowercase():
"""Generated name is entirely lowercase."""
name = generate_random_collection_name()
assert name == | name.lower() | assert | func_call | tests/handshakes/test_handshake_utils.py | test_generate_name_is_lowercase | 47 | null | |
chonkie-inc/chonkie | from typing import Any, Callable, Union
from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import CodeChunker
from chonkie.types import Chunk
def python_code() -> str:
"""Return a sample Python code snippet."""
return """
import os
import sys
def hello_world(name: str):
\"\"\"Prints ... | "python" | assert | string_literal | tests/cloud/test_cloud_code_chunker.py | test_cloud_code_chunker_initialization | 181 | null | |
chonkie-inc/chonkie | from __future__ import annotations
import pytest
from chonkie import Chunk
def test_chunk_embedding_repr():
"""Test Chunk __repr__ with embedding."""
# Test without embedding
chunk1 = Chunk(text="test", start_index=0, end_index=4, token_count=1)
repr1 = repr(chunk1)
assert "embedding" not in repr... | repr3 | assert | variable | tests/types/test_base.py | test_chunk_embedding_repr | 114 | null | |
chonkie-inc/chonkie | from __future__ import annotations
from pathlib import Path
import pytest
from chonkie.pipeline import Pipeline
from chonkie.types import Document
def temp_file(tmp_path: Path) -> Path:
"""Fixture that creates a temporary file."""
file_path = tmp_path / "file.txt"
file_path.write_text("This is test cont... | 2 | assert | numeric_literal | tests/test_pipeline.py | test_pipeline_with_extension_filter | TestPipelineFetcher | 136 | null |
chonkie-inc/chonkie | from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import TokenChunker
from chonkie.types import Chunk
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, str):
if not text_input.strip()... | 2 | assert | numeric_literal | tests/cloud/test_cloud_token_chunker.py | test_cloud_token_chunker_simple | 107 | null | |
chonkie-inc/chonkie | import pytest
from chonkie import CodeChunker
from chonkie.types import Chunk
def python_code() -> str:
"""Return a sample Python code snippet."""
return """
import os
import sys
def hello_world(name: str):
\"\"\"Prints a greeting.\"\"\"
print(f"Hello, {name}!")
class MyClass:
def __init__(self,... | None | assert | none_literal | tests/chunkers/test_code_chunker.py | test_code_chunker_initialization | 58 | null | |
chonkie-inc/chonkie | from unittest.mock import MagicMock, patch
import pytest
from chonkie import Chunk
from chonkie.cloud.refineries.base import BaseRefinery
from chonkie.cloud.refineries.embeddings import EmbeddingsRefinery
from chonkie.cloud.refineries.overlap import OverlapRefinery
def make_chunks(n: int = 3) -> list[Chunk]:
"""... | chunks | assert | variable | tests/cloud/test_cloud_refineries.py | test_base_refinery_call_delegates_to_refine | 56 | null | |
chonkie-inc/chonkie | from __future__ import annotations
import pytest
from chonkie import Chunk
def test_chunk_embedding_serialization():
"""Test Chunk serialization with embedding."""
# Test with list embedding
chunk1 = Chunk(
text="test",
start_index=0,
end_index=4,
token_count=1,
em... | dict1 | assert | variable | tests/types/test_base.py | test_chunk_embedding_serialization | 144 | null | |
chonkie-inc/chonkie | import os
from unittest.mock import Mock, patch
import pytest
from pytest import MonkeyPatch
from chonkie.cloud import SlumberChunker
from chonkie.types import Chunk
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, ... | 1 | assert | numeric_literal | tests/cloud/test_cloud_slumber_chunker.py | test_cloud_slumber_chunker_single_sentence | 119 | null | |
chonkie-inc/chonkie | from __future__ import annotations
import pytest
from chonkie import Chunk
def test_chunk_embedding_repr():
"""Test Chunk __repr__ with embedding."""
# Test without embedding
chunk1 = Chunk(text="test", start_index=0, end_index=4, token_count=1)
repr1 = repr(chunk1)
assert "embedding" not in | repr1 | assert | variable | tests/types/test_base.py | test_chunk_embedding_repr | 90 | null | |
chonkie-inc/chonkie | from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import SemanticChunker
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, str):
if not text_input.strip():
return []
... | 3 | assert | numeric_literal | tests/cloud/test_cloud_semantic_chunker.py | test_cloud_semantic_chunker_initialization | 124 | null | |
chonkie-inc/chonkie | import os
from unittest.mock import MagicMock, patch
import numpy as np
import pytest
from chonkie.embeddings.voyageai import VoyageAIEmbeddings
def mock_catsu_client():
"""Mock Catsu client for testing."""
mock_client = MagicMock()
mock_embed_response = MagicMock()
mock_embed_response.to_numpy.retu... | [] | assert | collection | tests/embeddings/test_voyageai_embeddings.py | test_embed_batch_empty | 111 | null | |
chonkie-inc/chonkie | from chonkie import Chunk
from chonkie.types import Document
def test_document_id_is_unique():
"""Two Document instances get different auto-generated ids."""
doc1 = Document()
doc2 = Document()
assert doc1.id != | doc2.id | assert | complex_expr | tests/types/test_document.py | test_document_id_is_unique | 25 | null | |
chonkie-inc/chonkie | from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import RecursiveChunker
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, str):
if not text_input.strip():
return []
... | 0 | assert | numeric_literal | tests/cloud/test_cloud_recursive_chunker.py | test_cloud_recursive_chunker_single_sentence | 106 | null | |
chonkie-inc/chonkie | import os
from unittest.mock import MagicMock, patch
import numpy as np
import pytest
from chonkie.embeddings.cohere import CohereEmbeddings
def mock_catsu_client():
"""Mock Catsu client for testing."""
mock_client = MagicMock()
mock_embed_response = MagicMock()
mock_embed_response.to_numpy.return_v... | len(sample_texts) | assert | func_call | tests/embeddings/test_cohere_embeddings.py | test_embed_batch_texts | 96 | null | |
chonkie-inc/chonkie | import importlib.util as importutil
import pytest
from chonkie import NeuralChunker
def sample_text() -> str:
"""Sample text for testing the NeuralChunker.
Returns:
str: A paragraph of text about machine learning chunking.
"""
text = """The process of neural text chunking represents a break... | 1 | assert | numeric_literal | tests/chunkers/test_neural_chunker.py | test_chunk_short_text | TestNeuralChunkerEdgeCases | 244 | null |
chonkie-inc/chonkie | from typing import Any, Callable, Union
from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import CodeChunker
from chonkie.types import Chunk
def python_code() -> str:
"""Return a sample Python code snippet."""
return """
import os
import sys
def hello_world(name: str):
\"\"\"Prints ... | js_code | assert | variable | tests/cloud/test_cloud_code_chunker.py | test_cloud_code_chunker_javascript | 284 | null | |
chonkie-inc/chonkie | from __future__ import annotations
import pytest
from tokenizers import Tokenizer
from chonkie import Chunk, SentenceChunker
def tokenizer() -> Tokenizer:
"""Return a tokenizer instance."""
return Tokenizer.from_pretrained("gpt2")
def sample_text() -> str:
"""Return a sample text."""
text = """# Chu... | 0 | assert | numeric_literal | tests/chunkers/test_sentence_chunker.py | test_sentence_chunker_chunking | 82 | null | |
chonkie-inc/chonkie | import os
from typing import List
from unittest.mock import MagicMock, patch
import numpy as np
import pytest
from tests.embeddings.utils import make_mock_catsu_client
def mock_catsu_client():
return make_mock_catsu_client(dimension=1024, model_name="voyage-3")
def embedding_model(mock_catsu_client):
"""Fix... | repr_str | assert | variable | tests/embeddings/test_catsu_embeddings.py | test_repr | 253 | null | |
chonkie-inc/chonkie | from chonkie.types.code import LanguageConfig, MergeRule, SplitRule
def test_language_config_equality():
"""Two LanguageConfigs with the same data are equal (dataclass default)."""
cfg1 = LanguageConfig(language="go", merge_rules=[], split_rules=[])
cfg2 = LanguageConfig(language="go", merge_rules=[], spli... | cfg2 | assert | variable | tests/types/test_code.py | test_language_config_equality | 164 | null | |
chonkie-inc/chonkie | import os
from unittest.mock import MagicMock, patch
import numpy as np
import pytest
from chonkie.embeddings.cohere import CohereEmbeddings
def mock_catsu_client():
"""Mock Catsu client for testing."""
mock_client = MagicMock()
mock_embed_response = MagicMock()
mock_embed_response.to_numpy.return_v... | repr_str | assert | variable | tests/embeddings/test_cohere_embeddings.py | test_repr | 129 | null | |
chonkie-inc/chonkie | import os
from unittest.mock import MagicMock, patch
import numpy as np
import pytest
from chonkie.embeddings.cohere import CohereEmbeddings
def mock_catsu_client():
"""Mock Catsu client for testing."""
mock_client = MagicMock()
mock_embed_response = MagicMock()
mock_embed_response.to_numpy.return_v... | [] | assert | collection | tests/embeddings/test_cohere_embeddings.py | test_embed_batch_empty | 102 | null | |
chonkie-inc/chonkie | from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import SemanticChunker
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, str):
if not text_input.strip():
return []
... | 0 | assert | numeric_literal | tests/cloud/test_cloud_semantic_chunker.py | test_cloud_semantic_chunker_initialization | 122 | null | |
chonkie-inc/chonkie | from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import LateChunker
from chonkie.types import Chunk
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, str):
if not text_input.strip():... | "gpt2" | assert | string_literal | tests/cloud/test_cloud_late_chunker.py | test_cloud_late_chunker_initialization | 83 | null | |
chonkie-inc/chonkie | import os
import numpy as np
import pytest
from chonkie.embeddings.azure_openai import AzureOpenAIEmbeddings
def azure_embedding_model() -> AzureOpenAIEmbeddings:
"""Fixture to create an AzureOpenAIEmbeddings instance."""
return AzureOpenAIEmbeddings(
model="text-embedding-3-small",
azure_end... | None | assert | none_literal | tests/embeddings/test_azure_openai_embeddings.py | test_initialization_with_model_name | 47 | null | |
chonkie-inc/chonkie | import pytest
from chonkie import CodeChunker
from chonkie.types import Chunk
def python_code() -> str:
"""Return a sample Python code snippet."""
return """
import os
import sys
def hello_world(name: str):
\"\"\"Prints a greeting.\"\"\"
print(f"Hello, {name}!")
class MyClass:
def __init__(self,... | 0 | assert | numeric_literal | tests/chunkers/test_code_chunker.py | test_code_chunker_chunking_python | 67 | null | |
chonkie-inc/chonkie | import json
from typing import Any, Optional
from unittest.mock import Mock, patch
import pytest
from chonkie.chunker import SlumberChunker
from chonkie.genie import BaseGenie
from chonkie.types import Chunk, RecursiveLevel, RecursiveRules
def mock_genie() -> MockGenie:
"""Fixture for mock genie."""
return M... | 3 | assert | numeric_literal | tests/chunkers/test_slumber_chunker.py | test_prepare_splits | TestSlumberChunkerInternalMethods | 273 | null |
chonkie-inc/chonkie | from chonkie import Chunk
from chonkie.types import Document
def test_document_default_initialization():
"""Document created with no args has empty content, chunks, and metadata."""
doc = Document()
assert doc.content == | "" | assert | string_literal | tests/types/test_document.py | test_document_default_initialization | 10 | null | |
chonkie-inc/chonkie | from __future__ import annotations
from typing import cast
import pytest
import tiktoken
from tiktoken import Encoding
from tokenizers import Tokenizer
from transformers import AutoTokenizer, PreTrainedTokenizerFast
from chonkie import Chunk, TokenChunker
def tiktokenizer() -> Encoding:
"""Fixture that returns ... | 0 | assert | numeric_literal | tests/chunkers/test_token_chunker.py | test_token_chunker_chunking | 120 | null | |
chonkie-inc/chonkie | from __future__ import annotations
import pytest
from chonkie import Chunk
def test_chunk_embedding_repr():
"""Test Chunk __repr__ with embedding."""
# Test without embedding
chunk1 = Chunk(text="test", start_index=0, end_index=4, token_count=1)
repr1 = repr(chunk1)
assert "embedding" not in repr... | repr2 | assert | variable | tests/types/test_base.py | test_chunk_embedding_repr | 101 | null | |
chonkie-inc/chonkie | import os
from unittest.mock import MagicMock, patch
import numpy as np
import pytest
from chonkie.embeddings.openai import OpenAIEmbeddings
def mock_catsu_client():
"""Mock Catsu client for testing."""
mock_client = MagicMock()
mock_embed_response = MagicMock()
mock_embed_response.to_numpy.return_v... | [] | assert | collection | tests/embeddings/test_openai_embeddings.py | test_embed_batch_empty | 104 | null | |
chonkie-inc/chonkie | from typing import Any, Callable, Union
from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import CodeChunker
from chonkie.types import Chunk
def python_code() -> str:
"""Return a sample Python code snippet."""
return """
import os
import sys
def hello_world(name: str):
\"\"\"Prints ... | None | assert | none_literal | tests/cloud/test_cloud_code_chunker.py | test_cloud_code_chunker_simple | 211 | null | |
chonkie-inc/chonkie | from __future__ import annotations
from pathlib import Path
from typing import Any
import pandas as pd
import pytest
from chonkie import TableChef
from chonkie.types import MarkdownDocument
class TestTableChef:
def table_chef(self) -> TableChef:
"""Fixture that returns a TableChef instance."""
... | 2 | assert | numeric_literal | tests/chef/test_table_chef.py | test_process_batch | TestTableChef | 126 | null |
chonkie-inc/chonkie | from chonkie import Chunk
from chonkie.types import Document
def test_document_metadata_stored():
"""Document stores arbitrary metadata key-value pairs."""
doc = Document(content="text", metadata={"source": "web", "page": 3})
assert doc.metadata["source"] == | "web" | assert | string_literal | tests/types/test_document.py | test_document_metadata_stored | 57 | null | |
chonkie-inc/chonkie | from unittest.mock import MagicMock, patch
import pytest
from chonkie import Chunk
from chonkie.cloud.refineries.base import BaseRefinery
from chonkie.cloud.refineries.embeddings import EmbeddingsRefinery
from chonkie.cloud.refineries.overlap import OverlapRefinery
def make_chunks(n: int = 3) -> list[Chunk]:
"""... | "gpt2" | assert | string_literal | tests/cloud/test_cloud_refineries.py | test_overlap_refinery_stores_all_parameters | 103 | null | |
chonkie-inc/chonkie | import uuid
from unittest.mock import Mock, patch
import pytest
from chonkie.handshakes.weaviate import WeaviateHandshake
from chonkie.types import Chunk
pytestmark = pytest.mark.skipif(weaviate is None, reason="weaviate not installed")
def mock_embeddings():
"""Mock AutoEmbeddings to avoid downloading models i... | chunk.language | assert | complex_expr | tests/handshakes/test_weaviate_handshake.py | test_weaviate_handshake_generate_properties_with_optional_fields | 368 | null | |
chonkie-inc/chonkie | import os
from unittest.mock import MagicMock, patch
import numpy as np
import pytest
from chonkie.embeddings.cohere import CohereEmbeddings
def mock_catsu_client():
"""Mock Catsu client for testing."""
mock_client = MagicMock()
mock_embed_response = MagicMock()
mock_embed_response.to_numpy.return_v... | None | assert | none_literal | tests/embeddings/test_cohere_embeddings.py | test_initialization | 57 | null | |
chonkie-inc/chonkie | import importlib.util as importutil
import pytest
from chonkie import NeuralChunker
def sample_text() -> str:
"""Sample text for testing the NeuralChunker.
Returns:
str: A paragraph of text about machine learning chunking.
"""
text = """The process of neural text chunking represents a break... | 3 | assert | numeric_literal | tests/chunkers/test_neural_chunker.py | test_get_chunks_from_splits | TestNeuralChunkerInternalMethods | 188 | null |
chonkie-inc/chonkie | from __future__ import annotations
from typing import cast
import pytest
import tiktoken
from tiktoken import Encoding
from tokenizers import Tokenizer
from transformers import AutoTokenizer, PreTrainedTokenizerFast
from chonkie import Chunk, TokenChunker
def tiktokenizer() -> Encoding:
"""Fixture that returns ... | 1 | assert | numeric_literal | tests/chunkers/test_token_chunker.py | test_token_chunker_single_token_text | 173 | null | |
chonkie-inc/chonkie | from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import RecursiveChunker
def mock_api_response():
"""Mock successful API response."""
def _mock_response(text_input, chunk_count=1):
if isinstance(text_input, str):
if not text_input.strip():
return []
... | 3 | assert | numeric_literal | tests/cloud/test_cloud_recursive_chunker.py | test_cloud_recursive_chunker_batch | 131 | null | |
chonkie-inc/chonkie | import uuid
from unittest.mock import Mock, patch
import pytest
from chonkie.handshakes.weaviate import WeaviateHandshake
from chonkie.types import Chunk
pytestmark = pytest.mark.skipif(weaviate is None, reason="weaviate not installed")
def mock_embeddings():
"""Mock AutoEmbeddings to avoid downloading models i... | chunk.text | assert | complex_expr | tests/handshakes/test_weaviate_handshake.py | test_weaviate_handshake_generate_properties_with_optional_fields | 359 | null | |
chonkie-inc/chonkie | import contextlib
import dataclasses
from unittest.mock import patch
import numpy as np
import pytest
from chonkie.embeddings.base import BaseEmbeddings
from chonkie.embeddings.cloudflare import CloudflareEmbeddings
from chonkie.embeddings.deepinfra import DeepInfraEmbeddings
from chonkie.embeddings.mistral import Mi... | ptp.default_model | assert | complex_expr | tests/embeddings/test_new_providers.py | test_initialization | TestNewProviderEmbeddings | 94 | null |
chonkie-inc/chonkie | import importlib.util as importutil
import pytest
from chonkie import NeuralChunker
def sample_text() -> str:
"""Sample text for testing the NeuralChunker.
Returns:
str: A paragraph of text about machine learning chunking.
"""
text = """The process of neural text chunking represents a break... | [] | assert | collection | tests/chunkers/test_neural_chunker.py | test_merge_close_spans_empty | TestNeuralChunkerInternalMethods | 175 | null |
chonkie-inc/chonkie | import os
import numpy as np
import pytest
from chonkie.embeddings.azure_openai import AzureOpenAIEmbeddings
def azure_embedding_model() -> AzureOpenAIEmbeddings:
"""Fixture to create an AzureOpenAIEmbeddings instance."""
return AzureOpenAIEmbeddings(
model="text-embedding-3-small",
azure_end... | True | assert | bool_literal | tests/embeddings/test_azure_openai_embeddings.py | test_is_available | 105 | null | |
chonkie-inc/chonkie | import pytest
from chonkie import SemanticChunker
from chonkie.embeddings import BaseEmbeddings, Model2VecEmbeddings
from chonkie.types import Chunk
def sample_text() -> str:
"""Sample text for testing the SemanticChunker."""
text = """The process of text chunking in RAG applications represents a delicate bal... | 5 | assert | numeric_literal | tests/chunkers/test_semantic_chunker.py | test_with_different_similarity_windows | TestSemanticChunkerConfiguration | 242 | null |
chonkie-inc/chonkie | from unittest.mock import MagicMock, patch
import pytest
from chonkie import Chunk
from chonkie.cloud.refineries.base import BaseRefinery
from chonkie.cloud.refineries.embeddings import EmbeddingsRefinery
from chonkie.cloud.refineries.overlap import OverlapRefinery
def make_chunks(n: int = 3) -> list[Chunk]:
"""... | "fr" | assert | string_literal | tests/cloud/test_cloud_refineries.py | test_overlap_refinery_stores_all_parameters | 108 | null | |
chonkie-inc/chonkie | import os
import pytest
from chonkie import AutoEmbeddings
from chonkie.embeddings.azure_openai import AzureOpenAIEmbeddings
from chonkie.embeddings.base import BaseEmbeddings
from chonkie.embeddings.catsu import CatsuEmbeddings
from chonkie.embeddings.cohere import CohereEmbeddings
from chonkie.embeddings.jina impor... | original | assert | variable | tests/embeddings/test_auto_embeddings.py | test_existing_embeddings_instance | TestAutoEmbeddingsInputTypes | 152 | null |
chonkie-inc/chonkie | from pathlib import Path
import pytest
from chonkie.fetcher import BaseFetcher, FileFetcher
class TestFileFetcher:
def file_fetcher(self):
"""Fixture that returns a FileFetcher instance."""
return FileFetcher()
def temp_dir_with_files(self, tmp_path) -> Path:
"""Fixture that creates... | ".py" | assert | string_literal | tests/fetcher/test_fetcher.py | test_fetch_single_file_with_ext_ignored | TestFileFetcher | 269 | null |
chonkie-inc/chonkie | from typing import Any, Callable, Union
from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import CodeChunker
from chonkie.types import Chunk
def python_code() -> str:
"""Return a sample Python code snippet."""
return """
import os
import sys
def hello_world(name: str):
\"\"\"Prints ... | "gpt2" | assert | string_literal | tests/cloud/test_cloud_code_chunker.py | test_cloud_code_chunker_initialization | 179 | null | |
chonkie-inc/chonkie | import html
import logging
import os
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from chonkie.types import Chunk
from chonkie.utils.viz import (
BODY_BACKGROUND_COLOR_DARK,
BODY_BACKGROUND_COLOR_LIGHT,
CONTENT_BACKGROUND_COLOR_DARK,
CONTENT_BACKGROUND_COLOR_LIGHT,... | 0 | assert | numeric_literal | tests/test_viz.py | test_print_strings_indices_with_gaps | TestVisualizerStringInput | 592 | null |
chonkie-inc/chonkie | from unittest.mock import MagicMock, patch
import pytest
from chonkie import Chunk
from chonkie.cloud.refineries.base import BaseRefinery
from chonkie.cloud.refineries.embeddings import EmbeddingsRefinery
from chonkie.cloud.refineries.overlap import OverlapRefinery
def make_chunks(n: int = 3) -> list[Chunk]:
"""... | None | assert | none_literal | tests/cloud/test_cloud_refineries.py | test_embeddings_refinery_attaches_numpy_embeddings | 287 | null | |
chonkie-inc/chonkie | import json
import pytest
from chonkie.utils import Hubbie
from chonkie.utils._api import get_config_path, load_token, login
requires_hf_hub = pytest.mark.skipif(not HF_HUB_AVAILABLE, reason="huggingface_hub not installed")
def hubbie() -> Hubbie:
"""Fixture to create a Hubbie instance."""
return Hubbie()
... | True | assert | bool_literal | tests/test_utils.py | test_hubbie_validate_recipe | 93 | null | |
chonkie-inc/chonkie | import pytest
from chonkie import Chunk
from chonkie.porters.base import BasePorter
def make_chunk(text: str = "hello") -> Chunk:
"""Make a Chunk object."""
return Chunk(text=text, start_index=0, end_index=len(text), token_count=1)
def test_base_porter_call_delegates_to_export():
"""__call__ on a concret... | chunks | assert | variable | tests/porters/test_base_porter.py | test_base_porter_call_delegates_to_export | 50 | null | |
chonkie-inc/chonkie | import pytest
from chonkie import Sentence
def test_sentence_repr_without_embedding_omits_embedding():
"""Test Sentence __repr__ does not show embedding when None."""
sentence = Sentence(text="Hello.", start_index=0, end_index=6, token_count=1)
assert "embedding" not in | repr(sentence) | assert | func_call | tests/types/test_sentence.py | test_sentence_repr_without_embedding_omits_embedding | 74 | null | |
chonkie-inc/chonkie | from typing import Any, Callable, Union
from unittest.mock import Mock, patch
import pytest
from chonkie.cloud import CodeChunker
from chonkie.types import Chunk
def python_code() -> str:
"""Return a sample Python code snippet."""
return """
import os
import sys
def hello_world(name: str):
\"\"\"Prints ... | 1 | assert | numeric_literal | tests/cloud/test_cloud_code_chunker.py | test_cloud_code_chunker_python_complex | 242 | null | |
chonkie-inc/chonkie | import html
import logging
import os
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from chonkie.types import Chunk
from chonkie.utils.viz import (
BODY_BACKGROUND_COLOR_DARK,
BODY_BACKGROUND_COLOR_LIGHT,
CONTENT_BACKGROUND_COLOR_DARK,
CONTENT_BACKGROUND_COLOR_LIGHT,... | 3 | assert | numeric_literal | tests/test_viz.py | test_print_strings_indices_with_gaps | TestVisualizerStringInput | 597 | null |
chonkie-inc/chonkie | import os
from unittest.mock import MagicMock, patch
import numpy as np
import pytest
from chonkie.embeddings.gemini import GeminiEmbeddings
def mock_catsu_client():
"""Mock Catsu client for testing."""
mock_client = MagicMock()
mock_embed_response = MagicMock()
mock_embed_response.to_numpy.return_v... | len(sample_texts) | assert | func_call | tests/embeddings/test_gemini_embeddings.py | test_embed_batch_texts | 115 | null | |
chonkie-inc/chonkie | from typing import Callable
import numpy as np
import pytest
from chonkie.embeddings.base import BaseEmbeddings
def test_custom_embeddings_token_count() -> None:
"""Test the token counting functionality."""
embeddings = CustomEmbeddings()
text = "Test string for counting tokens"
count = embeddings.co... | len(text.split()) | assert | func_call | tests/embeddings/test_custom_embeddings.py | test_custom_embeddings_token_count | 85 | null | |
chonkie-inc/chonkie | from unittest.mock import patch
import pytest
from datasets import Dataset
from chonkie.porters.datasets import DatasetsPorter
from chonkie.types import Chunk
def sample_chunks(): # noqa
return [
Chunk(text="Hello world", start_index=0, end_index=11, token_count=2),
Chunk(text="Another chunk", s... | chunk.end_index | assert | complex_expr | tests/porters/test_datasets_porter.py | test_dataset_structure_and_content | 65 | null | |
chonkie-inc/chonkie | from typing import Any, Callable
import pytest
import tiktoken
from tokenizers import Tokenizer as HFTokenizer
from transformers import AutoTokenizer as HFAutoTokenizer
from transformers import PreTrainedTokenizerFast
from chonkie.tokenizer import (
AutoTokenizer,
ByteTokenizer,
CharacterTokenizer,
Wo... | 6 | assert | numeric_literal | tests/test_tokenizer.py | test_byte_tokenizer_ascii_vs_unicode | 614 | null | |
chonkie-inc/chonkie | from __future__ import annotations
import pytest
from chonkie import Chunk, RecursiveChunker, TableChunker
from chonkie.types import Document, MarkdownDocument, MarkdownTable
def sample_table() -> str:
"""Fixture that returns a sample markdown table for testing."""
table = """| Name | Age | City | Country | ... | 0 | assert | numeric_literal | tests/chunkers/test_table_chunker.py | test_table_chunker_small_table | 77 | null | |
chonkie-inc/chonkie | import uuid
from unittest.mock import Mock, patch
import pytest
import chromadb
from chonkie import ChromaHandshake
from chonkie.handshakes.chroma import ChromaEmbeddingFunction
from chonkie.types import Chunk
pytestmark = pytest.mark.skipif(chromadb is None, reason="chromadb not installed")
def mock_embeddings():... | chunk.start_index | assert | complex_expr | tests/handshakes/test_chroma_handshake.py | test_chroma_handshake_write_single_chunk | 197 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.