Skip to content

Commit 18087a3

Browse files
authored
Merge branch 'stanfordnlp:main' into main
2 parents d29db15 + 41db5c1 commit 18087a3

File tree

168 files changed

+10557
-2509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+10557
-2509
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name": "🏃", "description": "Run Docker container to upload Python distribution packages to PyPI", "inputs": {"user": {"description": "PyPI user", "required": false}, "password": {"description": "Password for your PyPI user or an access token", "required": false}, "repository-url": {"description": "The repository URL to use", "required": false}, "packages-dir": {"description": "The target directory for distribution", "required": false}, "verify-metadata": {"description": "Check metadata before uploading", "required": false}, "skip-existing": {"description": "Do not fail if a Python package distribution exists in the target package index", "required": false}, "verbose": {"description": "Show verbose output.", "required": false}, "print-hash": {"description": "Show hash values of files to be uploaded", "required": false}, "attestations": {"description": "[EXPERIMENTAL] Enable experimental support for PEP 740 attestations. Only works with PyPI and TestPyPI via Trusted Publishing.", "required": false}}, "runs": {"using": "docker", "image": "docker://ghcr.io/pypa/gh-action-pypi-publish:release-v1"}}

.github/ISSUE_TEMPLATE/bug_report.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
name: Bug Report
3+
description: Report a bug in the project
4+
title: "[Bug] "
5+
labels: bug
6+
body:
7+
- type: markdown
8+
attributes:
9+
value: |
10+
## 🐛 Bug Report
11+
Please fill out all required fields to help us diagnose and fix the issue.
12+
13+
- type: textarea
14+
id: description
15+
attributes:
16+
label: "What happened?"
17+
description: "Clearly describe the unexpected behavior."
18+
placeholder: "Example: When I try to save a file, I get an error message..."
19+
validations:
20+
required: true
21+
22+
- type: textarea
23+
id: steps-to-reproduce
24+
attributes:
25+
label: "Steps to reproduce"
26+
description: "Tell us how to reproduce the issue."
27+
placeholder: "Please provide a code snippet or a github gist for reproducing purpose."
28+
validations:
29+
required: true
30+
31+
- type: input
32+
id: environment
33+
attributes:
34+
label: "DSPy version"
35+
description: "Tell us your DSPy version."
36+
validations:
37+
required: true
38+

.github/ISSUE_TEMPLATE/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
blank_issues_enabled: false
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Feature Request
2+
description: Suggest a new feature or improvement
3+
title: "[Feature] "
4+
labels: enhancement
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
## 🚀 Feature Request
10+
Please fill out the following details.
11+
12+
- type: textarea
13+
id: description
14+
attributes:
15+
label: "What feature would you like to see?"
16+
description: "Describe the feature clearly."
17+
validations:
18+
required: true
19+
20+
- type: checkboxes
21+
id: contribute
22+
attributes:
23+
label: "Would you like to contribute?"
24+
options:
25+
- label: Yes, I'd like to help implement this.
26+
- label: No, I just want to request it.
27+
28+
- type: textarea
29+
id: additional-info
30+
attributes:
31+
label: "Additional Context"
32+
description: "Any links, references, or extra details?"
33+
placeholder: "Example: This feature exists in XYZ tool."

.github/workflows/build_and_release.yml

