Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Allow arbitrary writeup in the api reference (#8123)

Chen Qian103d3d7b336c
diff --git a/docs/docs/api/adapters/Adapter.md b/docs/docs/api/adapters/Adapter.md
index 2b04a8199..3d2666331 100644
--- a/docs/docs/api/adapters/Adapter.md
+++ b/docs/docs/api/adapters/Adapter.md
@@ -1,10 +1,12 @@
# dspy.Adapter
+<!-- START_API_REF -->
::: dspy.Adapter
handler: python
options:
members:
- __call__
+ - acall
- format
- format_assistant_message_content
- format_conversation_history
@@ -22,3 +24,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/adapters/ChatAdapter.md b/docs/docs/api/adapters/ChatAdapter.md
index b67871a30..e76eeec05 100644
--- a/docs/docs/api/adapters/ChatAdapter.md
+++ b/docs/docs/api/adapters/ChatAdapter.md
@@ -1,10 +1,12 @@
# dspy.ChatAdapter
+<!-- START_API_REF -->
::: dspy.ChatAdapter
handler: python
options:
members:
- __call__
+ - acall
- format
- format_assistant_message_content
- format_conversation_history
@@ -25,3 +27,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/adapters/JSONAdapter.md b/docs/docs/api/adapters/JSONAdapter.md
index 4a5fb1212..0043c95ea 100644
--- a/docs/docs/api/adapters/JSONAdapter.md
+++ b/docs/docs/api/adapters/JSONAdapter.md
@@ -1,10 +1,12 @@
# dspy.JSONAdapter
+<!-- START_API_REF -->
::: dspy.JSONAdapter
handler: python
options:
members:
- __call__
+ - acall
- format
- format_assistant_message_content
- format_conversation_history
@@ -25,3 +27,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/adapters/TwoStepAdapter.md b/docs/docs/api/adapters/TwoStepAdapter.md
index 767a044e3..aea44e4b3 100644
--- a/docs/docs/api/adapters/TwoStepAdapter.md
+++ b/docs/docs/api/adapters/TwoStepAdapter.md
@@ -1,10 +1,12 @@
# dspy.TwoStepAdapter
+<!-- START_API_REF -->
::: dspy.TwoStepAdapter
handler: python
options:
members:
- __call__
+ - acall
- format
- format_assistant_message_content
- format_conversation_history
@@ -22,3 +24,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/evaluation/CompleteAndGrounded.md b/docs/docs/api/evaluation/CompleteAndGrounded.md
index b2662ce9d..d6e65b4f0 100644
--- a/docs/docs/api/evaluation/CompleteAndGrounded.md
+++ b/docs/docs/api/evaluation/CompleteAndGrounded.md
@@ -1,10 +1,12 @@
# dspy.evaluate.CompleteAndGrounded
+<!-- START_API_REF -->
::: dspy.evaluate.CompleteAndGrounded
handler: python
options:
members:
- __call__
+ - acall
- batch
- deepcopy
- dump_state
@@ -29,3 +31,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/evaluation/Evaluate.md b/docs/docs/api/evaluation/Evaluate.md
index acefdb6d7..17d369d72 100644
--- a/docs/docs/api/evaluation/Evaluate.md
+++ b/docs/docs/api/evaluation/Evaluate.md
@@ -1,5 +1,6 @@
# dspy.Evaluate
+<!-- START_API_REF -->
::: dspy.Evaluate
handler: python
options:
@@ -13,3 +14,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/evaluation/SemanticF1.md b/docs/docs/api/evaluation/SemanticF1.md
index 969685769..c34283ff3 100644
--- a/docs/docs/api/evaluation/SemanticF1.md
+++ b/docs/docs/api/evaluation/SemanticF1.md
@@ -1,10 +1,12 @@
# dspy.evaluate.SemanticF1
+<!-- START_API_REF -->
::: dspy.evaluate.SemanticF1
handler: python
options:
members:
- __call__
+ - acall
- batch
- deepcopy
- dump_state
@@ -29,3 +31,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/evaluation/answer_exact_match.md b/docs/docs/api/evaluation/answer_exact_match.md
index a876481e4..f3faa5f6a 100644
--- a/docs/docs/api/evaluation/answer_exact_match.md
+++ b/docs/docs/api/evaluation/answer_exact_match.md
@@ -1,5 +1,6 @@
# dspy.evaluate.answer_exact_match
+<!-- START_API_REF -->
::: dspy.evaluate.answer_exact_match
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/evaluation/answer_passage_match.md b/docs/docs/api/evaluation/answer_passage_match.md
index e8da0a80f..2fcbaf524 100644
--- a/docs/docs/api/evaluation/answer_passage_match.md
+++ b/docs/docs/api/evaluation/answer_passage_match.md
@@ -1,5 +1,6 @@
# dspy.evaluate.answer_passage_match
+<!-- START_API_REF -->
::: dspy.evaluate.answer_passage_match
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/models/Embedder.md b/docs/docs/api/models/Embedder.md
index 7fe3d8bde..48a2459ab 100644
--- a/docs/docs/api/models/Embedder.md
+++ b/docs/docs/api/models/Embedder.md
@@ -1,10 +1,12 @@
# dspy.Embedder
+<!-- START_API_REF -->
::: dspy.Embedder
handler: python
options:
members:
- __call__
+ - acall
show_source: true
show_root_heading: true
heading_level: 2
@@ -13,3 +15,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/models/LM.md b/docs/docs/api/models/LM.md
index b7da53cae..0eecbd830 100644
--- a/docs/docs/api/models/LM.md
+++ b/docs/docs/api/models/LM.md
@@ -1,10 +1,13 @@
# dspy.LM
+<!-- START_API_REF -->
::: dspy.LM
handler: python
options:
members:
- __call__
+ - acall
+ - aforward
- copy
- dump_state
- finetune
@@ -22,3 +25,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/modules/BestOfN.md b/docs/docs/api/modules/BestOfN.md
index 3df7745d3..4439017f1 100644
--- a/docs/docs/api/modules/BestOfN.md
+++ b/docs/docs/api/modules/BestOfN.md
@@ -1,10 +1,12 @@
# dspy.BestOfN
+<!-- START_API_REF -->
::: dspy.BestOfN
handler: python
options:
members:
- __call__
+ - acall
- batch
- deepcopy
- dump_state
@@ -29,3 +31,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/modules/ChainOfThought.md b/docs/docs/api/modules/ChainOfThought.md
index 1bc06577b..125ba6f85 100644
--- a/docs/docs/api/modules/ChainOfThought.md
+++ b/docs/docs/api/modules/ChainOfThought.md
@@ -1,10 +1,13 @@
# dspy.ChainOfThought
+<!-- START_API_REF -->
::: dspy.ChainOfThought
handler: python
options:
members:
- __call__
+ - acall
+ - aforward
- batch
- deepcopy
- dump_state
@@ -29,3 +32,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/modules/ChainOfThoughtWithHint.md b/docs/docs/api/modules/ChainOfThoughtWithHint.md
index 058c00c23..cbd4071f1 100644
--- a/docs/docs/api/modules/ChainOfThoughtWithHint.md
+++ b/docs/docs/api/modules/ChainOfThoughtWithHint.md
@@ -1,10 +1,12 @@
# dspy.ChainOfThoughtWithHint
+<!-- START_API_REF -->
::: dspy.ChainOfThoughtWithHint
handler: python
options:
members:
- __call__
+ - acall
- batch
- deepcopy
- dump_state
@@ -29,3 +31,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/modules/Module.md b/docs/docs/api/modules/Module.md
index 7a16122f8..f28ea31ef 100644
--- a/docs/docs/api/modules/Module.md
+++ b/docs/docs/api/modules/Module.md
@@ -1,10 +1,12 @@
# dspy.Module
+<!-- START_API_REF -->
::: dspy.Module
handler: python
options:
members:
- __call__
+ - acall
- batch
- deepcopy
- dump_state
@@ -28,3 +30,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/modules/MultiChainComparison.md b/docs/docs/api/modules/MultiChainComparison.md
index fab0e8022..5f8575ebf 100644
--- a/docs/docs/api/modules/MultiChainComparison.md
+++ b/docs/docs/api/modules/MultiChainComparison.md
@@ -1,10 +1,12 @@
# dspy.MultiChainComparison
+<!-- START_API_REF -->
::: dspy.MultiChainComparison
handler: python
options:
members:
- __call__
+ - acall
- batch
- deepcopy
- dump_state
@@ -29,3 +31,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/modules/Parallel.md b/docs/docs/api/modules/Parallel.md
index 8652791b0..f935c2dbf 100644
--- a/docs/docs/api/modules/Parallel.md
+++ b/docs/docs/api/modules/Parallel.md
@@ -1,5 +1,6 @@
# dspy.Parallel
+<!-- START_API_REF -->
::: dspy.Parallel
handler: python
options:
@@ -14,3 +15,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/modules/Predict.md b/docs/docs/api/modules/Predict.md
index 055b3b057..c7749b2a4 100644
--- a/docs/docs/api/modules/Predict.md
+++ b/docs/docs/api/modules/Predict.md
@@ -1,10 +1,13 @@
# dspy.Predict
+<!-- START_API_REF -->
::: dspy.Predict
handler: python
options:
members:
- __call__
+ - acall
+ - aforward
- batch
- deepcopy
- dump_state
@@ -32,3 +35,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/modules/Program.md b/docs/docs/api/modules/Program.md
index 51482b387..084cc0269 100644
--- a/docs/docs/api/modules/Program.md
+++ b/docs/docs/api/modules/Program.md
@@ -1,10 +1,12 @@
# dspy.Program
+<!-- START_API_REF -->
::: dspy.Program
handler: python
options:
members:
- __call__
+ - acall
- batch
- deepcopy
- dump_state
@@ -28,3 +30,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/modules/ProgramOfThought.md b/docs/docs/api/modules/ProgramOfThought.md
index 8dc409c6a..a3ad792da 100644
--- a/docs/docs/api/modules/ProgramOfThought.md
+++ b/docs/docs/api/modules/ProgramOfThought.md
@@ -1,10 +1,12 @@
# dspy.ProgramOfThought
+<!-- START_API_REF -->
::: dspy.ProgramOfThought
handler: python
options:
members:
- __call__
+ - acall
- batch
- deepcopy
- dump_state
@@ -29,3 +31,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/modules/ReAct.md b/docs/docs/api/modules/ReAct.md
index 00bcb9b7a..a2f728e80 100644
--- a/docs/docs/api/modules/ReAct.md
+++ b/docs/docs/api/modules/ReAct.md
@@ -1,10 +1,12 @@
# dspy.ReAct
+<!-- START_API_REF -->
::: dspy.ReAct
handler: python
options:
members:
- __call__
+ - acall
- batch
- deepcopy
- dump_state
@@ -30,3 +32,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/modules/Refine.md b/docs/docs/api/modules/Refine.md
index 3cfac2497..b75d0218e 100644
--- a/docs/docs/api/modules/Refine.md
+++ b/docs/docs/api/modules/Refine.md
@@ -1,10 +1,12 @@
# dspy.Refine
+<!-- START_API_REF -->
::: dspy.Refine
handler: python
options:
members:
- __call__
+ - acall
- batch
- deepcopy
- dump_state
@@ -29,3 +31,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/optimizers/BetterTogether.md b/docs/docs/api/optimizers/BetterTogether.md
index 69208b777..430639246 100644
--- a/docs/docs/api/optimizers/BetterTogether.md
+++ b/docs/docs/api/optimizers/BetterTogether.md
@@ -1,5 +1,6 @@
# dspy.BetterTogether
+<!-- START_API_REF -->
::: dspy.BetterTogether
handler: python
options:
@@ -14,3 +15,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/optimizers/BootstrapFewShot.md b/docs/docs/api/optimizers/BootstrapFewShot.md
index b76c9e4a6..3dace8195 100644
--- a/docs/docs/api/optimizers/BootstrapFewShot.md
+++ b/docs/docs/api/optimizers/BootstrapFewShot.md
@@ -1,5 +1,6 @@
# dspy.BootstrapFewShot
+<!-- START_API_REF -->
::: dspy.BootstrapFewShot
handler: python
options:
@@ -14,3 +15,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/optimizers/BootstrapFewShotWithRandomSearch.md b/docs/docs/api/optimizers/BootstrapFewShotWithRandomSearch.md
index 6fa6a64b6..f2df1530b 100644
--- a/docs/docs/api/optimizers/BootstrapFewShotWithRandomSearch.md
+++ b/docs/docs/api/optimizers/BootstrapFewShotWithRandomSearch.md
@@ -1,5 +1,6 @@
# dspy.BootstrapFewShotWithRandomSearch
+<!-- START_API_REF -->
::: dspy.BootstrapFewShotWithRandomSearch
handler: python
options:
@@ -14,3 +15,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/optimizers/BootstrapFinetune.md b/docs/docs/api/optimizers/BootstrapFinetune.md
index ac27a7110..8f1d3a337 100644
--- a/docs/docs/api/optimizers/BootstrapFinetune.md
+++ b/docs/docs/api/optimizers/BootstrapFinetune.md
@@ -1,5 +1,6 @@
# dspy.BootstrapFinetune
+<!-- START_API_REF -->
::: dspy.BootstrapFinetune
handler: python
options:
@@ -16,3 +17,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/optimizers/BootstrapRS.md b/docs/docs/api/optimizers/BootstrapRS.md
index bc2821356..df523b4e7 100644
--- a/docs/docs/api/optimizers/BootstrapRS.md
+++ b/docs/docs/api/optimizers/BootstrapRS.md
@@ -1,5 +1,6 @@
# dspy.BootstrapRS
+<!-- START_API_REF -->
::: dspy.BootstrapRS
handler: python
options:
@@ -14,3 +15,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/optimizers/COPRO.md b/docs/docs/api/optimizers/COPRO.md
index 53e1bc376..89926b407 100644
--- a/docs/docs/api/optimizers/COPRO.md
+++ b/docs/docs/api/optimizers/COPRO.md
@@ -1,5 +1,6 @@
# dspy.COPRO
+<!-- START_API_REF -->
::: dspy.COPRO
handler: python
options:
@@ -14,3 +15,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/optimizers/Ensemble.md b/docs/docs/api/optimizers/Ensemble.md
index 1585f5c5b..58aef770f 100644
--- a/docs/docs/api/optimizers/Ensemble.md
+++ b/docs/docs/api/optimizers/Ensemble.md
@@ -1,5 +1,6 @@
# dspy.Ensemble
+<!-- START_API_REF -->
::: dspy.Ensemble
handler: python
options:
@@ -14,3 +15,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/optimizers/InferRules.md b/docs/docs/api/optimizers/InferRules.md
index 797814b99..035c0b138 100644
--- a/docs/docs/api/optimizers/InferRules.md
+++ b/docs/docs/api/optimizers/InferRules.md
@@ -1,5 +1,6 @@
# dspy.InferRules
+<!-- START_API_REF -->
::: dspy.InferRules
handler: python
options:
@@ -19,3 +20,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/optimizers/KNN.md b/docs/docs/api/optimizers/KNN.md
index e37cd93d8..d8c3fcf94 100644
--- a/docs/docs/api/optimizers/KNN.md
+++ b/docs/docs/api/optimizers/KNN.md
@@ -1,5 +1,6 @@
# dspy.KNN
+<!-- START_API_REF -->
::: dspy.KNN
handler: python
options:
@@ -13,3 +14,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/optimizers/KNNFewShot.md b/docs/docs/api/optimizers/KNNFewShot.md
index 9b3bba7f4..758a6f819 100644
--- a/docs/docs/api/optimizers/KNNFewShot.md
+++ b/docs/docs/api/optimizers/KNNFewShot.md
@@ -1,5 +1,6 @@
# dspy.KNNFewShot
+<!-- START_API_REF -->
::: dspy.KNNFewShot
handler: python
options:
@@ -14,3 +15,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/optimizers/LabeledFewShot.md b/docs/docs/api/optimizers/LabeledFewShot.md
index 203922cd0..f1d96313e 100644
--- a/docs/docs/api/optimizers/LabeledFewShot.md
+++ b/docs/docs/api/optimizers/LabeledFewShot.md
@@ -1,5 +1,6 @@
# dspy.LabeledFewShot
+<!-- START_API_REF -->
::: dspy.LabeledFewShot
handler: python
options:
@@ -14,3 +15,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/optimizers/MIPROv2.md b/docs/docs/api/optimizers/MIPROv2.md
index 241dd0384..10a6b756b 100644
--- a/docs/docs/api/optimizers/MIPROv2.md
+++ b/docs/docs/api/optimizers/MIPROv2.md
@@ -1,5 +1,8 @@
# dspy.MIPROv2
+MIPROv2 optimizer optimizes instruction and also build few-shot examples.
+
+<!-- START_API_REF -->
::: dspy.MIPROv2
handler: python
options:
@@ -14,3 +17,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/primitives/Example.md b/docs/docs/api/primitives/Example.md
index 6634f73f7..1cfecea07 100644
--- a/docs/docs/api/primitives/Example.md
+++ b/docs/docs/api/primitives/Example.md
@@ -1,5 +1,6 @@
# dspy.Example
+<!-- START_API_REF -->
::: dspy.Example
handler: python
options:
@@ -22,3 +23,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/primitives/History.md b/docs/docs/api/primitives/History.md
index 409e30c84..3b5b717d0 100644
--- a/docs/docs/api/primitives/History.md
+++ b/docs/docs/api/primitives/History.md
@@ -1,5 +1,6 @@
# dspy.History
+<!-- START_API_REF -->
::: dspy.History
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/primitives/Image.md b/docs/docs/api/primitives/Image.md
index 68a37b6e2..5cee56032 100644
--- a/docs/docs/api/primitives/Image.md
+++ b/docs/docs/api/primitives/Image.md
@@ -1,5 +1,6 @@
# dspy.Image
+<!-- START_API_REF -->
::: dspy.Image
handler: python
options:
@@ -17,3 +18,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/primitives/Prediction.md b/docs/docs/api/primitives/Prediction.md
index 0d0cb6442..9f78b2b2c 100644
--- a/docs/docs/api/primitives/Prediction.md
+++ b/docs/docs/api/primitives/Prediction.md
@@ -1,5 +1,6 @@
# dspy.Prediction
+<!-- START_API_REF -->
::: dspy.Prediction
handler: python
options:
@@ -25,3 +26,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/primitives/Tool.md b/docs/docs/api/primitives/Tool.md
index ec482d5be..495939e1d 100644
--- a/docs/docs/api/primitives/Tool.md
+++ b/docs/docs/api/primitives/Tool.md
@@ -1,10 +1,12 @@
# dspy.Tool
+<!-- START_API_REF -->
::: dspy.Tool
handler: python
options:
members:
- __call__
+ - acall
show_source: true
show_root_heading: true
heading_level: 2
@@ -13,3 +15,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/signatures/InputField.md b/docs/docs/api/signatures/InputField.md
index b483f8ca0..f9b679d71 100644
--- a/docs/docs/api/signatures/InputField.md
+++ b/docs/docs/api/signatures/InputField.md
@@ -1,5 +1,6 @@
# dspy.InputField
+<!-- START_API_REF -->
::: dspy.InputField
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/signatures/OutputField.md b/docs/docs/api/signatures/OutputField.md
index d5004428f..16a096ca2 100644
--- a/docs/docs/api/signatures/OutputField.md
+++ b/docs/docs/api/signatures/OutputField.md
@@ -1,5 +1,6 @@
# dspy.OutputField
+<!-- START_API_REF -->
::: dspy.OutputField
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/signatures/Signature.md b/docs/docs/api/signatures/Signature.md
index af440c391..14e7db8ad 100644
--- a/docs/docs/api/signatures/Signature.md
+++ b/docs/docs/api/signatures/Signature.md
@@ -1,5 +1,6 @@
# dspy.Signature
+<!-- START_API_REF -->
::: dspy.Signature
handler: python
options:
@@ -21,3 +22,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/tools/ColBERTv2.md b/docs/docs/api/tools/ColBERTv2.md
index e24ea0a5c..9cfc13277 100644
--- a/docs/docs/api/tools/ColBERTv2.md
+++ b/docs/docs/api/tools/ColBERTv2.md
@@ -1,5 +1,6 @@
# dspy.ColBERTv2
+<!-- START_API_REF -->
::: dspy.ColBERTv2
handler: python
options:
@@ -13,3 +14,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/tools/Embeddings.md b/docs/docs/api/tools/Embeddings.md
index 16dcb6a24..9e5ac375c 100644
--- a/docs/docs/api/tools/Embeddings.md
+++ b/docs/docs/api/tools/Embeddings.md
@@ -1,5 +1,6 @@
# dspy.retrievers.Embeddings
+<!-- START_API_REF -->
::: dspy.retrievers.Embeddings
handler: python
options:
@@ -14,3 +15,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/tools/PythonInterpreter.md b/docs/docs/api/tools/PythonInterpreter.md
index a4fa37aba..baf6af1cf 100644
--- a/docs/docs/api/tools/PythonInterpreter.md
+++ b/docs/docs/api/tools/PythonInterpreter.md
@@ -1,5 +1,6 @@
# dspy.PythonInterpreter
+<!-- START_API_REF -->
::: dspy.PythonInterpreter
handler: python
options:
@@ -15,3 +16,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/utils/StatusMessage.md b/docs/docs/api/utils/StatusMessage.md
index cbc57348e..161b7a13d 100644
--- a/docs/docs/api/utils/StatusMessage.md
+++ b/docs/docs/api/utils/StatusMessage.md
@@ -1,5 +1,6 @@
# dspy.streaming.StatusMessage
+<!-- START_API_REF -->
::: dspy.streaming.StatusMessage
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/utils/StatusMessageProvider.md b/docs/docs/api/utils/StatusMessageProvider.md
index e375c3e83..19fac23ae 100644
--- a/docs/docs/api/utils/StatusMessageProvider.md
+++ b/docs/docs/api/utils/StatusMessageProvider.md
@@ -1,5 +1,6 @@
# dspy.streaming.StatusMessageProvider
+<!-- START_API_REF -->
::: dspy.streaming.StatusMessageProvider
handler: python
options:
@@ -18,3 +19,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/utils/StreamListener.md b/docs/docs/api/utils/StreamListener.md
index c6d8b800c..5785c6f12 100644
--- a/docs/docs/api/utils/StreamListener.md
+++ b/docs/docs/api/utils/StreamListener.md
@@ -1,5 +1,6 @@
# dspy.streaming.StreamListener
+<!-- START_API_REF -->
::: dspy.streaming.StreamListener
handler: python
options:
@@ -14,3 +15,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/utils/asyncify.md b/docs/docs/api/utils/asyncify.md
index ed30423a1..b1fa70a88 100644
--- a/docs/docs/api/utils/asyncify.md
+++ b/docs/docs/api/utils/asyncify.md
@@ -1,5 +1,6 @@
# dspy.asyncify
+<!-- START_API_REF -->
::: dspy.asyncify
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/utils/disable_litellm_logging.md b/docs/docs/api/utils/disable_litellm_logging.md
index 2fb8ca3c7..2d7b2a074 100644
--- a/docs/docs/api/utils/disable_litellm_logging.md
+++ b/docs/docs/api/utils/disable_litellm_logging.md
@@ -1,5 +1,6 @@
# dspy.disable_litellm_logging
+<!-- START_API_REF -->
::: dspy.disable_litellm_logging
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/utils/disable_logging.md b/docs/docs/api/utils/disable_logging.md
index aa1bb1813..6bb9debbe 100644
--- a/docs/docs/api/utils/disable_logging.md
+++ b/docs/docs/api/utils/disable_logging.md
@@ -1,5 +1,6 @@
# dspy.disable_logging
+<!-- START_API_REF -->
::: dspy.disable_logging
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/utils/enable_litellm_logging.md b/docs/docs/api/utils/enable_litellm_logging.md
index c1ca2ab1e..fa7f73705 100644
--- a/docs/docs/api/utils/enable_litellm_logging.md
+++ b/docs/docs/api/utils/enable_litellm_logging.md
@@ -1,5 +1,6 @@
# dspy.enable_litellm_logging
+<!-- START_API_REF -->
::: dspy.enable_litellm_logging
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/utils/enable_logging.md b/docs/docs/api/utils/enable_logging.md
index 02f21e1f1..55ae12b02 100644
--- a/docs/docs/api/utils/enable_logging.md
+++ b/docs/docs/api/utils/enable_logging.md
@@ -1,5 +1,6 @@
# dspy.enable_logging
+<!-- START_API_REF -->
::: dspy.enable_logging
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/utils/inspect_history.md b/docs/docs/api/utils/inspect_history.md
index 15736267f..81357c6d7 100644
--- a/docs/docs/api/utils/inspect_history.md
+++ b/docs/docs/api/utils/inspect_history.md
@@ -1,5 +1,6 @@
# dspy.inspect_history
+<!-- START_API_REF -->
::: dspy.inspect_history
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/utils/load.md b/docs/docs/api/utils/load.md
index 9579e115e..dec1eaa57 100644
--- a/docs/docs/api/utils/load.md
+++ b/docs/docs/api/utils/load.md
@@ -1,5 +1,6 @@
# dspy.load
+<!-- START_API_REF -->
::: dspy.load
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/docs/api/utils/streamify.md b/docs/docs/api/utils/streamify.md
index 0bf842688..57e1f7ede 100644
--- a/docs/docs/api/utils/streamify.md
+++ b/docs/docs/api/utils/streamify.md
@@ -1,5 +1,6 @@
# dspy.streamify
+<!-- START_API_REF -->
::: dspy.streamify
handler: python
options:
@@ -11,3 +12,4 @@
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
diff --git a/docs/scripts/generate_api_docs.py b/docs/scripts/generate_api_docs.py
index e7978806f..3b218972c 100644
--- a/docs/scripts/generate_api_docs.py
+++ b/docs/scripts/generate_api_docs.py
@@ -134,8 +134,7 @@ def generate_doc_page(name: str, module_path: str, obj: Any, is_root: bool = Fal
members:
{methods_list}"""
- return f"""# {module_path}.{name}
-
+ return f"""<!-- START_API_REF -->
::: {module_path}.{name}
handler: python
options:{members_config}
@@ -147,6 +146,7 @@ def generate_doc_page(name: str, module_path: str, obj: Any, is_root: bool = Fal
show_object_full_path: false
separate_signature: false
inherited_members: true
+<!-- END_API_REF -->
"""
@@ -157,6 +157,52 @@ def get_api_category(obj):
return None
+def read_existing_content(file_path: Path) -> tuple[str, str]:
+ """Read existing file content and split into pre and post API reference sections.
+
+ Returns:
+ tuple[str, str]: (content_before_api_ref, content_after_api_ref)
+ If file doesn't exist or no API ref section found, returns empty strings.
+ """
+ if not file_path.exists():
+ return "", ""
+
+ content = file_path.read_text()
+
+ # Look for our specific API reference markers
+ api_start_marker = "<!-- START_API_REF -->"
+ api_end_marker = "<!-- END_API_REF -->"
+
+ api_start = content.find(api_start_marker)
+ if api_start == -1:
+ # No API section found, treat all content as pre-content
+ return content, ""
+
+ api_end = content.find(api_end_marker)
+ if api_end == -1:
+ # Start marker found but no end marker - treat rest of file as post-content
+ api_end = len(content)
+ else:
+ api_end = api_end + len(api_end_marker)
+
+ return content[:api_start].rstrip(), content[api_end:].lstrip()
+
+
+def write_doc_file(file_path: Path, title: str, api_content: str):
+ """Write documentation to file while preserving existing content."""
+ pre_content, post_content = read_existing_content(file_path)
+
+ # If no pre-content exists, add the title
+ if not pre_content:
+ pre_content = f"# {title}\n"
+
+ # Combine all sections
+ full_content = f"{pre_content}\n\n{api_content}\n{post_content}".strip() + "\n"
+
+ # Write the combined content
+ file_path.write_text(full_content)
+
+
def generate_md_docs(output_dir: Path, excluded_modules=None):
"""Generate documentation for all public classes and functions in the dspy package.
@@ -181,8 +227,8 @@ def generate_md_docs(output_dir: Path, excluded_modules=None):
continue
page_content = generate_doc_page(name, "dspy", obj, is_root=True)
- with open(output_dir / category / f"{name}.md", "w") as f:
- f.write(page_content)
+ file_path = output_dir / category / f"{name}.md"
+ write_doc_file(file_path, f"dspy.{name}", page_content)
objects_processed[f"{obj.__module__}.{name}"] = obj
@@ -232,8 +278,8 @@ def generate_md_docs_submodule(module_path: str, output_dir: Path, objects_proce
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 / category / f"{name}.md", "w") as f:
- f.write(page_content)
+ file_path = output_dir / category / f"{name}.md"
+ write_doc_file(file_path, f"{module_path}.{name}", page_content)
objects_processed[full_name] = obj
@@ -254,19 +300,15 @@ def remove_empty_dirs(path: Path):
if __name__ == "__main__":
api_dir = Path("docs/api")
- if api_dir.exists():
- # Delete only subdirectories
- for item in api_dir.iterdir():
- if item.is_dir():
- shutil.rmtree(item)
-
- for keys in API_MAPPING.keys():
- # Create a directory for each API category
- subpath = api_dir / keys
+ api_dir.mkdir(parents=True, exist_ok=True)
+
+ # Create category directories if they don't exist
+ for category in API_MAPPING.keys():
+ subpath = api_dir / category
subpath.mkdir(parents=True, exist_ok=True)
excluded_modules = ["dspy.dsp"]
-
generate_md_docs(api_dir, excluded_modules=excluded_modules)
+
# Clean up empty directories
remove_empty_dirs(api_dir)