Add support for DSPy profiles
Project description
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. 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:
validateandtestcommands 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
-
Initialize a default profile interactively:
dspy-profiles initThis will prompt you for your language model and optionally your API key and API base.
-
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)
-
Run any script with a profile:
dspy-profiles run --profile default -- python my_script.py # You can also run it as a module python -m dspy_profiles run --profile default -- python my_script.py
Full Documentation
For a complete guide, including advanced features and the full API and CLI reference, please visit the official documentation site.
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, andvalidate/testcommands. - [x] Phase 4: Python API & Runtime Utilities: Programmatic shortcuts like
lm()and runtime introspection withcurrent_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
initwizard, 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dspy_profiles-0.1.4.tar.gz.
File metadata
- Download URL: dspy_profiles-0.1.4.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d3cbaba9ae9fcbf1e2dcaf27331b6e25bb0132cfd1aa6dd564057f31144b740
|
|
| MD5 |
ef02c3ada21de0cfe516c07e533c87cd
|
|
| BLAKE2b-256 |
23416c87c50a9d0e989a8ea6af14aef51f27d51a2a4ccdab21826c4f371f8a4d
|
Provenance
The following attestation bundles were made for dspy_profiles-0.1.4.tar.gz:
Publisher:
publish.yml on nielsgl/dspy-profiles
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dspy_profiles-0.1.4.tar.gz -
Subject digest:
5d3cbaba9ae9fcbf1e2dcaf27331b6e25bb0132cfd1aa6dd564057f31144b740 - Sigstore transparency entry: 444911244
- Sigstore integration time:
-
Permalink:
nielsgl/dspy-profiles@5e2482d093a18b41b4a6e81b92f1035f6c14de7b -
Branch / Tag:
refs/tags/0.1.4 - Owner: https://github.com/nielsgl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5e2482d093a18b41b4a6e81b92f1035f6c14de7b -
Trigger Event:
release
-
Statement type:
File details
Details for the file dspy_profiles-0.1.4-py3-none-any.whl.
File metadata
- Download URL: dspy_profiles-0.1.4-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3d12e0e498fd06bc25b18b99657f686feacf8ae3797d046fdc8aca654a404d5
|
|
| MD5 |
c414d4576552e60df584e4ab39f4710e
|
|
| BLAKE2b-256 |
20d7c850f6d196b124716be5b2ae02547f44fd79c7b7bd5b7cdd6c39d2479820
|
Provenance
The following attestation bundles were made for dspy_profiles-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on nielsgl/dspy-profiles
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dspy_profiles-0.1.4-py3-none-any.whl -
Subject digest:
a3d12e0e498fd06bc25b18b99657f686feacf8ae3797d046fdc8aca654a404d5 - Sigstore transparency entry: 444911253
- Sigstore integration time:
-
Permalink:
nielsgl/dspy-profiles@5e2482d093a18b41b4a6e81b92f1035f6c14de7b -
Branch / Tag:
refs/tags/0.1.4 - Owner: https://github.com/nielsgl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5e2482d093a18b41b4a6e81b92f1035f6c14de7b -
Trigger Event:
release
-
Statement type: