-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace relative imports by absolute imports (#1945)
* init * Remove relative imports * fix broken tests
- Loading branch information
1 parent
e0907eb
commit 7c2f604
Showing
21 changed files
with
188 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from dspy.adapters.base import Adapter | ||
from dspy.adapters.chat_adapter import ChatAdapter | ||
from dspy.adapters.json_adapter import JSONAdapter | ||
from dspy.adapters.json_adapter import JSONAdapter | ||
from dspy.adapters.image_utils import Image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
from .colors import Colors | ||
from .dataloader import DataLoader | ||
from .dataset import Dataset | ||
from .hotpotqa import HotPotQA | ||
from .math import MATH | ||
from dspy.datasets.colors import Colors | ||
from dspy.datasets.dataloader import DataLoader | ||
from dspy.datasets.dataset import Dataset | ||
from dspy.datasets.hotpotqa import HotPotQA | ||
from dspy.datasets.math import MATH | ||
|
||
__all__ = [ | ||
"Colors", | ||
"DataLoader", | ||
"Dataset", | ||
"HotPotQA", | ||
"MATH", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
from dspy.dsp.utils import EM, normalize_text | ||
|
||
from .auto_evaluation import * | ||
from .evaluate import Evaluate | ||
from .metrics import * | ||
from dspy.evaluate import auto_evaluation | ||
from dspy.evaluate.evaluate import Evaluate | ||
from dspy.evaluate import metrics | ||
|
||
__all__ = [ | ||
"auto_evaluation", | ||
"Evaluate", | ||
"metrics", | ||
"EM", | ||
"normalize_text", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .module_graph import * | ||
from dspy.experimental.module_graph import * | ||
|
||
from .synthesizer import * | ||
from .synthetic_data import * | ||
from dspy.experimental.synthesizer import * | ||
from dspy.experimental.synthetic_data import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from .synthesizer import * | ||
from dspy.experimental.synthesizer import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
from .aggregation import majority | ||
from .chain_of_thought import ChainOfThought | ||
from .chain_of_thought_with_hint import ChainOfThoughtWithHint | ||
from .knn import KNN | ||
from .multi_chain_comparison import MultiChainComparison | ||
from .predict import Predict | ||
from .program_of_thought import ProgramOfThought | ||
from .react import ReAct, Tool | ||
from .parallel import Parallel | ||
# from .retry import Retry | ||
from dspy.predict.aggregation import majority | ||
from dspy.predict.chain_of_thought import ChainOfThought | ||
from dspy.predict.chain_of_thought_with_hint import ChainOfThoughtWithHint | ||
from dspy.predict.knn import KNN | ||
from dspy.predict.multi_chain_comparison import MultiChainComparison | ||
from dspy.predict.predict import Predict | ||
from dspy.predict.program_of_thought import ProgramOfThought | ||
from dspy.predict.react import ReAct, Tool | ||
from dspy.predict.parallel import Parallel | ||
|
||
__all__ = [ | ||
"majority", | ||
"ChainOfThought", | ||
"ChainOfThoughtWithHint", | ||
"KNN", | ||
"MultiChainComparison", | ||
"Predict", | ||
"ProgramOfThought", | ||
"ReAct", | ||
"Tool", | ||
"Parallel", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .avatar import * | ||
from .models import * | ||
from .signatures import * | ||
from dspy.predict.avatar.avatar import * | ||
from dspy.predict.avatar.models import * | ||
from dspy.predict.avatar.signatures import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
from .assertions import * | ||
from .example import * | ||
from .prediction import * | ||
from .program import * | ||
from .python_interpreter import * | ||
from dspy.primitives import assertions | ||
from dspy.primitives.example import Example | ||
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 | ||
|
||
|
||
__all__ = [ | ||
"assertions", | ||
"Example", | ||
"BaseModule", | ||
"Prediction", | ||
"Completions", | ||
"Program", | ||
"Module", | ||
"PythonInterpreter", | ||
"TextPrompt", | ||
"CodePrompt", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
from .grounded_proposer import GroundedProposer | ||
from dspy.propose.grounded_proposer import GroundedProposer | ||
|
||
__all__ = [ | ||
"GroundedProposer", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
from .retrieve import Retrieve | ||
from dspy.retrieve.retrieve import Retrieve | ||
|
||
__all__ = [ | ||
"Retrieve", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from .embeddings import Embeddings | ||
from dspy.retrievers.embeddings import Embeddings | ||
|
||
__all__ = ["Embeddings"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,23 @@ | ||
from .field import * | ||
from .signature import * | ||
from dspy.signatures.field import InputField, OutputField, OldField, OldInputField, OldOutputField | ||
from dspy.signatures.signature import ( | ||
SignatureMeta, | ||
Signature, | ||
update_signatures, | ||
ensure_signature, | ||
make_signature, | ||
infer_prefix, | ||
) | ||
|
||
__all__ = [ | ||
"InputField", | ||
"OutputField", | ||
"OldField", | ||
"OldInputField", | ||
"OldOutputField", | ||
"SignatureMeta", | ||
"Signature", | ||
"infer_prefix", | ||
"update_signatures", | ||
"ensure_signature", | ||
"make_signature", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
from .avatar_optimizer import * | ||
from .bettertogether import BetterTogether | ||
from .bootstrap import * | ||
from .bootstrap_finetune import BootstrapFinetune | ||
from .copro_optimizer import COPRO | ||
from .ensemble import * | ||
from .knn_fewshot import * | ||
from dspy.teleprompt.avatar_optimizer import AvatarOptimizer | ||
from dspy.teleprompt.bettertogether import BetterTogether | ||
from dspy.teleprompt.bootstrap import BootstrapFewShot | ||
from dspy.teleprompt.bootstrap_finetune import BootstrapFinetune | ||
from dspy.teleprompt.copro_optimizer import COPRO | ||
from dspy.teleprompt.ensemble import Ensemble | ||
from dspy.teleprompt.knn_fewshot import KNNFewShot | ||
|
||
# from .mipro_optimizer import MIPRO | ||
from .mipro_optimizer_v2 import MIPROv2 | ||
from .random_search import * | ||
from dspy.teleprompt.mipro_optimizer_v2 import MIPROv2 | ||
from dspy.teleprompt.random_search import BootstrapFewShotWithRandomSearch | ||
|
||
# from .signature_opt import SignatureOptimizer | ||
# from .signature_opt_bayesian import BayesianSignatureOptimizer | ||
from .teleprompt import * | ||
from .teleprompt_optuna import * | ||
from .vanilla import * | ||
from dspy.teleprompt.teleprompt import Teleprompter | ||
from dspy.teleprompt.teleprompt_optuna import BootstrapFewShotWithOptuna | ||
from dspy.teleprompt.vanilla import LabeledFewShot | ||
|
||
__all__ = [ | ||
"AvatarOptimizer", | ||
"BetterTogether", | ||
"BootstrapFewShot", | ||
"BootstrapFinetune", | ||
"COPRO", | ||
"Ensemble", | ||
"KNNFewShot", | ||
"MIPROv2", | ||
"BootstrapFewShotWithRandomSearch", | ||
"BootstrapFewShotWithOptuna", | ||
"LabeledFewShot", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
from dspy.utils.callback import BaseCallback, with_callbacks | ||
from dspy.utils.dummies import * | ||
from dspy.utils.caching import * | ||
from dspy.utils.logging_utils import * | ||
from dspy.utils.dummies import DummyLM, DummyVectorizer, dummy_rm | ||
|
||
import os | ||
import ujson | ||
import requests | ||
|
||
|
||
def download(url): | ||
filename = os.path.basename(url) | ||
remote_size = int(requests.head(url, allow_redirects=True).headers.get('Content-Length', 0)) | ||
remote_size = int(requests.head(url, allow_redirects=True).headers.get("Content-Length", 0)) | ||
local_size = os.path.getsize(filename) if os.path.exists(filename) else 0 | ||
|
||
if local_size != remote_size: | ||
print(f"Downloading '{filename}'...") | ||
with requests.get(url, stream=True) as r, open(filename, 'wb') as f: | ||
for chunk in r.iter_content(chunk_size=8192): f.write(chunk) | ||
with requests.get(url, stream=True) as r, open(filename, "wb") as f: | ||
for chunk in r.iter_content(chunk_size=8192): | ||
f.write(chunk) | ||
|
||
|
||
__all__ = [ | ||
"download", | ||
"BaseCallback", | ||
"with_callbacks", | ||
"DummyLM", | ||
"DummyVectorizer", | ||
"dummy_rm", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters