Skip to main content

Add support for DSPy profiles

Project description

DSPy Profiles

PyPI Version Python Version PyPI Downloads Documentation Tests Coverage License Managed by uv Code style: black Ruff Project Status

A companion tool for the DSPy framework to manage configuration profiles, inspired by the AWS CLI.

dspy-profiles allows you to define, switch between, and manage different DSPy configurations for various environments (e.g., development, staging, production) without cluttering your code.


Requirements

  • Python 3.12+
  • DSPy 3.0+ (installed alongside your project)

The Problem

When working with DSPy, you often need to switch between different language models, retrieval models, and settings. Managing this directly in your code can be messy, error-prone, and insecure.

The Solution

dspy-profiles moves this configuration out of your code and into a simple profiles.toml file. It provides a powerful CLI and a clean Python API to manage and use these profiles seamlessly. The tool will automatically find your profiles.toml whether it's in your local project directory or in the global ~/.dspy/ folder.


Key Features

  • Declarative Profiles: Define all your environment settings in a clear, human-readable TOML file.
  • Powerful CLI: A rich command-line interface lets you manage your profiles without ever leaving the terminal.
  • Seamless Python API: Activate profiles in your Python code with an elegant and intuitive API.
  • Profile Inheritance: Create base profiles and extend them for different environments to avoid repetition.
  • Environment Precedence: A clear and predictable activation logic ensures the right profile is always used.
  • Validation & Testing: validate and test commands to ensure your profiles are correct and your models are reachable.

Installation

# With pip
pip install dspy-profiles

# With uv
uv add dspy-profiles

# Or run it directly without installation
uvx dspy-profiles --help

# Or as a tool in your cli
uv tool install dspy-profiles
dspy-profiles --help

Quickstart

  1. Initialize a default profile interactively:

    dspy-profiles init
    

    This will prompt you for your language model and optionally your API key and API base.

  2. Use it in your Python code:

    import dspy
    from dspy_profiles import profile
    
    with profile("default"):
        # Your DSPy code here, now using the settings from your 'default' profile.
        predictor = dspy.Predict("question -> answer")
        response = predictor(question="What is the capital of France?")
        print(response.answer)
    
  3. Run any script with a profile, without changing your code:

    # The new, convenient way to run any script with a profile
    dspy-run my_script.py
    
    # Specify a different profile, or run non-python commands
    dspy-run --profile production -- pytest
    

Full Documentation

For a complete guide, including advanced features and the full API and CLI reference, please visit the official documentation site.

Quick links:


Project Status & Roadmap

The project is under active development. All core features are implemented and stable.

  • [x] Phase 1: DX, Packaging & Documentation: Professional PyPI packaging, CI/CD, and a full documentation site.
  • [x] Phase 2: Core CLI & Env Var Enhancements: import, diff, run, and robust activation precedence.
  • [x] Phase 3: Advanced Profile Features: Profile composition (extends), inline overrides, and validate/test commands.
  • [x] Phase 4: Python API & Runtime Utilities: Programmatic shortcuts like lm() and runtime introspection with current_profile().
  • [x] Phase 5: Developer Experience Overhaul: A major refactor of the CLI, API, and documentation for clarity, stability, and ease of use.
  • [x] Phase 6: QoL & Advanced Workflows: An interactive init wizard, profile import/export, and async-friendly decorators.

See the PROJECT.md file for detailed specifications.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dspy_profiles-0.3.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dspy_profiles-0.3.0-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file dspy_profiles-0.3.0.tar.gz.

File metadata

  • Download URL: dspy_profiles-0.3.0.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dspy_profiles-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ae623245e1e46677710ebd5e1715f05c2fcde1e6064f7f04aad58a5d05063618
MD5 510b254690410bbba0707a8b0694c3bf
BLAKE2b-256 f657a4f234c5604bc0151ff38553237d09e77fb656b3643b69c7403b580f3479

See more details on using hashes here.

Provenance

The following attestation bundles were made for dspy_profiles-0.3.0.tar.gz:

Publisher: release.yml on nielsgl/dspy-profiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dspy_profiles-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: dspy_profiles-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dspy_profiles-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d87c8a07a4dc0fb4de358a15638a1794857cd539342523028ec7d22d42a4ee1
MD5 f4d7dde97ae95e36c88e982dee9fdc88
BLAKE2b-256 8ea830ee7fcdb27c1c63f93454877d775035a50fb12fd1745e844e7b80e2d500

See more details on using hashes here.

Provenance

The following attestation bundles were made for dspy_profiles-0.3.0-py3-none-any.whl:

Publisher: release.yml on nielsgl/dspy-profiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page