DSPy: The framework for programming—not prompting—language models
Python
Break API references into subpages (#1991)
Chen Qian1245150dd010
diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.ymlindex f73779285..3bb198939 100644--- a/.github/workflows/docs-push.yml+++ b/.github/workflows/docs-push.yml@@ -15,7 +15,11 @@ jobs:if: github.event_name == 'pull_request'runs-on: ubuntu-lateststeps:- - uses: actions/checkout@v3+ - name: Checkout code+ uses: actions/checkout@v3+ - name: Install the dspy package+ run: |+ pip install .- name: Set up Node.jsuses: actions/setup-node@v3with:diff --git a/docs/README.md b/docs/README.mdindex 69f7aa134..a204dff2f 100644--- a/docs/README.md+++ b/docs/README.md@@ -16,8 +16,9 @@ To build and test the documentation locally:pip install -r requirements.txt```-3. Generate the API docs and index them:+3. In docs/ directory, run the command below to generate the API docs and index them:```bash+ cd docs/python scripts/generate_api_docs.pypython scripts/generate_api_summary.py```diff --git a/docs/docs/api/adapters/Adapter.md b/docs/docs/api/adapters/Adapter.mdnew file mode 100644index 000000000..eeef9ab83--- /dev/null+++ b/docs/docs/api/adapters/Adapter.md@@ -0,0 +1,19 @@+# dspy.Adapter++::: dspy.Adapter+ handler: python+ options:+ members:+ - __call__+ - format+ - format_finetune_data+ - parse+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/adapters/ChatAdapter.md b/docs/docs/api/adapters/ChatAdapter.mdnew file mode 100644index 000000000..2d65e6e72--- /dev/null+++ b/docs/docs/api/adapters/ChatAdapter.md@@ -0,0 +1,21 @@+# dspy.ChatAdapter++::: dspy.ChatAdapter+ handler: python+ options:+ members:+ - __call__+ - format+ - format_fields+ - format_finetune_data+ - format_turn+ - parse+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/adapters/JSONAdapter.md b/docs/docs/api/adapters/JSONAdapter.mdnew file mode 100644index 000000000..619c6743d--- /dev/null+++ b/docs/docs/api/adapters/JSONAdapter.md@@ -0,0 +1,21 @@+# dspy.JSONAdapter++::: dspy.JSONAdapter+ handler: python+ options:+ members:+ - __call__+ - format+ - format_fields+ - format_finetune_data+ - format_turn+ - parse+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/evaluation/CompleteAndGrounded.md b/docs/docs/api/evaluation/CompleteAndGrounded.mdnew file mode 100644index 000000000..8a9da2b0b--- /dev/null+++ b/docs/docs/api/evaluation/CompleteAndGrounded.md@@ -0,0 +1,32 @@+# dspy.evaluate.CompleteAndGrounded++::: dspy.evaluate.CompleteAndGrounded+ handler: python+ options:+ members:+ - __call__+ - batch+ - deepcopy+ - dump_state+ - forward+ - get_lm+ - load+ - load_state+ - map_named_predictors+ - named_parameters+ - named_predictors+ - named_sub_modules+ - parameters+ - predictors+ - reset_copy+ - save+ - set_lm+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/evaluation/Evaluate.md b/docs/docs/api/evaluation/Evaluate.mdnew file mode 100644index 000000000..d30fbcd0e--- /dev/null+++ b/docs/docs/api/evaluation/Evaluate.md@@ -0,0 +1,16 @@+# dspy.Evaluate++::: dspy.Evaluate+ handler: python+ options:+ members:+ - __call__+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/evaluation/SemanticF1.md b/docs/docs/api/evaluation/SemanticF1.mdnew file mode 100644index 000000000..d9a62d1f0--- /dev/null+++ b/docs/docs/api/evaluation/SemanticF1.md@@ -0,0 +1,32 @@+# dspy.evaluate.SemanticF1++::: dspy.evaluate.SemanticF1+ handler: python+ options:+ members:+ - __call__+ - batch+ - deepcopy+ - dump_state+ - forward+ - get_lm+ - load+ - load_state+ - map_named_predictors+ - named_parameters+ - named_predictors+ - named_sub_modules+ - parameters+ - predictors+ - reset_copy+ - save+ - set_lm+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/evaluation/answer_exact_match.md b/docs/docs/api/evaluation/answer_exact_match.mdnew file mode 100644index 000000000..cd8e668b4--- /dev/null+++ b/docs/docs/api/evaluation/answer_exact_match.md@@ -0,0 +1,14 @@+# dspy.evaluate.answer_exact_match++::: dspy.evaluate.answer_exact_match+ handler: python+ options:+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/evaluation/answer_passage_match.md b/docs/docs/api/evaluation/answer_passage_match.mdnew file mode 100644index 000000000..91d6f503a--- /dev/null+++ b/docs/docs/api/evaluation/answer_passage_match.md@@ -0,0 +1,14 @@+# dspy.evaluate.answer_passage_match++::: dspy.evaluate.answer_passage_match+ handler: python+ options:+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/models/Embedder.md b/docs/docs/api/models/Embedder.mdnew file mode 100644index 000000000..961cab954--- /dev/null+++ b/docs/docs/api/models/Embedder.md@@ -0,0 +1,16 @@+# dspy.Embedder++::: dspy.Embedder+ handler: python+ options:+ members:+ - __call__+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/models/LM.md b/docs/docs/api/models/LM.mdnew file mode 100644index 000000000..4cb13803e--- /dev/null+++ b/docs/docs/api/models/LM.md@@ -0,0 +1,24 @@+# dspy.LM++::: dspy.LM+ handler: python+ options:+ members:+ - __call__+ - copy+ - finetune+ - infer_adapter+ - infer_provider+ - inspect_history+ - kill+ - launch+ - update_global_history+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/modules/ChainOfThought.md b/docs/docs/api/modules/ChainOfThought.mdnew file mode 100644index 000000000..1e42589ec--- /dev/null+++ b/docs/docs/api/modules/ChainOfThought.md@@ -0,0 +1,32 @@+# dspy.ChainOfThought++::: dspy.ChainOfThought+ handler: python+ options:+ members:+ - __call__+ - batch+ - deepcopy+ - dump_state+ - forward+ - get_lm+ - load+ - load_state+ - map_named_predictors+ - named_parameters+ - named_predictors+ - named_sub_modules+ - parameters+ - predictors+ - reset_copy+ - save+ - set_lm+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/modules/ChainOfThoughtWithHint.md b/docs/docs/api/modules/ChainOfThoughtWithHint.mdnew file mode 100644index 000000000..28033493a--- /dev/null+++ b/docs/docs/api/modules/ChainOfThoughtWithHint.md@@ -0,0 +1,32 @@+# dspy.ChainOfThoughtWithHint++::: dspy.ChainOfThoughtWithHint+ handler: python+ options:+ members:+ - __call__+ - batch+ - deepcopy+ - dump_state+ - forward+ - get_lm+ - load+ - load_state+ - map_named_predictors+ - named_parameters+ - named_predictors+ - named_sub_modules+ - parameters+ - predictors+ - reset_copy+ - save+ - set_lm+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/modules/Module.md b/docs/docs/api/modules/Module.mdnew file mode 100644index 000000000..18c72a475--- /dev/null+++ b/docs/docs/api/modules/Module.md@@ -0,0 +1,31 @@+# dspy.Module++::: dspy.Module+ handler: python+ options:+ members:+ - __call__+ - batch+ - deepcopy+ - dump_state+ - get_lm+ - load+ - load_state+ - map_named_predictors+ - named_parameters+ - named_predictors+ - named_sub_modules+ - parameters+ - predictors+ - reset_copy+ - save+ - set_lm+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/modules/MultiChainComparison.md b/docs/docs/api/modules/MultiChainComparison.mdnew file mode 100644index 000000000..64e0b6f63--- /dev/null+++ b/docs/docs/api/modules/MultiChainComparison.md@@ -0,0 +1,32 @@+# dspy.MultiChainComparison++::: dspy.MultiChainComparison+ handler: python+ options:+ members:+ - __call__+ - batch+ - deepcopy+ - dump_state+ - forward+ - get_lm+ - load+ - load_state+ - map_named_predictors+ - named_parameters+ - named_predictors+ - named_sub_modules+ - parameters+ - predictors+ - reset_copy+ - save+ - set_lm+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/modules/Parallel.md b/docs/docs/api/modules/Parallel.mdnew file mode 100644index 000000000..9560840b5--- /dev/null+++ b/docs/docs/api/modules/Parallel.md@@ -0,0 +1,17 @@+# dspy.Parallel++::: dspy.Parallel+ handler: python+ options:+ members:+ - __call__+ - forward+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/modules/Predict.md b/docs/docs/api/modules/Predict.mdnew file mode 100644index 000000000..cdf1edd1a--- /dev/null+++ b/docs/docs/api/modules/Predict.md@@ -0,0 +1,35 @@+# dspy.Predict++::: dspy.Predict+ handler: python+ options:+ members:+ - __call__+ - batch+ - deepcopy+ - dump_state+ - forward+ - get_config+ - get_lm+ - load+ - load_state+ - map_named_predictors+ - named_parameters+ - named_predictors+ - named_sub_modules+ - parameters+ - predictors+ - reset+ - reset_copy+ - save+ - set_lm+ - update_config+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/modules/Program.md b/docs/docs/api/modules/Program.mdnew file mode 100644index 000000000..b0c006488--- /dev/null+++ b/docs/docs/api/modules/Program.md@@ -0,0 +1,31 @@+# dspy.Program++::: dspy.Program+ handler: python+ options:+ members:+ - __call__+ - batch+ - deepcopy+ - dump_state+ - get_lm+ - load+ - load_state+ - map_named_predictors+ - named_parameters+ - named_predictors+ - named_sub_modules+ - parameters+ - predictors+ - reset_copy+ - save+ - set_lm+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/modules/ProgramOfThought.md b/docs/docs/api/modules/ProgramOfThought.mdnew file mode 100644index 000000000..abea2f2e0--- /dev/null+++ b/docs/docs/api/modules/ProgramOfThought.md@@ -0,0 +1,34 @@+# dspy.ProgramOfThought++::: dspy.ProgramOfThought+ handler: python+ options:+ members:+ - __call__+ - batch+ - deepcopy+ - dump_state+ - execute_code+ - forward+ - get_lm+ - load+ - load_state+ - map_named_predictors+ - named_parameters+ - named_predictors+ - named_sub_modules+ - parameters+ - parse_code+ - predictors+ - reset_copy+ - save+ - set_lm+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/modules/ReAct.md b/docs/docs/api/modules/ReAct.mdnew file mode 100644index 000000000..d4117c74c--- /dev/null+++ b/docs/docs/api/modules/ReAct.md@@ -0,0 +1,32 @@+# dspy.ReAct++::: dspy.ReAct+ handler: python+ options:+ members:+ - __call__+ - batch+ - deepcopy+ - dump_state+ - forward+ - get_lm+ - load+ - load_state+ - map_named_predictors+ - named_parameters+ - named_predictors+ - named_sub_modules+ - parameters+ - predictors+ - reset_copy+ - save+ - set_lm+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/optimizers/BetterTogether.md b/docs/docs/api/optimizers/BetterTogether.mdnew file mode 100644index 000000000..d60d00601--- /dev/null+++ b/docs/docs/api/optimizers/BetterTogether.md@@ -0,0 +1,16 @@+# dspy.BetterTogether++::: dspy.BetterTogether+ handler: python+ options:+ members:+ - compile+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/optimizers/BootstrapFewShot.md b/docs/docs/api/optimizers/BootstrapFewShot.mdnew file mode 100644index 000000000..1ba00156a--- /dev/null+++ b/docs/docs/api/optimizers/BootstrapFewShot.md@@ -0,0 +1,16 @@+# dspy.BootstrapFewShot++::: dspy.BootstrapFewShot+ handler: python+ options:+ members:+ - compile+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/optimizers/BootstrapFewShotWithRandomSearch.md b/docs/docs/api/optimizers/BootstrapFewShotWithRandomSearch.mdnew file mode 100644index 000000000..57ace3a4a--- /dev/null+++ b/docs/docs/api/optimizers/BootstrapFewShotWithRandomSearch.md@@ -0,0 +1,16 @@+# dspy.BootstrapFewShotWithRandomSearch++::: dspy.BootstrapFewShotWithRandomSearch+ handler: python+ options:+ members:+ - compile+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/optimizers/BootstrapFinetune.md b/docs/docs/api/optimizers/BootstrapFinetune.mdnew file mode 100644index 000000000..938afaadb--- /dev/null+++ b/docs/docs/api/optimizers/BootstrapFinetune.md@@ -0,0 +1,18 @@+# dspy.BootstrapFinetune++::: dspy.BootstrapFinetune+ handler: python+ options:+ members:+ - compile+ - convert_to_lm_dict+ - finetune_lms+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/optimizers/BootstrapRS.md b/docs/docs/api/optimizers/BootstrapRS.mdnew file mode 100644index 000000000..127675784--- /dev/null+++ b/docs/docs/api/optimizers/BootstrapRS.md@@ -0,0 +1,16 @@+# dspy.BootstrapRS++::: dspy.BootstrapRS+ handler: python+ options:+ members:+ - compile+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/optimizers/COPRO.md b/docs/docs/api/optimizers/COPRO.mdnew file mode 100644index 000000000..d9974a146--- /dev/null+++ b/docs/docs/api/optimizers/COPRO.md@@ -0,0 +1,16 @@+# dspy.COPRO++::: dspy.COPRO+ handler: python+ options:+ members:+ - compile+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/optimizers/Ensemble.md b/docs/docs/api/optimizers/Ensemble.mdnew file mode 100644index 000000000..791cbd0f0--- /dev/null+++ b/docs/docs/api/optimizers/Ensemble.md@@ -0,0 +1,16 @@+# dspy.Ensemble++::: dspy.Ensemble+ handler: python+ options:+ members:+ - compile+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/optimizers/KNN.md b/docs/docs/api/optimizers/KNN.mdnew file mode 100644index 000000000..adf98c6f6--- /dev/null+++ b/docs/docs/api/optimizers/KNN.md@@ -0,0 +1,16 @@+# dspy.KNN++::: dspy.KNN+ handler: python+ options:+ members:+ - __call__+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/optimizers/KNNFewShot.md b/docs/docs/api/optimizers/KNNFewShot.mdnew file mode 100644index 000000000..8a19c8d62--- /dev/null+++ b/docs/docs/api/optimizers/KNNFewShot.md@@ -0,0 +1,16 @@+# dspy.KNNFewShot++::: dspy.KNNFewShot+ handler: python+ options:+ members:+ - compile+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/optimizers/LabeledFewShot.md b/docs/docs/api/optimizers/LabeledFewShot.mdnew file mode 100644index 000000000..58d2f2a60--- /dev/null+++ b/docs/docs/api/optimizers/LabeledFewShot.md@@ -0,0 +1,16 @@+# dspy.LabeledFewShot++::: dspy.LabeledFewShot+ handler: python+ options:+ members:+ - compile+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/optimizers/MIPROv2.md b/docs/docs/api/optimizers/MIPROv2.mdnew file mode 100644index 000000000..6d6255282--- /dev/null+++ b/docs/docs/api/optimizers/MIPROv2.md@@ -0,0 +1,16 @@+# dspy.MIPROv2++::: dspy.MIPROv2+ handler: python+ options:+ members:+ - compile+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/primitives/Example.md b/docs/docs/api/primitives/Example.mdnew file mode 100644index 000000000..447e5b634--- /dev/null+++ b/docs/docs/api/primitives/Example.md@@ -0,0 +1,25 @@+# dspy.Example++::: dspy.Example+ handler: python+ options:+ members:+ - copy+ - get+ - inputs+ - items+ - keys+ - labels+ - toDict+ - values+ - with_inputs+ - without+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/primitives/Image.md b/docs/docs/api/primitives/Image.mdnew file mode 100644index 000000000..747e0ddfc--- /dev/null+++ b/docs/docs/api/primitives/Image.md@@ -0,0 +1,22 @@+# dspy.Image++::: dspy.Image+ handler: python+ options:+ members:+ - copy+ - dict+ - json+ - model_copy+ - model_dump+ - model_dump_json+ - model_post_init+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/primitives/Prediction.md b/docs/docs/api/primitives/Prediction.mdnew file mode 100644index 000000000..ffecb60a9--- /dev/null+++ b/docs/docs/api/primitives/Prediction.md@@ -0,0 +1,25 @@+# dspy.Prediction++::: dspy.Prediction+ handler: python+ options:+ members:+ - copy+ - get+ - inputs+ - items+ - keys+ - labels+ - toDict+ - values+ - with_inputs+ - without+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/primitives/Tool.md b/docs/docs/api/primitives/Tool.mdnew file mode 100644index 000000000..d936c35af--- /dev/null+++ b/docs/docs/api/primitives/Tool.md@@ -0,0 +1,16 @@+# dspy.Tool++::: dspy.Tool+ handler: python+ options:+ members:+ - __call__+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/signatures/InputField.md b/docs/docs/api/signatures/InputField.mdnew file mode 100644index 000000000..872ca9a28--- /dev/null+++ b/docs/docs/api/signatures/InputField.md@@ -0,0 +1,14 @@+# dspy.InputField++::: dspy.InputField+ handler: python+ options:+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/signatures/OutputField.md b/docs/docs/api/signatures/OutputField.mdnew file mode 100644index 000000000..1eb8094db--- /dev/null+++ b/docs/docs/api/signatures/OutputField.md@@ -0,0 +1,14 @@+# dspy.OutputField++::: dspy.OutputField+ handler: python+ options:+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/signatures/Signature.md b/docs/docs/api/signatures/Signature.mdnew file mode 100644index 000000000..c784ffd2e--- /dev/null+++ b/docs/docs/api/signatures/Signature.md@@ -0,0 +1,22 @@+# dspy.Signature++::: dspy.Signature+ handler: python+ options:+ members:+ - copy+ - dict+ - json+ - model_copy+ - model_dump+ - model_dump_json+ - model_post_init+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/tools/ColBERTv2.md b/docs/docs/api/tools/ColBERTv2.mdnew file mode 100644index 000000000..9097a5352--- /dev/null+++ b/docs/docs/api/tools/ColBERTv2.md@@ -0,0 +1,16 @@+# dspy.ColBERTv2++::: dspy.ColBERTv2+ handler: python+ options:+ members:+ - __call__+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/tools/Embeddings.md b/docs/docs/api/tools/Embeddings.mdnew file mode 100644index 000000000..379e1a0a6--- /dev/null+++ b/docs/docs/api/tools/Embeddings.md@@ -0,0 +1,17 @@+# dspy.retrievers.Embeddings++::: dspy.retrievers.Embeddings+ handler: python+ options:+ members:+ - __call__+ - forward+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/tools/PythonInterpreter.md b/docs/docs/api/tools/PythonInterpreter.mdnew file mode 100644index 000000000..3709c4988--- /dev/null+++ b/docs/docs/api/tools/PythonInterpreter.md@@ -0,0 +1,18 @@+# dspy.PythonInterpreter++::: dspy.PythonInterpreter+ handler: python+ options:+ members:+ - __call__+ - execute+ - shutdown+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/utils/asyncify.md b/docs/docs/api/utils/asyncify.mdnew file mode 100644index 000000000..b24e4940c--- /dev/null+++ b/docs/docs/api/utils/asyncify.md@@ -0,0 +1,14 @@+# dspy.asyncify++::: dspy.asyncify+ handler: python+ options:+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/utils/disable_litellm_logging.md b/docs/docs/api/utils/disable_litellm_logging.mdnew file mode 100644index 000000000..dbc437c33--- /dev/null+++ b/docs/docs/api/utils/disable_litellm_logging.md@@ -0,0 +1,14 @@+# dspy.disable_litellm_logging++::: dspy.disable_litellm_logging+ handler: python+ options:+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/utils/disable_logging.md b/docs/docs/api/utils/disable_logging.mdnew file mode 100644index 000000000..4190f39f4--- /dev/null+++ b/docs/docs/api/utils/disable_logging.md@@ -0,0 +1,14 @@+# dspy.disable_logging++::: dspy.disable_logging+ handler: python+ options:+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/utils/enable_litellm_logging.md b/docs/docs/api/utils/enable_litellm_logging.mdnew file mode 100644index 000000000..99200d7ea--- /dev/null+++ b/docs/docs/api/utils/enable_litellm_logging.md@@ -0,0 +1,14 @@+# dspy.enable_litellm_logging++::: dspy.enable_litellm_logging+ handler: python+ options:+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/utils/enable_logging.md b/docs/docs/api/utils/enable_logging.mdnew file mode 100644index 000000000..94b665ba5--- /dev/null+++ b/docs/docs/api/utils/enable_logging.md@@ -0,0 +1,14 @@+# dspy.enable_logging++::: dspy.enable_logging+ handler: python+ options:+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/utils/inspect_history.md b/docs/docs/api/utils/inspect_history.mdnew file mode 100644index 000000000..ac528b283--- /dev/null+++ b/docs/docs/api/utils/inspect_history.md@@ -0,0 +1,14 @@+# dspy.inspect_history++::: dspy.inspect_history+ handler: python+ options:+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/utils/load.md b/docs/docs/api/utils/load.mdnew file mode 100644index 000000000..cb37fe482--- /dev/null+++ b/docs/docs/api/utils/load.md@@ -0,0 +1,14 @@+# dspy.load++::: dspy.load+ handler: python+ options:+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/docs/api/utils/streamify.md b/docs/docs/api/utils/streamify.mdnew file mode 100644index 000000000..c41ac2397--- /dev/null+++ b/docs/docs/api/utils/streamify.md@@ -0,0 +1,14 @@+# dspy.streamify++::: dspy.streamify+ handler: python+ options:+ show_source: true+ show_undocumented_members: true+ show_root_heading: true+ show_inherited_members: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: falsediff --git a/docs/mkdocs.yml b/docs/mkdocs.ymlindex e5846b039..6ac802659 100644--- a/docs/mkdocs.yml+++ b/docs/mkdocs.yml@@ -64,6 +64,65 @@ nav:- FAQ: faqs.md- Cheatsheet: cheatsheet.md+ - API Reference:+ - Adapters:+ - Adapter: api/adapters/Adapter.md+ - ChatAdapter: api/adapters/ChatAdapter.md+ - JSONAdapter: api/adapters/JSONAdapter.md+ - Evaluation:+ - CompleteAndGrounded: api/evaluation/CompleteAndGrounded.md+ - Evaluate: api/evaluation/Evaluate.md+ - SemanticF1: api/evaluation/SemanticF1.md+ - answer_exact_match: api/evaluation/answer_exact_match.md+ - answer_passage_match: api/evaluation/answer_passage_match.md+ - Models:+ - Embedder: api/models/Embedder.md+ - LM: api/models/LM.md+ - Modules:+ - ChainOfThought: api/modules/ChainOfThought.md+ - ChainOfThoughtWithHint: api/modules/ChainOfThoughtWithHint.md+ - Module: api/modules/Module.md+ - MultiChainComparison: api/modules/MultiChainComparison.md+ - Parallel: api/modules/Parallel.md+ - Predict: api/modules/Predict.md+ - Program: api/modules/Program.md+ - ProgramOfThought: api/modules/ProgramOfThought.md+ - ReAct: api/modules/ReAct.md+ - Optimizers:+ - BetterTogether: api/optimizers/BetterTogether.md+ - BootstrapFewShot: api/optimizers/BootstrapFewShot.md+ - BootstrapFewShotWithRandomSearch: api/optimizers/BootstrapFewShotWithRandomSearch.md+ - BootstrapFinetune: api/optimizers/BootstrapFinetune.md+ - BootstrapRS: api/optimizers/BootstrapRS.md+ - COPRO: api/optimizers/COPRO.md+ - Ensemble: api/optimizers/Ensemble.md+ - KNN: api/optimizers/KNN.md+ - KNNFewShot: api/optimizers/KNNFewShot.md+ - LabeledFewShot: api/optimizers/LabeledFewShot.md+ - MIPROv2: api/optimizers/MIPROv2.md+ - Primitives:+ - Example: api/primitives/Example.md+ - Image: api/primitives/Image.md+ - Prediction: api/primitives/Prediction.md+ - Tool: api/primitives/Tool.md+ - Signatures:+ - InputField: api/signatures/InputField.md+ - OutputField: api/signatures/OutputField.md+ - Signature: api/signatures/Signature.md+ - Tools:+ - ColBERTv2: api/tools/ColBERTv2.md+ - Embeddings: api/tools/Embeddings.md+ - PythonInterpreter: api/tools/PythonInterpreter.md+ - Utils:+ - asyncify: api/utils/asyncify.md+ - disable_litellm_logging: api/utils/disable_litellm_logging.md+ - disable_logging: api/utils/disable_logging.md+ - enable_litellm_logging: api/utils/enable_litellm_logging.md+ - enable_logging: api/utils/enable_logging.md+ - inspect_history: api/utils/inspect_history.md+ - load: api/utils/load.md+ - streamify: api/utils/streamify.md+theme:name: materialcustom_dir: overridesdiff --git a/docs/requirements.txt b/docs/requirements.txtindex 6dacc4af2..a822b31bf 100644--- a/docs/requirements.txt+++ b/docs/requirements.txt@@ -3,4 +3,5 @@ mkdocs-jupyter>=0.25.1mkdocs-material[imaging]>=9.5.41mkdocs-redirects>=1.2.1mkdocstrings>=0.26.1-urllib3==1.26.6\ No newline at end of file+mkdocstrings-python>=1.12.2+urllib3==1.26.6diff --git a/docs/scripts/generate_api_docs.py b/docs/scripts/generate_api_docs.pyindex 0a78bde26..d3308e077 100644--- a/docs/scripts/generate_api_docs.py+++ b/docs/scripts/generate_api_docs.py@@ -4,6 +4,74 @@ import inspectimport pkgutilimport shutilfrom typing import Any+import dspy++API_MAPPING = {+ "models": [+ dspy.LM,+ dspy.Embedder,+ ],+ "primitives": [+ dspy.Example,+ dspy.Image,+ dspy.Prediction,+ dspy.Tool,+ ],+ "signatures": [+ dspy.Signature,+ dspy.InputField,+ dspy.OutputField,+ ],+ "adapters": [+ dspy.Adapter,+ dspy.ChatAdapter,+ dspy.JSONAdapter,+ ],+ "modules": [+ dspy.Module,+ dspy.Predict,+ dspy.ChainOfThought,+ dspy.ReAct,+ dspy.ProgramOfThought,+ dspy.MultiChainComparison,+ dspy.ChainOfThoughtWithHint,+ dspy.Parallel,+ ],+ "tools": [+ dspy.ColBERTv2,+ dspy.retrievers.Embeddings,+ dspy.PythonInterpreter,+ ],+ "utils": [+ dspy.inspect_history,+ dspy.load,+ dspy.asyncify,+ dspy.streamify,+ dspy.enable_logging,+ dspy.disable_logging,+ dspy.enable_litellm_logging,+ dspy.disable_litellm_logging,+ ],+ "evaluation": [+ dspy.Evaluate,+ dspy.evaluate.answer_exact_match,+ dspy.evaluate.answer_passage_match,+ dspy.evaluate.SemanticF1,+ dspy.evaluate.CompleteAndGrounded,+ ],+ "optimizers": [+ dspy.LabeledFewShot,+ dspy.BootstrapFewShot,+ dspy.BootstrapFewShotWithRandomSearch,+ dspy.MIPROv2,+ dspy.BetterTogether,+ dspy.BootstrapFinetune,+ dspy.COPRO,+ dspy.Ensemble,+ dspy.KNN,+ dspy.KNNFewShot,+ ],+}def get_module_contents(module):@@ -62,6 +130,13 @@ def generate_doc_page(name: str, module_path: str, obj: Any, is_root: bool = Fal"""+def get_api_category(obj):+ for category, objects in API_MAPPING.items():+ if obj in objects:+ return category+ return None++def generate_md_docs(output_dir: Path, excluded_modules=None):"""Generate documentation for all public classes and functions in the dspy package.@@ -80,8 +155,13 @@ def generate_md_docs(output_dir: Path, excluded_modules=None):if inspect.ismodule(obj):continue+ category = get_api_category(obj)+ if category is None:+ # Skip if the object is not in the API mapping.+ continue+page_content = generate_doc_page(name, "dspy", obj, is_root=True)- with open(output_dir / f"{name}.md", "w") as f:+ with open(output_dir / category / f"{name}.md", "w") as f:f.write(page_content)objects_processed[f"{obj.__module__}.{name}"] = obj@@ -93,7 +173,7 @@ def generate_md_docs(output_dir: Path, excluded_modules=None):if submodule_name.startswith("_") or submodule_name not in init_contents:continue- generate_md_docs_submodule(submodule.name, output_dir / submodule_name, objects_processed, excluded_modules)+ generate_md_docs_submodule(submodule.name, output_dir, objects_processed, excluded_modules)def generate_md_docs_submodule(module_path: str, output_dir: Path, objects_processed=None, excluded_modules=None):@@ -116,7 +196,6 @@ def generate_md_docs_submodule(module_path: str, output_dir: Path, objects_proceexcept ImportError:print(f"Skipping {module_path} due to import error")return- output_dir.mkdir(parents=True, exist_ok=True)init_contents = get_module_contents(module)@@ -124,11 +203,16 @@ def generate_md_docs_submodule(module_path: str, output_dir: Path, objects_proceif inspect.ismodule(obj):continue+ category = get_api_category(obj)+ if category is None:+ # Skip if the object is not in the API mapping.+ continue+full_name = f"{obj.__module__}.{name}"if full_name not in objects_processed:# Only generate docs for objects that are not root-level objects.page_content = generate_doc_page(name, module_path, obj, is_root=False)- with open(output_dir / f"{name}.md", "w") as f:+ with open(output_dir / category / f"{name}.md", "w") as f:f.write(page_content)objects_processed[full_name] = obj@@ -153,6 +237,11 @@ if __name__ == "__main__":if api_dir.exists():shutil.rmtree(api_dir)+ for keys in API_MAPPING.keys():+ # Create a directory for each API category+ subpath = api_dir / keys+ subpath.mkdir(parents=True, exist_ok=True)+excluded_modules = ["dspy.dsp"]generate_md_docs(api_dir, excluded_modules=excluded_modules)# Clean up empty directoriesdiff --git a/docs/scripts/generate_api_summary.py b/docs/scripts/generate_api_summary.pyindex 0bb412bd1..e62d82e13 100644--- a/docs/scripts/generate_api_summary.py+++ b/docs/scripts/generate_api_summary.py@@ -1,5 +1,17 @@from pathlib import Path+INDEX_NAME = {+ "models": "Models",+ "primitives": "Primitives",+ "signatures": "Signatures",+ "adapters": "Adapters",+ "modules": "Modules",+ "evaluation": "Evaluation",+ "optimizers": "Optimizers",+ "utils": "Utils",+ "tools": "Tools",+}+def build_nav_structure(directory: Path, base_path: Path) -> dict:"""Recursively build navigation structure for a directory."""@@ -8,19 +20,11 @@ def build_nav_structure(directory: Path, base_path: Path) -> dict:# Get all items in current directoryitems = sorted(directory.iterdir())- # First handle all MD files in current directoryfor path in items:if path.suffix == ".md":name = path.stemnav[name] = str(path.relative_to(base_path))- # Then handle all subdirectories- for path in items:- if path.is_dir():- sub_nav = build_nav_structure(path, base_path)- if sub_nav: # Only add non-empty directories- nav[path.name] = sub_nav-return nav@@ -90,18 +94,11 @@ def generate_api_nav():api_nav = {}api_path = Path("docs/api")- # First process each top-level module directoryfor dir_path in sorted(api_path.iterdir()):if dir_path.is_dir():- category = dir_path.name+ category = INDEX_NAME[dir_path.name]api_nav[category] = build_nav_structure(dir_path, Path("docs"))- # Then process any .md files directly in the api directory- for path in sorted(api_path.glob("*.md")):- if path.parent == api_path: # Only process files directly in api/- name = path.stem- api_nav[name] = str(path.relative_to(Path("docs")))-return api_nav