+40-13
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ jobs:
2323
name: pypi
2424
permissions:
2525
id-token: write # IMPORTANT: mandatory for trusted publishing
26+
contents: write
2627
steps:
2728
- uses: actions/checkout@v4
2829
- name: Set up Python 3.9
2930
uses: actions/setup-python@v3
3031
with:
3132
python-version: "3.9"
3233
- name: Install dependencies
33-
run: python3 -m pip install setuptools wheel twine semver packaging
34+
run: python3 -m pip install --upgrade setuptools wheel twine semver packaging
3435
- name: Get correct version for TestPyPI release
3536
id: check_version
3637
run: |
@@ -41,11 +42,11 @@ jobs:
4142
echo "Version to be used for TestPyPI release: $NEW_VERSION"
4243
echo "::set-output name=version::$NEW_VERSION"
4344
- name: Update version in setup.py
44-
run: sed -i '/#replace_package_version_marker/{n;s/version="[^"]*"/version="${{ steps.check_version.outputs.version }}"/;}' setup.py
45+
run: sed -i '/#replace_package_version_marker/{n;s/__version__="[^"]*"/__version__="${{ steps.check_version.outputs.version }}"/;}' ./dspy/__metadata__.py
4546
- name: Update version in pyproject.toml
4647
run: sed -i '/#replace_package_version_marker/{n;s/version="[^"]*"/version="${{ steps.check_version.outputs.version }}"/;}' pyproject.toml
4748
- name: Update package name in setup.py
48-
run: sed -i '/#replace_package_name_marker/{n;s/name="[^"]*"/name="dspy-ai-test"/;}' setup.py
49+
run: sed -i '/#replace_package_name_marker/{n;s/__name__="[^"]*"/__name__="dspy-ai-test"/;}' ./dspy/__metadata__.py
4950
- name: Update package name in pyproject.toml
5051
run: sed -i '/#replace_package_name_marker/{n;s/name="[^"]*"/name="dspy-ai-test"/;}' pyproject.toml
5152
- name: Build a binary wheel
@@ -62,41 +63,67 @@ jobs:
6263
name: pypi
6364
permissions:
6465
id-token: write # IMPORTANT: mandatory for trusted publishing
66+
contents: write
6567
steps:
6668
- uses: actions/checkout@v4
6769
- name: Set up Python 3.9
6870
uses: actions/setup-python@v3
6971
with:
7072
python-version: "3.9"
7173
- name: Install dependencies
72-
run: python3 -m pip install setuptools wheel twine
74+
run: python3 -m pip install --upgrade setuptools wheel twine
7375
- name: Update version in setup.py (dspy)
74-
run: sed -i '/#replace_package_version_marker/{n;s/version="[^"]*"/version="${{ needs.extract-tag.outputs.version }}"/;}' setup.py
76+
run: sed -i '/#replace_package_version_marker/{n;s/__version__ *= *"[^"]*"/__version__="${{ needs.extract-tag.outputs.version }}"/;}' ./dspy/__metadata__.py
7577
- name: Update version in pyproject.toml
76-
run: sed -i '/#replace_package_version_marker/{n;s/version="[^"]*"/version="${{ needs.extract-tag.outputs.version }}"/;}' pyproject.toml
78+
run: sed -i '/#replace_package_version_marker/{n;s/version *= *"[^"]*"/version="${{ needs.extract-tag.outputs.version }}"/;}' pyproject.toml
7779
# Publish to dspy
7880
- name: Update package name in setup.py
7981
run: |
80-
sed -i '/#replace_package_name_marker/{n;s/name="[^"]*"/name="dspy"/;}' setup.py
82+
sed -i '/#replace_package_name_marker/{n;s/__name__ *= *"[^"]*"/__name__="dspy"/;}' ./dspy/__metadata__.py
8183
- name: Update package name in pyproject.toml
82-
run: sed -i '/#replace_package_name_marker/{n;s/name="[^"]*"/name="dspy"/;}' pyproject.toml
84+
run: sed -i '/#replace_package_name_marker/{n;s/name *= *"[^"]*"/name="dspy"/;}' pyproject.toml
85+
# Remove pyproject.toml temporarily to avoid conflicts
86+
- name: Temporarily remove pyproject.toml
87+
run: mv pyproject.toml pyproject.toml.bak
8388
- name: Build a binary wheel
8489
run: python3 setup.py sdist bdist_wheel
8590
- name: Publish distribution 📦 to PyPI (dspy)
8691
uses: pypa/gh-action-pypi-publish@release/v1 # This requires a trusted publisher to be setup in pypi
8792
with:
8893
attestations: false
89-
# Publish to dspy-ai
94+
# Publish to dspy-ai
9095
- name: Update version in setup.py (dspy-ai)
91-
run: sed -i '/#replace_package_version_marker/{n;s/version="[^"]*"/version="${{ needs.extract-tag.outputs.version }}"/;}' ./dspy/.internal_dspyai/setup.py
96+
run: sed -i '/#replace_package_version_marker/{n;s/version *= *"[^"]*"/version="${{ needs.extract-tag.outputs.version }}"/;}' ./dspy/.internal_dspyai/setup.py
9297
- name: Update package name in setup.py
93-
run: sed -i '/#replace_package_name_marker/{n;s/name="[^"]*"/name="dspy-ai"/;}' ./dspy/.internal_dspyai/setup.py
98+
run: sed -i '/#replace_package_name_marker/{n;s/name *= *"[^"]*"/name="dspy-ai"/;}' ./dspy/.internal_dspyai/setup.py
9499
- name: Update dspy dependency version in setup.py
95100
run: |
96-
sed -i '/#replace_dspy_version_marker/{n;s/dspy==[^"]*/dspy>=${{ needs.extract-tag.outputs.version }}/;}' ./dspy/.internal_dspyai/setup.py
101+
sed -i '/#replace_dspy_version_marker/{n;s/dspy>=[^"]*/dspy>=${{ needs.extract-tag.outputs.version }}/;}' ./dspy/.internal_dspyai/setup.py
97102
- name: Build a binary wheel
98103
run: python3 ./dspy/.internal_dspyai/setup.py sdist bdist_wheel
99104
- name: Publish distribution 📦 to PyPI (dspy-ai)
100105
uses: pypa/gh-action-pypi-publish@release/v1 # This requires a trusted publisher to be setup in pypi
101106
with:
102-
attestations: false
107+
attestations: false
108+
# Restore pyproject.toml
109+
- name: Restore pyproject.toml
110+
run: mv pyproject.toml.bak pyproject.toml
111+
- uses: stefanzweifel/git-auto-commit-action@v5 # auto commit changes to main
112+
with:
113+
commit_message: Update versions
114+
create_branch: true
115+
branch: release-${{ needs.extract-tag.outputs.version }}
116+
- name: Checkout main branch
117+
run: |
118+
git fetch origin
119+
git checkout main
120+
- name: Configure git user
121+
run: |
122+
git config --global user.email "[email protected]"
123+
git config --global user.name "Github Actions"
124+
- name: Merge release branch into main
125+
run: |
126+
git merge --no-ff release-${{ needs.extract-tag.outputs.version }}
127+
- name: Push changes to main
128+
run: |
129+
git push origin main

