Skip to content

Commit 759a95b

Browse files
Merge remote-tracking branch 'upstream/main' into fix-streaming-literal-brackets
2 parents d6e88bb + f1260ff commit 759a95b

146 files changed

Lines changed: 12884 additions & 1675 deletions

File tree

Some content is hidden

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

‎.github/.internal_dspyai/pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#replace_package_name_marker
33
name="dspy-ai"
44
#replace_package_version_marker
5-
version="3.4.0b1"
5+
version="3.4.0"
66
description = "DSPy"
77
readme = {text = "`dspy-ai` is a compatibility alias for the [dspy](https://pypi.org/project/dspy/) package. Install `dspy` instead: `pip install dspy`.", content-type = "text/markdown"}
88
authors = [
@@ -11,7 +11,7 @@ authors = [
1111
license = { text = "MIT License" }
1212
requires-python = ">=3.9"
1313
#replace_dspy_version_marker
14-
dependencies = ["dspy>=3.4.0b1"]
14+
dependencies = ["dspy>=3.4.0"]
1515
urls = { "Homepage" = "https://github.com/stanfordnlp/dsp" }
1616

1717
[build-system]

‎.github/workflows/bootstrap-versioned-docs.yml‎

Lines changed: 0 additions & 82 deletions
This file was deleted.

‎.github/workflows/build_and_release.yml‎

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ jobs:
134134
(cd "$RUNNER_TEMP" && python -c 'import dspy; assert dspy.PythonInterpreter().execute("6 * 7") == 42')
135135
deactivate
136136
rm -r test_before_pypi
137+
- name: Preserve the exact release wheel for documentation
138+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
139+
with:
140+
name: dspy-release-wheel
141+
path: dist/*.whl
142+
if-no-files-found: error
137143
- name: Publish distribution 📦 to PyPI (dspy)
138144
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1
139145
with:
@@ -158,6 +164,112 @@ jobs:
158164
with:
159165
attestations: false
160166
packages-dir: .github/.internal_dspyai/dist/
167+
168+
release-docs:
169+
needs: [extract-tag, build-and-publish-pypi]
170+
if: github.repository_owner == 'stanfordnlp'
171+
runs-on: ubuntu-latest
172+
permissions:
173+
contents: read
174+
steps:
175+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
176+
with:
177+
persist-credentials: false
178+
fetch-depth: 0
179+
- name: Check whether this is a documentation release
180+
id: publishable
181+
env:
182+
VERSION: ${{ needs.extract-tag.outputs.version }}
183+
run: |
184+
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?$ ]] && (( ${VERSION%%.*} >= 3 )); then
185+
echo "publish=true" >> "$GITHUB_OUTPUT"
186+
else
187+
echo "publish=false" >> "$GITHUB_OUTPUT"
188+
fi
189+
- name: Set up Python 3.11
190+
if: steps.publishable.outputs.publish == 'true'
191+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
192+
with:
193+
python-version: "3.11"
194+
- name: Download exact production wheel
195+
if: steps.publishable.outputs.publish == 'true'
196+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
197+
with:
198+
name: dspy-release-wheel
199+
path: release-wheel
200+
- name: Install documentation dependencies and release wheel
201+
if: steps.publishable.outputs.publish == 'true'
202+
run: python -m pip install -r docs/requirements.txt release-wheel/*.whl
203+
- name: Verify API introspection uses the release wheel
204+
if: steps.publishable.outputs.publish == 'true'
205+
run: |
206+
cd "$RUNNER_TEMP"
207+
env -u PYTHONPATH PYTHONSAFEPATH=1 python -P - <<'PY'
208+
import site
209+
from pathlib import Path
210+
211+
import dspy
212+
213+
module = Path(dspy.__file__).resolve()
214+
site_packages = [Path(root).resolve() for root in site.getsitepackages()]
215+
if not any(module.is_relative_to(root) for root in site_packages):
216+
raise SystemExit(f"DSPy resolved outside site-packages: {module}")
217+
print(f"DSPy API source: {module}")
218+
PY
219+
- name: Build immutable release documentation
220+
if: steps.publishable.outputs.publish == 'true'
221+
env:
222+
VERSION: ${{ needs.extract-tag.outputs.version }}
223+
run: |
224+
cd "$RUNNER_TEMP"
225+
env PYTHONPATH="$GITHUB_WORKSPACE/docs/scripts" PYTHONSAFEPATH=1 python -P \
226+
"$GITHUB_WORKSPACE/docs/scripts/build_docs.py" release \
227+
--config "$GITHUB_WORKSPACE/docs/mkdocs.yml" \
228+
--output "$GITHUB_WORKSPACE/release-site" \
229+
--version "$VERSION" \
230+
--artifact "$GITHUB_WORKSPACE"/release-wheel/*.whl \
231+
--package-source workflow-wheel
232+
- name: Check out documentation deployment
233+
if: steps.publishable.outputs.publish == 'true'
234+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
235+
with:
236+
repository: krypticmouse/dspy-docs
237+
ref: master
238+
path: docs-deployment
239+
persist-credentials: false
240+
token: ${{ secrets.GH_PAT }} # zizmor: ignore[secrets-outside-env]
241+
- name: Publish immutable release documentation
242+
if: steps.publishable.outputs.publish == 'true'
243+
env:
244+
GH_TOKEN: ${{ secrets.GH_PAT }}
245+
VERSION: ${{ needs.extract-tag.outputs.version }}
246+
run: |
247+
gh auth setup-git
248+
git -C docs-deployment config user.name github-actions
249+
git -C docs-deployment config user.email github-actions@github.com
250+
aliases=()
251+
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
252+
aliases=(--alias "${VERSION%.*}")
253+
fi
254+
for attempt in 1 2 3; do
255+
git -C docs-deployment fetch origin master
256+
git -C docs-deployment reset --hard origin/master
257+
python docs/scripts/publish_versioned_docs.py \
258+
--repository docs-deployment \
259+
--site release-site \
260+
--identifier "$VERSION" \
261+
"${aliases[@]}" \
262+
--package-source workflow-wheel \
263+
--branch master \
264+
--require-current-renderer zensical
265+
if git -C docs-deployment push origin master; then
266+
exit 0
267+
fi
268+
sleep $((2 ** attempt + RANDOM % 5))
269+
done
270+
echo "::error::Documentation deployment changed repeatedly; rerun this release job"
271+
exit 1
272+
161273
open-main-version-bump-pr:
162274
needs: [extract-tag, build-and-publish-pypi]
163275
if: github.repository_owner == 'stanfordnlp'

‎.github/workflows/docs-push.yml‎

Lines changed: 23 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -31,91 +31,14 @@ jobs:
3131
persist-credentials: false
3232
- name: Install dependencies and build
3333
run: |
34-
cd docs
35-
pip install -r requirements.txt
36-
python scripts/build_docs.py current
34+
pip install -r docs/requirements.txt -e .
35+
python docs/scripts/build_docs.py current \
36+
--config docs/mkdocs.yml \
37+
--output docs/site
3738
38-
detect-versioned-deployment:
39+
publish-current:
3940
if: github.event_name == 'push' && github.repository == 'stanfordnlp/dspy'
4041
runs-on: ubuntu-latest
41-
permissions:
42-
contents: read
43-
outputs:
44-
enabled: ${{ steps.deployment.outputs.enabled }}
45-
steps:
46-
- name: Check out deployment tooling
47-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
48-
with:
49-
persist-credentials: false
50-
- name: Check the production deployment format
51-
id: deployment
52-
run: |
53-
git clone --depth 1 --branch master https://github.com/krypticmouse/dspy-docs.git docs-deployment
54-
# The staging branch deliberately does not activate Mike. Only the
55-
# reviewed promotion of versions.json to production master does.
56-
if [[ ! -f docs-deployment/versions.json ]]; then
57-
echo "enabled=false" >> "$GITHUB_OUTPUT"
58-
elif jq -e 'type == "array" and any(.[]; .version == "current")' docs-deployment/versions.json >/dev/null; then
59-
echo "enabled=true" >> "$GITHUB_OUTPUT"
60-
else
61-
echo "::error::Production versions.json does not contain Current"
62-
exit 1
63-
fi
64-
65-
update-legacy-deployment:
66-
needs: detect-versioned-deployment
67-
if: needs.detect-versioned-deployment.outputs.enabled == 'false'
68-
runs-on: ubuntu-latest
69-
concurrency:
70-
group: dspy-docs-deployment
71-
cancel-in-progress: false
72-
permissions:
73-
contents: read
74-
steps:
75-
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
76-
with:
77-
persist-credentials: false
78-
fetch-depth: 0
79-
- name: Check out the legacy deployment
80-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
81-
with:
82-
repository: krypticmouse/dspy-docs
83-
ref: master
84-
path: docs-deployment
85-
persist-credentials: false
86-
token: ${{ secrets.GH_PAT }} # zizmor: ignore[secrets-outside-env]
87-
- name: Update the legacy deployment without crossing the cutover
88-
env:
89-
GH_TOKEN: ${{ secrets.GH_PAT }}
90-
run: |
91-
gh auth setup-git
92-
if [[ -f docs-deployment/versions.json ]]; then
93-
echo "The versioned deployment is already live; leaving it unchanged."
94-
exit 0
95-
fi
96-
rsync --archive --delete --exclude=.git docs/ docs-deployment/
97-
git -C docs-deployment config user.name github-actions
98-
git -C docs-deployment config user.email github-actions@github.com
99-
git -C docs-deployment add --all
100-
if git -C docs-deployment diff --cached --quiet; then
101-
exit 0
102-
fi
103-
git -C docs-deployment commit -m "Update documentation"
104-
if git -C docs-deployment push origin HEAD:master; then
105-
exit 0
106-
fi
107-
git -C docs-deployment fetch origin master
108-
if git -C docs-deployment show origin/master:versions.json >/dev/null 2>&1; then
109-
echo "The versioned deployment won the race; leaving it unchanged."
110-
exit 0
111-
fi
112-
echo "::error::The deployment changed concurrently; rerun this workflow"
113-
exit 1
114-
115-
update-versioned-deployment:
116-
needs: detect-versioned-deployment
117-
if: needs.detect-versioned-deployment.outputs.enabled == 'true'
118-
runs-on: ubuntu-latest
11942
concurrency:
12043
group: dspy-docs-deployment
12144
cancel-in-progress: false
@@ -133,9 +56,7 @@ jobs:
13356
cache: "pip"
13457
cache-dependency-path: docs/requirements.txt
13558
- name: Install documentation dependencies
136-
run: |
137-
grep -v 'github.com/stanfordnlp/dspy' docs/requirements.txt > "$RUNNER_TEMP/docs-requirements.txt"
138-
python -m pip install -r "$RUNNER_TEMP/docs-requirements.txt" -e .
59+
run: python -m pip install -r docs/requirements.txt -e .
13960
- name: Build Current documentation
14061
run: |
14162
python docs/scripts/build_docs.py current \
@@ -156,10 +77,20 @@ jobs:
15677
gh auth setup-git
15778
git -C docs-deployment config user.name github-actions
15879
git -C docs-deployment config user.email github-actions@github.com
159-
python docs/scripts/publish_versioned_docs.py \
160-
--repository docs-deployment \
161-
--site current-site \
162-
--identifier current \
163-
--package-source working-tree \
164-
--branch master
165-
git -C docs-deployment push origin master
80+
for attempt in 1 2 3; do
81+
git -C docs-deployment fetch origin master
82+
git -C docs-deployment reset --hard origin/master
83+
python docs/scripts/publish_versioned_docs.py \
84+
--repository docs-deployment \
85+
--site current-site \
86+
--identifier current \
87+
--package-source working-tree \
88+
--branch master \
89+
--require-current-renderer zensical
90+
if git -C docs-deployment push origin master; then
91+
exit 0
92+
fi
93+
sleep $((2 ** attempt + RANDOM % 5))
94+
done
95+
echo "::error::Documentation deployment changed repeatedly; rerun this workflow"
96+
exit 1

‎docs/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@ This guide is for contributors looking to make changes to the documentation in t
7676

7777
## LLMs.txt
7878

79-
The build process generates an `/llms.txt` file for LLM consumption using [mkdocs-llmstxt](https://github.com/pawamoy/mkdocs-llmstxt). Configure sections in `mkdocs.yml` under the `llmstxt` plugin.
79+
The build process generates an `/llms.txt` file for LLM consumption, plus a Markdown copy of every rendered page at `<page>/index.md` for its links to point to. Configure sections in `build.yml` under `llms`; the generator lives in `scripts/zensical_build.py`.
8080

‎docs/build.yml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
llms:
2+
markdown_description: >
3+
DSPy is the framework for programming—rather than prompting—language models.
4+
DSPy unifies techniques for prompting, fine-tuning, reasoning, tool use, and evaluation of LMs.
5+
It provides a systematic approach to building AI applications through composable modules,
6+
optimization techniques, and evaluation frameworks.
7+
sections:
8+
Get Started:
9+
- index.md: DSPy overview and quick start guide
10+
Getting Started:
11+
- getting-started/**.md
12+
Diving Deeper:
13+
- diving-deeper/**.md
14+
Tutorials - Docs:
15+
- tutorials/**.md
16+
Tutorials - Notebooks:
17+
- tutorials/**.ipynb
18+
Community:
19+
- community/**.md
20+
FAQ:
21+
- faqs.md: Common questions on DSPy usage, comparisons, optimization, and debugging
22+
- cheatsheet.md: DSPy cheatsheet for quick reference
23+
API Reference:
24+
- api/**.md

0 commit comments

Comments
 (0)