Skip to content

Commit 8ca6412

Browse files
authored
Merge branch 'stanfordnlp:main' into fix/react_keys
2 parents b652c8e + 0cc7bd1 commit 8ca6412

File tree

94 files changed

+4314
-1103
lines changed

Some content is hidden

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

94 files changed

+4314
-1103
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/workflows/build_and_release.yml

+36-9
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
7678
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
8284
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)
9196
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
9398
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

+11
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ jobs:
4141
python-version: ["3.9"]
4242
steps:
4343
- uses: actions/checkout@v4
44+
- name: Install Deno
45+
run: |
46+
curl -fsSL https://deno.land/install.sh | sh
47+
echo "Deno installed"
48+
49+
- name: Add Deno to PATH
50+
run: echo "${HOME}/.deno/bin" >> $GITHUB_PATH
51+
52+
- name: Verify Deno installation
53+
run: deno --version
54+
4455
- name: Load cached Poetry installation
4556
id: cached-poetry
4657
uses: actions/cache@v3

.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

+4
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# dspy.evaluate.CompleteAndGrounded
2+
3+
::: dspy.evaluate.CompleteAndGrounded
4+
handler: python
5+
options:
6+
members:
7+
- __call__
8+
- batch
9+
- deepcopy
10+
- dump_state
11+
- forward
12+
- get_lm
13+
- load
14+
- load_state
15+
- map_named_predictors
16+
- named_parameters
17+
- named_predictors
18+
- named_sub_modules
19+
- parameters
20+
- predictors
21+
- reset_copy
22+
- save
23+
- set_lm
24+
show_source: true
25+
show_undocumented_members: true
26+
show_root_heading: true
27+
show_inherited_members: true
28+
heading_level: 2
29+
docstring_style: google
30+
show_root_full_path: true
31+
show_object_full_path: false
32+
separate_signature: false

docs/docs/api/evaluation/Evaluate.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# dspy.Evaluate
2+
3+
::: dspy.Evaluate
4+
handler: python
5+
options:
6+
members:
7+
- __call__
8+
show_source: true
9+
show_undocumented_members: true
10+
show_root_heading: true
11+
show_inherited_members: true
12+
heading_level: 2
13+
docstring_style: google
14+
show_root_full_path: true
15+
show_object_full_path: false
16+
separate_signature: false
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# dspy.evaluate.SemanticF1
2+
3+
::: dspy.evaluate.SemanticF1
4+
handler: python
5+
options:
6+
members:
7+
- __call__
8+
- batch
9+
- deepcopy
10+
- dump_state
11+
- forward
12+
- get_lm
13+
- load
14+
- load_state
15+
- map_named_predictors
16+
- named_parameters
17+
- named_predictors
18+
- named_sub_modules
19+
- parameters
20+
- predictors
21+
- reset_copy
22+
- save
23+
- set_lm
24+
show_source: true
25+
show_undocumented_members: true
26+
show_root_heading: true
27+
show_inherited_members: true
28+
heading_level: 2
29+
docstring_style: google
30+
show_root_full_path: true
31+
show_object_full_path: false
32+
separate_signature: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# dspy.evaluate.answer_exact_match
2+
3+
::: dspy.evaluate.answer_exact_match
4+
handler: python
5+
options:
6+
show_source: true
7+
show_undocumented_members: true
8+
show_root_heading: true
9+
show_inherited_members: true
10+
heading_level: 2
11+
docstring_style: google
12+
show_root_full_path: true
13+
show_object_full_path: false
14+
separate_signature: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# dspy.evaluate.answer_passage_match
2+
3+
::: dspy.evaluate.answer_passage_match
4+
handler: python
5+
options:
6+
show_source: true
7+
show_undocumented_members: true
8+
show_root_heading: true
9+
show_inherited_members: true
10+
heading_level: 2
11+
docstring_style: google
12+
show_root_full_path: true
13+
show_object_full_path: false
14+
separate_signature: false

docs/docs/api/models/Embedder.md

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

docs/docs/api/models/LM.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# dspy.LM
2+
3+
::: dspy.LM
4+
handler: python
5+
options:
6+
members:
7+
- __call__
8+
- copy
9+
- finetune
10+
- infer_adapter
11+
- infer_provider
12+
- inspect_history
13+
- kill
14+
- launch
15+
- update_global_history
16+
show_source: true
17+
show_undocumented_members: true
18+
show_root_heading: true
19+
show_inherited_members: true
20+
heading_level: 2
21+
docstring_style: google
22+
show_root_full_path: true
23+
show_object_full_path: false
24+
separate_signature: false

0 commit comments

Comments
 (0)