Skip to content

feat(checks): add pydantic-settings for default model and config#2581

Merged
kevinmessiaen merged 6 commits into
mainfrom
cursor/pydantic-checks-settings-f16d
Jul 8, 2026
Merged

feat(checks): add pydantic-settings for default model and config#2581
kevinmessiaen merged 6 commits into
mainfrom
cursor/pydantic-checks-settings-f16d

Conversation

@kevinmessiaen

Copy link
Copy Markdown
Member

Summary

Adds pydantic-settings to giskard-checks so library configuration can be driven by environment variables (or a .env file), with set_default_generator() retained as a runtime override.

Settings

New GiskardChecksSettings class (GISKARD_CHECKS_* prefix):

Env var Purpose Default
GISKARD_CHECKS_DEFAULT_MODEL Default LLM for checks/scan openai/gpt-4o-mini
GISKARD_CHECKS_DEFAULT_EMBEDDING_MODEL Default embedding model text-embedding-3-small
GISKARD_CHECKS_MAX_REPORTED_FAILURES Suite report failure cap unlimited
GISKARD_CHECKS_DISABLE_RICH_PRETTY Disable rich REPL pretty-print false

Precedence: set_default_generator() / set_default_embedding_model() runtime overrides beat environment settings.

Impact on scan

giskard-scan already calls get_default_generator() for recommendations — it automatically picks up GISKARD_CHECKS_DEFAULT_MODEL with no scan code changes.

CI / tests

  • Integration workflow for checks now sets GISKARD_CHECKS_DEFAULT_MODEL and GISKARD_CHECKS_DEFAULT_EMBEDDING_MODEL instead of TEST_MODEL.
  • Integration test fixtures use get_default_generator() instead of hardcoded model strings.
  • New unit tests cover settings resolution, validation, and override precedence.

Verification

make check          # passed
make test-unit PACKAGE=giskard-checks  # 727 passed, 4 skipped
make test-unit PACKAGE=giskard-scan    # 153 passed
Open in Web Open in Cursor 

Introduce GiskardChecksSettings backed by pydantic-settings so checks
and scan can configure the default LLM/embedding models and other
library options via GISKARD_CHECKS_* environment variables.

- Wire get_default_generator/get_default_embedding_model to settings
- Consolidate max_reported_failures and disable_rich_pretty into settings
- Update integration tests and CI to use GISKARD_CHECKS_DEFAULT_MODEL
- Add unit tests for settings resolution and precedence

Co-authored-by: Kevin Messiaen <kevinmessiaen@users.noreply.github.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces pydantic-settings to manage configuration via environment variables and .env files, replacing direct os.getenv calls with a structured GiskardChecksSettings class. Feedback focuses on avoiding eager settings instantiation at import time in __init__.py, removing unnecessary caching via @lru_cache to keep settings dynamic, and refining the max_reported_failures validator to prevent booleans from being incorrectly treated as integers.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread libs/giskard-checks/src/giskard/checks/__init__.py
Comment thread libs/giskard-checks/src/giskard/checks/settings.py Outdated
Comment thread libs/giskard-checks/src/giskard/checks/settings.py Outdated
- Revert import-time get_settings() for rich.pretty (use os.getenv)
- Remove @lru_cache so settings stay responsive to env changes
- Reject bool values in max_reported_failures validator

Co-authored-by: Kevin Messiaen <kevinmessiaen@users.noreply.github.com>
- Unify disable_rich_pretty on get_settings() in __init__.py
- Inline max_reported_failures lookup; move env var constant to settings
- Remove unused set_default_embedding_model and runtime embedding override
- Shorten max_reported_failures validator
- Promote reset_default_generator fixture to package conftest

Co-authored-by: Kevin Messiaen <kevinmessiaen@users.noreply.github.com>

@davidberenstein1957 davidberenstein1957 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a minor remark about reasoning mode for model settings.

_default_generator: BaseGenerator | None = None
_default_embedding_model: BaseEmbeddingModel | None = None

DEFAULT_MODEL = "openai/gpt-4o-mini"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also give control over reasonign modes?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now we don't really set reasoning mode globally. Each call side can set a value.

But long term we will probably have something like this:

EASY_TASK_MODEL = {"model": ..., "reasoning_effort": "low"}
HARD_TASK_MODEL = {"model": ..., "reasoning_effort": "high"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants