6b7e6b44f1
gh-pages / build (push) Waiting to run
Python Publish (pypi) / Upload release to PyPI (push) Waiting to run
Spellcheck / spellcheck (push) Waiting to run
Python Build and Type Check / python-ci (ubuntu-latest, 3.11) (push) Has been cancelled
Python Build and Type Check / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Build and Type Check / python-ci (windows-latest, 3.11) (push) Has been cancelled
Python Build and Type Check / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Integration Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Integration Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Notebook Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Notebook Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Smoke Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Smoke Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Unit Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Unit Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
40 lines
1016 B
Python
40 lines
1016 B
Python
# Copyright (c) 2024 Microsoft Corporation.
|
|
# Licensed under the MIT License
|
|
|
|
"""Test tokenizer configuration loading."""
|
|
|
|
import pytest
|
|
from graphrag_llm.config import TokenizerConfig, TokenizerType
|
|
|
|
|
|
def test_litellm_tokenizer_validation() -> None:
|
|
"""Test that missing required parameters raise validation errors."""
|
|
|
|
with pytest.raises(
|
|
ValueError,
|
|
match="model_id must be specified for LiteLLM tokenizer\\.",
|
|
):
|
|
_ = TokenizerConfig(
|
|
type=TokenizerType.LiteLLM,
|
|
model_id="",
|
|
)
|
|
|
|
with pytest.raises(
|
|
ValueError,
|
|
match="encoding_name must be specified for TikToken tokenizer\\.",
|
|
):
|
|
_ = TokenizerConfig(
|
|
type=TokenizerType.Tiktoken,
|
|
encoding_name="",
|
|
)
|
|
|
|
# passes validation
|
|
_ = TokenizerConfig(
|
|
type=TokenizerType.LiteLLM,
|
|
model_id="openai/gpt-4o",
|
|
)
|
|
_ = TokenizerConfig(
|
|
type=TokenizerType.Tiktoken,
|
|
encoding_name="o200k-base",
|
|
)
|