Skip to content

Commit 7e9c12e

Browse files
authored
Move get_model_name method to BaseTLM class (#100)
1 parent 4112cd6 commit 7e9c12e

File tree

7 files changed

+42
-9
lines changed

7 files changed

+42
-9
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.1.19] - 2025-07-25
11+
12+
### Added
13+
14+
- Add `get_model_name()` method to `TrustworthyRAG`, `TLMChatCompletion`
15+
16+
1017
## [1.1.18] - 2025-07-25
1118

1219
### Fixed
1320

1421
- Properly pass quality preset in `TLMChatCompletion`
1522

23+
1624
## [1.1.17] - 2025-07-18
1725

1826
### Changed
@@ -265,7 +273,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
265273
- Release of the Cleanlab TLM Python client.
266274

267275

268-
[Unreleased]: https://github.com/cleanlab/cleanlab-tlm/compare/v1.1.18...HEAD
276+
[Unreleased]: https://github.com/cleanlab/cleanlab-tlm/compare/v1.1.19...HEAD
277+
[1.1.19]: https://github.com/cleanlab/cleanlab-tlm/compare/v1.1.18...v1.1.19
269278
[1.1.18]: https://github.com/cleanlab/cleanlab-tlm/compare/v1.1.17...v1.1.18
270279
[1.1.17]: https://github.com/cleanlab/cleanlab-tlm/compare/v1.1.16...v1.1.17
271280
[1.1.16]: https://github.com/cleanlab/cleanlab-tlm/compare/v1.1.15...v1.1.16

src/cleanlab_tlm/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# SPDX-License-Identifier: MIT
2-
__version__ = "1.1.18"
2+
__version__ = "1.1.19"

src/cleanlab_tlm/internal/base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import asyncio
88
import os
99
import sys
10-
from typing import TYPE_CHECKING, Optional, Union
10+
from typing import TYPE_CHECKING, Optional, Union, cast
1111

1212
from cleanlab_tlm.errors import MissingApiKeyError, ValidationError
1313
from cleanlab_tlm.internal.concurrency import TlmRateHandler
@@ -102,3 +102,9 @@ def __init__(
102102
except RuntimeError:
103103
self._event_loop = asyncio.new_event_loop()
104104
self._rate_handler = TlmRateHandler()
105+
106+
def get_model_name(self) -> str:
107+
"""Returns the underlying LLM used to generate responses and score their trustworthiness.
108+
Available base LLMs that you can run TLM with are listed under "model" configuration in TLMOptions.
109+
"""
110+
return cast(str, self._options["model"])

src/cleanlab_tlm/tlm.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,6 @@ async def _get_trustworthiness_score_async(
531531

532532
return {"trustworthiness_score": response_json["confidence_score"]}
533533

534-
def get_model_name(self) -> str:
535-
"""Returns the underlying LLM used to generate responses and score their trustworthiness.
536-
Available base LLMs that you can run TLM with are listed under "model" configuration in [TLMOptions](#class-tlmoptions).
537-
"""
538-
return cast(str, self._options["model"])
539-
540534

541535
class TLMResponse(TypedDict):
542536
"""A typed dict containing the response, trustworthiness score, and additional logs output by the Trustworthy Language Model.

tests/test_chat_completions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
PromptTokensDetails,
1212
)
1313

14+
from cleanlab_tlm.internal.constants import _TLM_DEFAULT_MODEL
1415
from cleanlab_tlm.internal.types import TLMQualityPreset
1516
from cleanlab_tlm.tlm import TLMScore
1617
from cleanlab_tlm.utils.chat_completions import TLMChatCompletion
@@ -22,6 +23,14 @@
2223
test_response = make_text_unique(TEST_RESPONSE)
2324

2425

26+
def test_get_model_name() -> None:
27+
tlm = TLMChatCompletion()
28+
model_name = tlm.get_model_name()
29+
30+
assert model_name == tlm._options["model"]
31+
assert model_name == _TLM_DEFAULT_MODEL
32+
33+
2534
@pytest.mark.parametrize(
2635
"quality_preset",
2736
["base", "low", "medium", "high", "best"],

tests/test_config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import tiktoken
33

44
from cleanlab_tlm.errors import TlmBadRequestError
5+
from cleanlab_tlm.internal.constants import _TLM_DEFAULT_MODEL
56
from cleanlab_tlm.tlm import TLM
67
from cleanlab_tlm.utils.config import (
78
get_default_context_limit,
@@ -14,6 +15,13 @@
1415
tlm_with_default_setting = TLM()
1516

1617

18+
def test_get_model_name(tlm: TLM) -> None:
19+
model_name = tlm.get_model_name()
20+
21+
assert model_name == tlm._options["model"]
22+
assert model_name == _TLM_DEFAULT_MODEL
23+
24+
1725
def test_get_default_model(tlm: TLM) -> None:
1826
assert tlm.get_model_name() == get_default_model()
1927

tests/test_tlm_rag.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ def test_init_with_quality_preset(trustworthy_rag_api_key: str, quality_preset:
201201
assert tlm_rag._quality_preset == quality_preset
202202

203203

204+
def test_get_model_name(trustworthy_rag: TrustworthyRAG) -> None:
205+
model_name = trustworthy_rag.get_model_name()
206+
207+
assert model_name == trustworthy_rag._options["model"]
208+
assert model_name == _TLM_DEFAULT_MODEL
209+
210+
204211
def test_get_evals(trustworthy_rag: TrustworthyRAG) -> None:
205212
evals = trustworthy_rag.get_evals()
206213

0 commit comments

Comments
 (0)