Skip to content

Commit

Permalink
step fixes, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
WeetHet committed Sep 24, 2024
1 parent 64ffc76 commit 91e3440
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions verified_cogen/runners/chain_of_thought/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ def __init__(self, question: str, answer: str):
self.question = question
self.answer = answer

def __repr__(self) -> str:
return f"Substep(question={self.question}, answer={self.answer})"

def __eq__(self, value: object, /) -> bool:
if not isinstance(value, Substep):
return False
return self.question == value.question and self.answer == value.answer


class Step:
substeps: list[Substep] = []
Expand All @@ -26,10 +34,15 @@ def __init__(self, data: str):
elif line.startswith("===== ANSWER ====="):
appending_to = current_answer
elif line.startswith("===== QUESTION ====="):
self.substeps.append(
Substep("\n".join(current_question), "\n".join(current_answer))
)

self.question = "\n".join(data_lines[i + 1 :])
break
else:
appending_to.append(line)
self.substeps = self.substeps[1:]

def __repr__(self) -> str:
return f"Step(question={self.question}, substeps={self.substeps})"
Expand Down

0 comments on commit 91e3440

Please sign in to comment.