Skip to content

Commit

Permalink
Update multi_chain_comparison.py (#2025)
Browse files Browse the repository at this point in the history
Encountered a type error locally since my signature was returning a float (score), which doesn't have the `strip()` method. Once we cast this answer to a string, things work smoothly. 

NOTE: It seems like the answers provided within the completions only contain the final output field, but this does not generalize to cases where the signature has multiple output fields.
  • Loading branch information
zbambergerNLP authored Jan 8, 2025
1 parent 9c5a44e commit 9515397
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dspy/predict/multi_chain_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def forward(self, completions, **kwargs):

for c in completions:
rationale = c.get('rationale', c.get('reasoning')).strip().split("\n")[0].strip()
answer = c[self.last_key].strip().split("\n")[0].strip()
answer = str(c[self.last_key]).strip().split("\n")[0].strip()
attempts.append(
f"«I'm trying to {rationale} I'm not sure but my prediction is {answer}»",
)
Expand Down

0 comments on commit 9515397

Please sign in to comment.