Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Confident ai Deepeval Constants Module

From Leeroopedia
Knowledge Sources
Domains Configuration, LLM_Providers
Last Updated 2026-02-14 09:30 GMT

Overview

Central constants module that defines file paths, environment variable names, the `ProviderSlug` enum for supported LLM providers, and a `slugify` helper used throughout the deepeval framework.

Description

The Constants Module (`deepeval/constants.py`) centralizes all package-wide constants to prevent magic strings from being scattered across the codebase. It defines:

  • File paths: `KEY_FILE` (`.deepeval`) for the API key file name, and `HIDDEN_DIR` (defaults to `.deepeval`, overridable via `DEEPEVAL_CACHE_FOLDER` env var) for the configuration directory.
  • Tracing environment variables: `CONFIDENT_TRACE_VERBOSE`, `CONFIDENT_TRACE_FLUSH`, `CONFIDENT_TRACE_SAMPLE_RATE`, `CONFIDENT_TRACE_ENVIRONMENT`, `CONFIDENT_TRACING_ENABLED`.
  • Metric logging environment variables: `CONFIDENT_METRIC_LOGGING_VERBOSE`, `CONFIDENT_METRIC_LOGGING_FLUSH`, `CONFIDENT_METRIC_LOGGING_SAMPLE_RATE`, `CONFIDENT_METRIC_LOGGING_ENABLED`.
  • Other constants: `CONFIDENT_OPEN_BROWSER`, `CONFIDENT_TEST_CASE_BATCH_SIZE`, and `LOGIN_PROMPT`.
  • ProviderSlug enum: A `str`-`Enum` hybrid that enumerates all 12 supported LLM provider slugs (OpenAI, Azure, Anthropic, Bedrock, DeepSeek, Google, Grok, Kimi, LiteLLM, Local, Ollama, OpenRouter).
  • slugify function: Normalizes a string or `ProviderSlug` value to its lowercase slug form.
  • SUPPORTED_PROVIDER_SLUGS: A `frozenset` for O(1) membership testing.

Usage

Import constants from this module whenever you need to reference provider slugs, hidden directory paths, tracing configuration variable names, or other package-wide constants. This is a foundational dependency used by `key_handler.py`, `telemetry.py`, the tracing subsystem, and the CLI.

Code Reference

Source Location

Signature

class ProviderSlug(str, Enum):
    OPENAI = "openai"
    AZURE = "azure"
    ANTHROPIC = "anthropic"
    BEDROCK = "bedrock"
    DEEPSEEK = "deepseek"
    GOOGLE = "google"
    GROK = "grok"
    KIMI = "kimi"
    LITELLM = "litellm"
    LOCAL = "local"
    OLLAMA = "ollama"
    OPENROUTER = "openrouter"


def slugify(value: Union[str, ProviderSlug]) -> str:
    """Normalize a string or ProviderSlug to its lowercase slug form."""
    return (
        value.value
        if isinstance(value, ProviderSlug)
        else str(value).strip().lower()
    )


SUPPORTED_PROVIDER_SLUGS: frozenset = frozenset(s.value for s in ProviderSlug)

Import

from deepeval.constants import ProviderSlug, slugify, SUPPORTED_PROVIDER_SLUGS
from deepeval.constants import KEY_FILE, HIDDEN_DIR
from deepeval.constants import CONFIDENT_TRACING_ENABLED, CONFIDENT_TRACE_VERBOSE

I/O Contract

Inputs

Name Type Required Description
value Union[str, ProviderSlug] Yes A provider name string or ProviderSlug enum member to normalize (for `slugify`)
DEEPEVAL_CACHE_FOLDER env var No Overrides the default hidden directory path (`.deepeval`)

Outputs

Name Type Description
slugify return str Lowercase slug string for the given provider
ProviderSlug Enum Enumeration of supported LLM provider identifiers
SUPPORTED_PROVIDER_SLUGS frozenset[str] Set of all valid provider slug strings for O(1) lookup
KEY_FILE str File name for persisted API keys (`.deepeval`)
HIDDEN_DIR str Directory name for cached configuration

Usage Examples

Using ProviderSlug Enum

from deepeval.constants import ProviderSlug, slugify, SUPPORTED_PROVIDER_SLUGS

# Check if a provider is supported
provider_name = "openai"
if provider_name in SUPPORTED_PROVIDER_SLUGS:
    print(f"{provider_name} is a supported provider")

# Use enum directly
slug = ProviderSlug.ANTHROPIC
print(slug.value)  # "anthropic"

# Normalize user input
user_input = "  OpenAI  "
normalized = slugify(user_input)  # "openai"

# Normalize from enum
normalized = slugify(ProviderSlug.AZURE)  # "azure"

Using Configuration Constants

import os
from deepeval.constants import CONFIDENT_TRACING_ENABLED, HIDDEN_DIR

# Check if tracing is enabled via environment variable
tracing_on = os.getenv(CONFIDENT_TRACING_ENABLED, "false").lower() == "true"

# Access the hidden configuration directory
config_dir = HIDDEN_DIR  # defaults to ".deepeval"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment