DSPy: The framework for programming—not prompting—language models
Python
Include built-in types in DSPy api references (#8810)
Chen Qian9a34e2187c2a
diff --git a/docs/docs/api/primitives/Audio.md b/docs/docs/api/primitives/Audio.mdnew file mode 100644index 000000000..8ad304bdf--- /dev/null+++ b/docs/docs/api/primitives/Audio.md@@ -0,0 +1,26 @@+# dspy.Audio+++<!-- START_API_REF -->+::: dspy.Audio+ handler: python+ options:+ members:+ - description+ - extract_custom_type_from_annotation+ - format+ - from_array+ - from_file+ - from_url+ - serialize_model+ - validate_input+ show_source: true+ show_root_heading: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: false+ inherited_members: true+:::+<!-- END_API_REF -->diff --git a/docs/docs/api/primitives/Code.md b/docs/docs/api/primitives/Code.mdnew file mode 100644index 000000000..96a0a212e--- /dev/null+++ b/docs/docs/api/primitives/Code.md@@ -0,0 +1,23 @@+# dspy.Code+++<!-- START_API_REF -->+::: dspy.Code+ handler: python+ options:+ members:+ - description+ - extract_custom_type_from_annotation+ - format+ - serialize_model+ - validate_input+ show_source: true+ show_root_heading: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: false+ inherited_members: true+:::+<!-- END_API_REF -->diff --git a/docs/docs/api/primitives/ToolCalls.md b/docs/docs/api/primitives/ToolCalls.mdnew file mode 100644index 000000000..192095863--- /dev/null+++ b/docs/docs/api/primitives/ToolCalls.md@@ -0,0 +1,24 @@+# dspy.ToolCalls+++<!-- START_API_REF -->+::: dspy.ToolCalls+ handler: python+ options:+ members:+ - description+ - extract_custom_type_from_annotation+ - format+ - from_dict_list+ - serialize_model+ - validate_input+ show_source: true+ show_root_heading: true+ heading_level: 2+ docstring_style: google+ show_root_full_path: true+ show_object_full_path: false+ separate_signature: false+ inherited_members: true+:::+<!-- END_API_REF -->diff --git a/docs/mkdocs.yml b/docs/mkdocs.ymlindex b39b1e0c7..cfae69f91 100644--- a/docs/mkdocs.yml+++ b/docs/mkdocs.yml@@ -131,11 +131,14 @@ nav:- MIPROv2: api/optimizers/MIPROv2.md- SIMBA: api/optimizers/SIMBA.md- Primitives:+ - Audio: api/primitives/Audio.md+ - Code: api/primitives/Code.md- Example: api/primitives/Example.md- History: api/primitives/History.md- Image: api/primitives/Image.md- Prediction: api/primitives/Prediction.md- Tool: api/primitives/Tool.md+ - ToolCalls: api/primitives/ToolCalls.md- Signatures:- InputField: api/signatures/InputField.md- OutputField: api/signatures/OutputField.mddiff --git a/docs/scripts/generate_api_docs.py b/docs/scripts/generate_api_docs.pyindex 11d391b29..e06293c77 100644--- a/docs/scripts/generate_api_docs.py+++ b/docs/scripts/generate_api_docs.py@@ -1,9 +1,9 @@-from pathlib import Pathimport importlibimport inspectimport pkgutil-import shutil+from pathlib import Pathfrom typing import Any+import dspyAPI_MAPPING = {@@ -12,11 +12,14 @@ API_MAPPING = {dspy.Embedder,],"primitives": [+ dspy.Audio,+ dspy.Code,dspy.Example,dspy.Image,dspy.History,dspy.Prediction,dspy.Tool,+ dspy.ToolCalls,],"signatures": [dspy.Signature,@@ -78,7 +81,7 @@ API_MAPPING = {dspy.KNN,dspy.KNNFewShot,dspy.InferRules,- dspy.GEPA+ dspy.GEPA,],"experimental": [dspy.experimental.Citations,@@ -91,7 +94,7 @@ def should_document_method(obj):name = obj.__name__# Exclude methods not defined in dspy, such as `model_dump_json` from pydantic.module = getattr(obj, "__module__", "")- if not module or not module.startswith(f"dspy"):+ if not module or not module.startswith("dspy"):return False# Exclude private and dunder methods, but include `__call__`if name == "__call__" or not name.startswith("_"):