.github/workflows/docs-push.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ jobs:
1515
if: github.event_name == 'pull_request'
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v3
18+
- name: Checkout code
19+
uses: actions/checkout@v3
1920
- name: Set up Node.js
2021
uses: actions/setup-node@v3
2122
with:

.github/workflows/run_tests.yml

+23-21
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
types: [opened, synchronize, reopened]
99

1010
env:
11-
POETRY_VERSION: "1.7.1"
11+
POETRY_VERSION: "2.0.0"
1212

1313
jobs:
1414
fix:
@@ -41,28 +41,36 @@ jobs:
4141
python-version: ["3.9"]
4242
steps:
4343
- uses: actions/checkout@v4
44+
- uses: actions/setup-python@v5
45+
with:
46+
python-version: ${{ matrix.python-version }}
47+
- name: Install Deno
48+
run: |
49+
curl -fsSL https://deno.land/install.sh | sh
50+
echo "Deno installed"
51+
52+
- name: Add Deno to PATH
53+
run: echo "${HOME}/.deno/bin" >> $GITHUB_PATH
54+
55+
- name: Verify Deno installation
56+
run: deno --version
57+
4458
- name: Load cached Poetry installation
4559
id: cached-poetry
4660
uses: actions/cache@v3
4761
with:
4862
path: ~/.local
4963
key: poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
5064
- name: Install Poetry
51-
if: steps.cached-poetry.outputs.cache-hit != 'true'
52-
uses: snok/install-poetry@v1
53-
- name: Set up python ${{ matrix.python-version }}
54-
uses: actions/setup-python@v5
55-
with:
56-
python-version: ${{ matrix.python-version }}
57-
cache: "poetry"
65+
run: python -m pip install --upgrade "poetry==${{ env.POETRY_VERSION }}"
5866
- name: Install dependencies
5967
run: poetry install --no-interaction
6068
- name: Run lint with tests
6169
uses: chartboost/ruff-action@v1
6270
with:
6371
args: check --fix-only
6472
- name: Run tests with pytest
65-
run: poetry run pytest tests/ --ignore=tests/reliability
73+
run: poetry run pytest tests/
6674

