From 515cea6bb1410c760709d72f2f07fb9bb438361c Mon Sep 17 00:00:00 2001 From: chenmoneygithub Date: Sun, 22 Dec 2024 17:30:19 -0800 Subject: [PATCH 1/4] Fixes on imports --- dspy/__init__.py | 13 +------------ dspy/adapters/__init__.py | 7 +++++++ dspy/clients/__init__.py | 3 +-- dspy/evaluate/__init__.py | 10 ++++++++++ dspy/experimental/synthesizer/__init__.py | 9 ++++++++- dspy/experimental/synthesizer/synthesizer.py | 13 ++++--------- dspy/primitives/__init__.py | 4 +--- dspy/signatures/__init__.py | 2 -- dspy/utils/__init__.py | 2 -- 9 files changed, 32 insertions(+), 31 deletions(-) diff --git a/dspy/__init__.py b/dspy/__init__.py index fea48caca8..b4080854e7 100644 --- a/dspy/__init__.py +++ b/dspy/__init__.py @@ -24,15 +24,4 @@ configure = settings.configure context = settings.context - -import dspy.teleprompt - -LabeledFewShot = dspy.teleprompt.LabeledFewShot -BootstrapFewShot = dspy.teleprompt.BootstrapFewShot -BootstrapFewShotWithRandomSearch = dspy.teleprompt.BootstrapFewShotWithRandomSearch -BootstrapRS = dspy.teleprompt.BootstrapFewShotWithRandomSearch -BootstrapFinetune = dspy.teleprompt.BootstrapFinetune -BetterTogether = dspy.teleprompt.BetterTogether -COPRO = dspy.teleprompt.COPRO -MIPROv2 = dspy.teleprompt.MIPROv2 -Ensemble = dspy.teleprompt.Ensemble +BootstrapRS = BootstrapFewShotWithRandomSearch diff --git a/dspy/adapters/__init__.py b/dspy/adapters/__init__.py index 5802bd58d4..e6358a27e2 100644 --- a/dspy/adapters/__init__.py +++ b/dspy/adapters/__init__.py @@ -2,3 +2,10 @@ from dspy.adapters.chat_adapter import ChatAdapter from dspy.adapters.json_adapter import JSONAdapter from dspy.adapters.image_utils import Image + +__all__ = [ + "Adapter", + "ChatAdapter", + "JSONAdapter", + "Image", +] diff --git a/dspy/clients/__init__.py b/dspy/clients/__init__.py index fbeec22e29..cb0e81689f 100644 --- a/dspy/clients/__init__.py +++ b/dspy/clients/__init__.py @@ -1,6 +1,6 @@ from dspy.clients.lm import LM from dspy.clients.provider import Provider, TrainingJob -from dspy.clients.base_lm import BaseLM, inspect_history +from dspy.clients.base_lm import inspect_history from dspy.clients.embedding import Embedder import litellm import os @@ -39,7 +39,6 @@ def disable_litellm_logging(): "LM", "Provider", "TrainingJob", - "BaseLM", "inspect_history", "Embedder", "enable_litellm_logging", diff --git a/dspy/evaluate/__init__.py b/dspy/evaluate/__init__.py index c2336c3f9c..a4dd669aea 100644 --- a/dspy/evaluate/__init__.py +++ b/dspy/evaluate/__init__.py @@ -3,3 +3,13 @@ from dspy.evaluate.metrics import answer_exact_match, answer_passage_match from dspy.evaluate.evaluate import Evaluate from dspy.evaluate.auto_evaluation import SemanticF1, CompleteAndGrounded + +__all__ = [ + "EM", + "normalize_text", + "answer_exact_match", + "answer_passage_match", + "Evaluate", + "SemanticF1", + "CompleteAndGrounded", +] diff --git a/dspy/experimental/synthesizer/__init__.py b/dspy/experimental/synthesizer/__init__.py index 40f0c94f70..78f879c74b 100644 --- a/dspy/experimental/synthesizer/__init__.py +++ b/dspy/experimental/synthesizer/__init__.py @@ -1 +1,8 @@ -from dspy.experimental.synthesizer import * +from dspy.experimental.synthesizer.synthesizer import Synthesizer +from dspy.experimental.synthesizer.config import SynthesizerArguments + + +__all__ = [ + "Synthesizer", + "SynthesizerArguments", +] diff --git a/dspy/experimental/synthesizer/synthesizer.py b/dspy/experimental/synthesizer/synthesizer.py index 2fea0f85dd..9a2bfcd74c 100644 --- a/dspy/experimental/synthesizer/synthesizer.py +++ b/dspy/experimental/synthesizer/synthesizer.py @@ -7,13 +7,12 @@ from tqdm import tqdm, trange import dspy - -from .config import SynthesizerArguments -from .instruction_suffixes import ( +from dspy.experimental.synthesizer.config import SynthesizerArguments +from dspy.experimental.synthesizer.instruction_suffixes import ( INPUT_GENERATION_TASK_WITH_EXAMPLES_SUFFIX, INPUT_GENERATION_TASK_WITH_FEEDBACK_SUFFIX, ) -from .signatures import ( +from dspy.experimental.synthesizer.signatures import ( ExplainTask, GenerateFieldDescription, GenerateInputFieldsData, @@ -22,12 +21,8 @@ UnderstandTask, UpdateTaskDescriptionBasedOnFeedback, ) -from .utils import format_examples +from dspy.experimental.synthesizer.utils import format_examples -__all__ = [ - "Synthesizer", - "SynthesizerArguments", -] class Synthesizer: def __init__(self, config: SynthesizerArguments): diff --git a/dspy/primitives/__init__.py b/dspy/primitives/__init__.py index 655d9d67d6..21ee25be82 100644 --- a/dspy/primitives/__init__.py +++ b/dspy/primitives/__init__.py @@ -3,7 +3,7 @@ from dspy.primitives.module import BaseModule from dspy.primitives.prediction import Prediction, Completions from dspy.primitives.program import Program, Module -from dspy.primitives.python_interpreter import PythonInterpreter, TextPrompt, CodePrompt +from dspy.primitives.python_interpreter import PythonInterpreter __all__ = [ @@ -15,6 +15,4 @@ "Program", "Module", "PythonInterpreter", - "TextPrompt", - "CodePrompt", ] diff --git a/dspy/signatures/__init__.py b/dspy/signatures/__init__.py index b94fb579ff..2f92b389b4 100644 --- a/dspy/signatures/__init__.py +++ b/dspy/signatures/__init__.py @@ -3,7 +3,6 @@ SignatureMeta, Signature, update_signatures, - ensure_signature, make_signature, infer_prefix, ) @@ -18,6 +17,5 @@ "Signature", "infer_prefix", "update_signatures", - "ensure_signature", "make_signature", ] diff --git a/dspy/utils/__init__.py b/dspy/utils/__init__.py index b2f2d053c1..978f575c36 100644 --- a/dspy/utils/__init__.py +++ b/dspy/utils/__init__.py @@ -18,9 +18,7 @@ def download(url): __all__ = [ - "download", "BaseCallback", - "with_callbacks", "DummyLM", "DummyVectorizer", "dummy_rm", From 721d261a4e3fc0d2086ef09a4463949a1e9e564b Mon Sep 17 00:00:00 2001 From: chenmoneygithub Date: Mon, 23 Dec 2024 14:19:47 -0800 Subject: [PATCH 2/4] Add back BaseLM --- dspy/clients/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dspy/clients/__init__.py b/dspy/clients/__init__.py index cb0e81689f..869c544d97 100644 --- a/dspy/clients/__init__.py +++ b/dspy/clients/__init__.py @@ -1,6 +1,6 @@ from dspy.clients.lm import LM from dspy.clients.provider import Provider, TrainingJob -from dspy.clients.base_lm import inspect_history +from dspy.clients.base_lm import BaseLM, inspect_history from dspy.clients.embedding import Embedder import litellm import os @@ -36,6 +36,7 @@ def disable_litellm_logging(): __all__ = [ + "BaseLM", "LM", "Provider", "TrainingJob", From 148f987a379f574317d3bc1384c9df3f6e79e3bf Mon Sep 17 00:00:00 2001 From: Omar Khattab Date: Wed, 25 Dec 2024 13:06:35 -0800 Subject: [PATCH 3/4] Update __init__.py --- dspy/utils/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dspy/utils/__init__.py b/dspy/utils/__init__.py index 978f575c36..b2f2d053c1 100644 --- a/dspy/utils/__init__.py +++ b/dspy/utils/__init__.py @@ -18,7 +18,9 @@ def download(url): __all__ = [ + "download", "BaseCallback", + "with_callbacks", "DummyLM", "DummyVectorizer", "dummy_rm", From b96895f0173ad7d5ce7bbf277933c1114f799ee7 Mon Sep 17 00:00:00 2001 From: Omar Khattab Date: Wed, 25 Dec 2024 13:07:41 -0800 Subject: [PATCH 4/4] Update __init__.py --- dspy/signatures/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dspy/signatures/__init__.py b/dspy/signatures/__init__.py index 2f92b389b4..3b902dbb5b 100644 --- a/dspy/signatures/__init__.py +++ b/dspy/signatures/__init__.py @@ -3,10 +3,12 @@ SignatureMeta, Signature, update_signatures, + ensure_signature, make_signature, infer_prefix, ) + __all__ = [ "InputField", "OutputField", @@ -17,5 +19,6 @@ "Signature", "infer_prefix", "update_signatures", + "ensure_signature", "make_signature", ]