Skip to content

Commit 42d1b62

Browse files
Fix - expose options and quality_preset props (#86)
1 parent 3e8cd3f commit 42d1b62

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

CHANGELOG.md

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

88
## [Unreleased]
99

10+
## [1.0.18] 2025-06-3
11+
12+
- Expose `options` and `quality_preset` properties for `Validator.validate()`
13+
1014
## [1.0.17] 2025-06-3
1115

1216
- Refactor `validate()` to use `/validate` endpoint from Codex backend and leverage this default logic
@@ -86,7 +90,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8690

8791
- Initial release of the `cleanlab-codex` client library.
8892

89-
[Unreleased]: https://github.com/cleanlab/cleanlab-codex/compare/v1.0.17...HEAD
93+
[Unreleased]: https://github.com/cleanlab/cleanlab-codex/compare/v1.0.18...HEAD
94+
[1.0.18]: https://github.com/cleanlab/cleanlab-codex/compare/v1.0.17...v1.0.18
9095
[1.0.17]: https://github.com/cleanlab/cleanlab-codex/compare/v1.0.16...v1.0.17
9196
[1.0.16]: https://github.com/cleanlab/cleanlab-codex/compare/v1.0.15...v1.0.16
9297
[1.0.15]: https://github.com/cleanlab/cleanlab-codex/compare/v1.0.14...v1.0.15

src/cleanlab_codex/__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.0.17"
2+
__version__ = "1.0.18"

src/cleanlab_codex/validator.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44

55
from __future__ import annotations
66

7-
from typing import Any, Callable, Optional
7+
from typing import TYPE_CHECKING as _TYPE_CHECKING
8+
from typing import Any, Callable, Literal, Optional
89

910
from cleanlab_tlm import TrustworthyRAG
1011

1112
from cleanlab_codex.internal.validator import validate_thresholds
1213
from cleanlab_codex.project import Project
1314

15+
if _TYPE_CHECKING:
16+
from codex.types.project_validate_params import Options as ProjectValidateOptions
17+
1418

1519
class Validator:
1620
def __init__(
@@ -54,6 +58,8 @@ def validate(
5458
prompt: Optional[str] = None,
5559
form_prompt: Optional[Callable[[str, str], str]] = None,
5660
metadata: Optional[dict[str, Any]] = None,
61+
options: Optional[ProjectValidateOptions] = None,
62+
quality_preset: Literal["best", "high", "medium", "low", "base"] = "medium",
5763
) -> dict[str, Any]:
5864
"""Evaluate whether the AI-generated response is bad, and if so, request an alternate expert answer.
5965
If no expert answer is available, this query is still logged for SMEs to answer.
@@ -65,6 +71,8 @@ def validate(
6571
prompt (str, optional): Optional prompt representing the actual inputs (combining query, context, and system instructions into one string) to the LLM that generated the response.
6672
form_prompt (Callable[[str, str], str], optional): Optional function to format the prompt based on query and context. Cannot be provided together with prompt, provide one or the other. This function should take query and context as parameters and return a formatted prompt string. If not provided, a default prompt formatter will be used. To include a system prompt or any other special instructions for your LLM, incorporate them directly in your custom form_prompt() function definition.
6773
metadata (dict, optional): Additional custom metadata to associate with the query logged in the Codex Project.
74+
options (ProjectValidateOptions, optional): Typed dict of advanced configuration options for the Trustworthy Language Model.
75+
quality_preset (Literal["best", "high", "medium", "low", "base"], optional): The quality preset to use for the TLM or Trustworthy RAG API.
6876
6977
Returns:
7078
dict[str, Any]: A dictionary containing:
@@ -91,6 +99,8 @@ def validate(
9199
response=response,
92100
custom_eval_thresholds=self._custom_eval_thresholds,
93101
custom_metadata=metadata,
102+
options=options,
103+
quality_preset=quality_preset,
94104
)
95105

96106
formatted_eval_scores = {

0 commit comments

Comments
 (0)