6775
build_poetry:
6876
name: Build Poetry
@@ -78,14 +86,11 @@ jobs:
7886
with:
7987
path: ~/.local
8088
key: poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
81-
- name: Install Poetry
82-
if: steps.cached-poetry.outputs.cache-hit != 'true'
83-
uses: snok/install-poetry@v1
84-
- name: Set up python ${{ matrix.python-version }}
85-
uses: actions/setup-python@v5
89+
- uses: actions/setup-python@v5
8690
with:
8791
python-version: ${{ matrix.python-version }}
88-
cache: "poetry"
92+
- name: Install Poetry
93+
run: python -m pip install --upgrade "poetry==${{ env.POETRY_VERSION }}"
8994
- name: Build
9095
run: poetry build
9196
- name: Install built package
@@ -107,13 +112,10 @@ jobs:
107112
with:
108113
path: ~/.local
109114
key: poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
110-
- name: Install Poetry
111-
if: steps.cached-poetry.outputs.cache-hit != 'true'
112-
uses: snok/install-poetry@v1
113-
- name: Set up python ${{ matrix.python-version }}
114-
uses: actions/setup-python@v5
115+
- uses: actions/setup-python@v5
115116
with:
116117
python-version: ${{ matrix.python-version }}
117-
cache: "poetry"
118+
- name: Install Poetry
119+
run: python -m pip install --upgrade "poetry==${{ env.POETRY_VERSION }}"
118120
- name: Run setup.py build
119121
run: python setup.py build

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ dummy.csv
6262
docs/docs/**/*.json*
6363
*.index
6464
*.pkl
65+
*.tar.gz

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.github/

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
**Documentation:** [DSPy Docs](https://dspy.ai/)
1010

11-
[![Downloads](https://static.pepy.tech/badge/dspy-ai)](https://pepy.tech/project/dspy-ai) [![Downloads](https://static.pepy.tech/badge/dspy/month)](https://pepy.tech/project/dspy)
11+
[![PyPI Downloads](https://static.pepy.tech/badge/dspy)](https://pepy.tech/projects/dspy) [![PyPI Downloads](https://static.pepy.tech/badge/dspy/month)](https://pepy.tech/projects/dspy)
1212

1313

1414
----
@@ -42,6 +42,10 @@ pip install git+https://github.com/stanfordnlp/dspy.git
4242

4343
## 📜 Citation & Reading More
4444

45+
If you're looking to understand the framework, please go to the [DSPy Docs at dspy.ai](https://dspy.ai).
46+
47+
If you're looking to understand the underlying research, this is a set of our papers:
48+
4549
**[Jun'24] [Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs](https://arxiv.org/abs/2406.11695)**
4650
**[Oct'23] [DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines](https://arxiv.org/abs/2310.03714)**
4751
[Jul'24] [Fine-Tuning and Prompt Optimization: Two Great Steps that Work Better Together](https://arxiv.org/abs/2407.10930)

docs/README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ To build and test the documentation locally:
1616
pip install -r requirements.txt
1717
```
1818

19-
3. Run the build command:
19+
3. In docs/ directory, run the command below to generate the API docs and index them:
20+
```bash
21+
cd docs/
22+
python scripts/generate_api_docs.py
23+
python scripts/generate_api_summary.py
24+
```
25+
26+
4. Run the build command:
2027
```bash
2128
mkdocs build
2229
```

docs/docs/api/adapters/Adapter.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# dspy.Adapter
2+
3+
::: dspy.Adapter
4+
handler: python
5+
options:
6+
members:
7+
- __call__
8+
- format
9+
- format_finetune_data
10+
- parse
11+
show_source: true
12+
show_undocumented_members: true
13+
show_root_heading: true
14+
show_inherited_members: true
15+
heading_level: 2
16+
docstring_style: google
17+
show_root_full_path: true
18+
show_object_full_path: false
19+
separate_signature: false

docs/docs/api/adapters/ChatAdapter.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# dspy.ChatAdapter
2+
3+
::: dspy.ChatAdapter
4+
handler: python
5+
options:
6+
members:
7+
- __call__
8+
- format
9+
- format_fields
10+
- format_finetune_data
11+
- format_turn
12+
- parse
13+
show_source: true
14+
show_undocumented_members: true
15+
show_root_heading: true
16+
show_inherited_members: true
17+
heading_level: 2
18+
docstring_style: google
19+
show_root_full_path: true
20+
show_object_full_path: false
21+
separate_signature: false

docs/docs/api/adapters/JSONAdapter.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# dspy.JSONAdapter
2+
3+
::: dspy.JSONAdapter
4+
handler: python
5+
options:
6+
members:
7+
- __call__
8+
- format
9+
- format_fields
10+
- format_finetune_data
11+
- format_turn
12+
- parse
13+
show_source: true
14+
show_undocumented_members: true
15+
show_root_heading: true
16+
show_inherited_members: true
17+
heading_level: 2
18+
docstring_style: google
19+
show_root_full_path: true
20+
show_object_full_path: false
21+
separate_signature: false

0 commit comments

Comments
 (0)