Skip to content

Commit 6e4d279

Browse files
authored
Merge pull request #451 from validmind/juan/sc-13271/pass-test-parameters-to-llm-test-result-description-generation
[SC-13271] Pass test parameters to LLM test result description generation
2 parents 8afcfa6 + cf48b45 commit 6e4d279

5 files changed

Lines changed: 13 additions & 5 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "validmind"
3-
version = "2.10.4"
3+
version = "2.10.5"
44
description = "ValidMind Library"
55
readme = "README.pypi.md"
66
requires-python = ">=3.9,<3.13"

validmind/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.10.4"
1+
__version__ = "2.10.5"

validmind/ai/test_descriptions.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import json
66
import os
77
from concurrent.futures import ThreadPoolExecutor
8-
from typing import List, Optional, Union
8+
from typing import Any, Dict, List, Optional, Union
99

1010
import tiktoken
1111

@@ -76,6 +76,7 @@ def generate_description(
7676
title: Optional[str] = None,
7777
instructions: Optional[str] = None,
7878
additional_context: Optional[str] = None,
79+
params: Optional[Dict[str, Any]] = None,
7980
):
8081
"""Generate the description for the test results."""
8182
from validmind.api_client import generate_test_result_description
@@ -124,6 +125,7 @@ def generate_description(
124125
"figures": [figure._get_b64_url() for figure in figures or []],
125126
"additional_context": additional_context,
126127
"instructions": instructions,
128+
"params": params,
127129
}
128130
)["content"]
129131

@@ -137,6 +139,7 @@ def background_generate_description(
137139
title: Optional[str] = None,
138140
instructions: Optional[str] = None,
139141
additional_context: Optional[str] = None,
142+
params: Optional[Dict[str, Any]] = None,
140143
):
141144
def wrapped():
142145
try:
@@ -150,6 +153,7 @@ def wrapped():
150153
title=title,
151154
instructions=instructions,
152155
additional_context=additional_context,
156+
params=params,
153157
),
154158
True,
155159
)
@@ -181,6 +185,7 @@ def get_result_description(
181185
title: Optional[str] = None,
182186
instructions: Optional[str] = None,
183187
additional_context: Optional[str] = None,
188+
params: Optional[Dict[str, Any]] = None,
184189
):
185190
"""Get the metadata dictionary for a test or metric result.
186191
@@ -204,6 +209,7 @@ def get_result_description(
204209
should_generate (bool): Whether to generate the description or not. Defaults to True.
205210
instructions (Optional[str]): Instructions for the LLM to generate the description.
206211
additional_context (Optional[str]): Additional context for the LLM to generate the description.
212+
params (Optional[Dict[str, Any]]): Test parameters used to customize test behavior.
207213
208214
Returns:
209215
str: The description to be logged with the test results.
@@ -232,6 +238,7 @@ def get_result_description(
232238
title=title,
233239
instructions=_instructions,
234240
additional_context=additional_context,
241+
params=params,
235242
)
236243

237244
else:

validmind/tests/data_validation/TooManyZeroValues.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ def TooManyZeroValues(
2323
The 'TooManyZeroValues' test is utilized to identify numerical columns in the dataset that may present a quantity
2424
of zero values considered excessive. The aim is to detect situations where these may implicate data sparsity or a
2525
lack of variation, limiting their effectiveness within a machine learning model. The definition of 'too many' is
26-
quantified as a percentage of total values, with a default set to 3%.
26+
quantified as a percentage of total values, with a default set to 0.03%.
2727
2828
### Test Mechanism
2929
3030
This test is conducted by looping through each column in the dataset and categorizing those that pertain to
3131
numerical data. On identifying a numerical column, the function computes the total quantity of zero values and
3232
their ratio to the total row count. Should the proportion exceed a pre-set threshold parameter, set by default at
33-
0.03 or 3%, the column is considered to have failed the test. The results for each column are summarized and
33+
0.03%, the column is considered to have failed the test. The results for each column are summarized and
3434
reported, indicating the count and percentage of zero values for each numerical column, alongside a status
3535
indicating whether the column has passed or failed the test.
3636

validmind/tests/run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ def run_test( # noqa: C901
461461
title=title,
462462
instructions=instructions,
463463
additional_context=additional_context,
464+
params=result.params,
464465
)
465466

466467
if show:

0 commit comments

Comments
 (0)