DSPy: The framework for programming—not prompting—language models
Python
Rename modules to module (#8407)
TomuHirata407dcca21635
diff --git a/dspy/predict/chain_of_thought.py b/dspy/predict/chain_of_thought.pyindex 744cbbd31..ab2a196db 100644--- a/dspy/predict/chain_of_thought.py+++ b/dspy/predict/chain_of_thought.py@@ -3,7 +3,7 @@ from typing import Optional, Type, Unionfrom pydantic.fields import FieldInfoimport dspy-from dspy.primitives.modules import Module+from dspy.primitives.module import Modulefrom dspy.signatures.field import OutputFieldfrom dspy.signatures.signature import Signature, ensure_signaturediff --git a/dspy/predict/multi_chain_comparison.py b/dspy/predict/multi_chain_comparison.pyindex 1a37c8399..eaab57673 100644--- a/dspy/predict/multi_chain_comparison.py+++ b/dspy/predict/multi_chain_comparison.py@@ -1,5 +1,5 @@from dspy.predict.predict import Predict-from dspy.primitives.modules import Module+from dspy.primitives.module import Modulefrom dspy.signatures import InputField, OutputFieldfrom dspy.signatures.signature import ensure_signaturediff --git a/dspy/predict/predict.py b/dspy/predict/predict.pyindex 6ff0d6e3a..0afb067d9 100644--- a/dspy/predict/predict.py+++ b/dspy/predict/predict.py@@ -8,7 +8,7 @@ from dspy.clients.base_lm import BaseLMfrom dspy.clients.lm import LMfrom dspy.dsp.utils.settings import settingsfrom dspy.predict.parameter import Parameter-from dspy.primitives.modules import Module+from dspy.primitives.module import Modulefrom dspy.primitives.prediction import Predictionfrom dspy.signatures.signature import ensure_signaturediff --git a/dspy/predict/program_of_thought.py b/dspy/predict/program_of_thought.pyindex e06ba62fc..4b95c5060 100644--- a/dspy/predict/program_of_thought.py+++ b/dspy/predict/program_of_thought.py@@ -4,7 +4,7 @@ import refrom typing import Optional, Type, Unionimport dspy-from dspy.primitives.modules import Module+from dspy.primitives.module import Modulefrom dspy.primitives.python_interpreter import PythonInterpreterfrom dspy.signatures.signature import Signature, ensure_signaturediff --git a/dspy/predict/react.py b/dspy/predict/react.pyindex d75238671..212f7b216 100644--- a/dspy/predict/react.py+++ b/dspy/predict/react.py@@ -5,7 +5,7 @@ from litellm import ContextWindowExceededErrorimport dspyfrom dspy.adapters.types.tool import Tool-from dspy.primitives.modules import Module+from dspy.primitives.module import Modulefrom dspy.signatures.signature import ensure_signaturelogger = logging.getLogger(__name__)diff --git a/dspy/primitives/__init__.py b/dspy/primitives/__init__.pyindex d2a63eda5..4bd9b1fd3 100644--- a/dspy/primitives/__init__.py+++ b/dspy/primitives/__init__.py@@ -1,6 +1,6 @@from dspy.primitives.base_module import BaseModulefrom dspy.primitives.example import Example-from dspy.primitives.modules import Module+from dspy.primitives.module import Modulefrom dspy.primitives.prediction import Completions, Predictionfrom dspy.primitives.python_interpreter import PythonInterpreterdiff --git a/dspy/primitives/modules.py b/dspy/primitives/module.pysimilarity index 99%rename from dspy/primitives/modules.pyrename to dspy/primitives/module.pyindex 1c539aa7b..450816706 100644--- a/dspy/primitives/modules.py+++ b/dspy/primitives/module.py@@ -1,4 +1,3 @@-# TODO: Rename to module.pyimport inspectimport loggingfrom typing import Optionaldiff --git a/dspy/streaming/streamify.py b/dspy/streaming/streamify.pyindex a24cf4671..89ffb6f94 100644--- a/dspy/streaming/streamify.py+++ b/dspy/streaming/streamify.py@@ -21,7 +21,7 @@ from dspy.utils.asyncify import asyncifylogger = logging.getLogger(__name__)if TYPE_CHECKING:- from dspy.primitives.modules import Module+ from dspy.primitives.module import Moduledef streamify(diff --git a/dspy/streaming/streaming_listener.py b/dspy/streaming/streaming_listener.pyindex b88f399d4..2aaec847f 100644--- a/dspy/streaming/streaming_listener.py+++ b/dspy/streaming/streaming_listener.py@@ -11,7 +11,7 @@ from dspy.dsp.utils.settings import settingsfrom dspy.streaming.messages import StreamResponseif TYPE_CHECKING:- from dspy.primitives.modules import Module+ from dspy.primitives.module import Moduleclass StreamListener:diff --git a/dspy/teleprompt/bettertogether.py b/dspy/teleprompt/bettertogether.pyindex 965b522ee..8712f8e82 100644--- a/dspy/teleprompt/bettertogether.py+++ b/dspy/teleprompt/bettertogether.py@@ -4,7 +4,7 @@ from typing import Callable, List, Optionalimport dspyfrom dspy.primitives.example import Example-from dspy.primitives.modules import Module+from dspy.primitives.module import Modulefrom dspy.teleprompt.bootstrap_finetune import (BootstrapFinetune,all_predictors_have_lms,diff --git a/dspy/teleprompt/bootstrap_finetune.py b/dspy/teleprompt/bootstrap_finetune.pyindex c203de787..117959e86 100644--- a/dspy/teleprompt/bootstrap_finetune.py+++ b/dspy/teleprompt/bootstrap_finetune.py@@ -12,7 +12,7 @@ from dspy.dsp.utils.settings import settingsfrom dspy.evaluate.evaluate import Evaluatefrom dspy.predict.predict import Predictfrom dspy.primitives.example import Example-from dspy.primitives.modules import Module+from dspy.primitives.module import Modulefrom dspy.teleprompt.teleprompt import Teleprompterfrom dspy.utils.exceptions import AdapterParseErrordiff --git a/dspy/teleprompt/grpo.py b/dspy/teleprompt/grpo.pyindex 28ea165cd..4a2e70668 100644--- a/dspy/teleprompt/grpo.py+++ b/dspy/teleprompt/grpo.py@@ -10,7 +10,7 @@ from dspy.clients.utils_finetune import GRPOGroup, TrainDataFormatfrom dspy.dsp.utils.settings import settingsfrom dspy.evaluate.evaluate import Evaluatefrom dspy.primitives.example import Example-from dspy.primitives.modules import Module+from dspy.primitives.module import Modulefrom dspy.teleprompt.bootstrap_finetune import (FailedPrediction,FinetuneTeleprompter,diff --git a/dspy/utils/asyncify.py b/dspy/utils/asyncify.pyindex b4ee8cad7..842746e49 100644--- a/dspy/utils/asyncify.py+++ b/dspy/utils/asyncify.py@@ -4,7 +4,7 @@ import asyncerfrom anyio import CapacityLimiterif TYPE_CHECKING:- from dspy.primitives.modules import Module+ from dspy.primitives.module import Module_limiter = Nonediff --git a/tests/primitives/test_modules.py b/tests/primitives/test_module.pysimilarity index 97%rename from tests/primitives/test_modules.pyrename to tests/primitives/test_module.pyindex 161cad9e9..4e9901d0d 100644--- a/tests/primitives/test_modules.py+++ b/tests/primitives/test_module.py@@ -1,6 +1,5 @@-# TODO: Rename to test_module.pyimport dspy-from dspy.primitives.modules import Module, set_attribute_by_name # Adjust the import based on your file structure+from dspy.primitives.module import Module, set_attribute_by_name # Adjust the import based on your file structurefrom dspy.utils import DummyLM