Welcome to dspy-profiles¶
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.
The Problem
When working with DSPy, you often need to switch between different language models, retrieval models, and settings. For example:
- Using a cheap, fast model like
gpt-4o-mini
in development. - Using a powerful model like
claude-3-opus
in production. - Pointing to a staging database for your retrieval model.
- Toggling settings like
track_usage
.
Managing this configuration 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, centralized profiles.toml
file. It provides a powerful CLI and a clean Python API to manage and use these profiles seamlessly.
Configuration Hierarchy¶
dspy-profiles
locates your configuration file with a clear, git
-like precedence:
- Project-Specific File: It searches for a
profiles.toml
in the current directory and its parent directories. This allows you to commit project-specific profiles directly to your repository. - Environment Variable: You can set the
DSPY_PROFILES_PATH
environment variable to point to a specific configuration file. - Global File: If neither of the above is found, it falls back to the global default at
~/.dspy/profiles.toml
.
Key Features¶
dspy-profiles
is designed to be a comprehensive solution for DSPy configuration management.
Define all your environment settings in a clear, human-readable TOML file.
A rich command-line interface lets you manage your profiles without ever leaving the terminal.
dspy-profiles init
: Interactively create a new profile.dspy-profiles list
: See all your available profiles.dspy-profiles show <name>
: View the full configuration of a profile.dspy-profiles diff <a a> <b b>
: Compare two profiles.dspy-run ...
: The star of the show. Execute any script with a profile, no code changes needed.
Keep your DSPy code completely clean of configuration. Use dspy-run
to activate profiles from the command line, or use the elegant context manager for fine-grained control.
- Profile Inheritance: Create base profiles and extend them for different environments.
- Environment Precedence: A clear and predictable activation logic ensures the right profile is always used.
- Validation:
dspy-profiles validate
checks your configuration file for correctness. - Connectivity Testing:
dspy-profiles test <name>
ensures your settings are correct and your models are reachable.
Get Started¶
Ready to streamline your DSPy workflow?