Skip to content

Instantly share code, notes, and snippets.

@fsndzomga
Created April 8, 2024 22:38
Show Gist options
  • Save fsndzomga/64770fab76e68dbcaea1e21bfdb48ac8 to your computer and use it in GitHub Desktop.
Save fsndzomga/64770fab76e68dbcaea1e21bfdb48ac8 to your computer and use it in GitHub Desktop.
class logical_reasoner(dspy.Module):
def __init__(self):
super().__init__()
self.logical_reasoner = dspy.Predict("text -> premises, conclusions")
self.checker = dspy.ChainOfThought(check_logic)
def forward(self,text):
prediction = self.logical_reasoner(text=text)
result = self.checker(premises=prediction.premises, conclusions=prediction.conclusions)
return result
text="If it is raining, then the grass is wet. The grass is wet. Therefore, it is not raining."
lr = logical_reasoner()
print(lr(text=text))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment