Skip to content

Commit

Permalink
Merge pull request #1092 from dat-boris/patch-prompt
Browse files Browse the repository at this point in the history
fix(dspy): fix langchain predict (#1091)
  • Loading branch information
okhat authored Jun 4, 2024
2 parents 16a8b34 + a8c1a0f commit 183564f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions dspy/teleprompt/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,17 @@ def _prepare_predictor_mappings(self):

for (name1, predictor1), (name2, predictor2) in zip(student.named_predictors(), teacher.named_predictors()):
assert name1 == name2, "Student and teacher must have the same program structure."
assert predictor1.signature.equals(
predictor2.signature,
), (f"Student and teacher must have the same signatures. "
f"{type(predictor1.signature)} != {type(predictor2.signature)}"
if hasattr(predictor1.signature, "equals"):
assert predictor1.signature.equals(
predictor2.signature,
), (f"Student and teacher must have the same signatures. "
f"{type(predictor1.signature)} != {type(predictor2.signature)}"
)
else:
# fallback in case if .equals is not implemented (e.g. dsp.Prompt)
assert predictor1.signature == predictor2.signature, (
f"Student and teacher must have the same signatures. "
f"{type(predictor1.signature)} != {type(predictor2.signature)}"
)
assert id(predictor1) != id(predictor2), "Student and teacher must be different objects."

Expand Down

0 comments on commit 183564f

Please sign in to comment.