Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 66 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ description = "ValidMind Library"
license = "Commercial License"
name = "validmind"
readme = "README.pypi.md"
version = "2.8.3"
version = "2.8.4"

[tool.poetry.dependencies]
python = ">=3.8.1,<3.12"
aiohttp = {extras = ["speedups"], version = "*"}
anywidget = "^0.9.13"
arch = "*"
bert-score = ">=0.3.13"
catboost = "*"
Expand All @@ -36,7 +38,6 @@ plotly = "*"
plotly-express = "*"
polars = "*"
pycocoevalcap = {version = "^1.2", optional = true}
python = ">=3.8.1,<3.12"
python-dotenv = "*"
ragas = {version = ">=0.2.3", optional = true}
rouge = ">=1"
Expand Down
2 changes: 1 addition & 1 deletion validmind/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.8.3"
__version__ = "2.8.4"
3 changes: 2 additions & 1 deletion validmind/ai/test_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def get_result_description(
# Check the feature flag first, then the environment variable
llm_descriptions_enabled = (
client_config.can_generate_llm_test_descriptions()
and os.getenv("VALIDMIND_LLM_DESCRIPTIONS_ENABLED", "1") not in ["0", "false"]
and os.getenv("VALIDMIND_LLM_DESCRIPTIONS_ENABLED", "1").lower()
not in ["0", "false"]
)

# TODO: fix circular import
Expand Down
6 changes: 5 additions & 1 deletion validmind/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def init(
api_host: Optional[str] = None,
model: Optional[str] = None,
monitoring: bool = False,
generate_descriptions: Optional[bool] = None,
):
"""
Initializes the API client instances and calls the /ping endpoint to ensure
Expand All @@ -209,7 +210,7 @@ def init(
api_secret (str, optional): The API secret. Defaults to None.
api_host (str, optional): The API host. Defaults to None.
monitoring (bool): The ongoing monitoring flag. Defaults to False.

generate_descriptions (bool): Whether to use GenAI to generate test result descriptions. Defaults to True.
Raises:
ValueError: If the API key and secret are not provided
"""
Expand All @@ -235,6 +236,9 @@ def init(

_monitoring = monitoring

if generate_descriptions is not None:
os.environ["VALIDMIND_LLM_DESCRIPTIONS_ENABLED"] = str(generate_descriptions)

reload()


Expand Down
15 changes: 8 additions & 7 deletions validmind/tests/model_validation/ragas/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@

import os

from validmind.ai.utils import get_client_and_model
from validmind.client_config import client_config
from validmind.ai.utils import get_client_and_model, is_configured

EMBEDDINGS_MODEL = "text-embedding-3-small"


def get_ragas_config():
if not client_config.can_generate_llm_test_descriptions():
raise ValueError(
"LLM based descriptions are not enabled in the current configuration."
)

# import here since its an optional dependency
try:
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
except ImportError:
raise ImportError("Please run `pip install validmind[llm]` to use LLM tests")

if not is_configured():
raise ValueError(
"LLM is not configured. Please set an `OPENAI_API_KEY` environment variable "
"or ensure that you are connected to the ValidMind API and ValidMind AI is "
"enabled for your account."
)

client, model = get_client_and_model()
os.environ["OPENAI_API_BASE"] = str(client.base_url)

Expand Down
9 changes: 5 additions & 4 deletions validmind/tests/prompt_validation/ai_powered_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import re

from validmind.ai.utils import get_client_and_model
from validmind.client_config import client_config
from validmind.ai.utils import get_client_and_model, is_configured

missing_prompt_message = """
Cannot run prompt validation tests on a model with no prompt.
Expand All @@ -25,9 +24,11 @@ def call_model(
system_prompt: str, user_prompt: str, temperature: float = 0.0, seed: int = 42
):
"""Call LLM with the given prompts and return the response"""
if not client_config.can_generate_llm_test_descriptions():
if not is_configured():
raise ValueError(
"LLM based descriptions are not enabled for your organization."
"LLM is not configured. Please set an `OPENAI_API_KEY` environment variable "
"or ensure that you are connected to the ValidMind API and ValidMind AI is "
"enabled for your account."
)

client, model = get_client_and_model()
Expand Down