Skip to content

Commit

Permalink
misc: small fix or general refactoring i did not bother commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Feb 4, 2025
1 parent 5e47c08 commit 32d9b0b
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions examples/ab_problem/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@ def get_solution(message):


if __name__ == "__main__":
"""
program = "#A #B #A #A #B A# #B #A #A #A B# B#".strip().split(" ")
actual, _ = solve(program)
print(program)
print(actual)
exit()
"""
raw = sys.stdin.read()
state = json.loads(raw)

Expand All @@ -98,21 +91,19 @@ def get_solution(message):

# find the most recent solution in the chat history
for message in reversed(state["chat"]["history"]["conversation"]):
try:
solution = get_solution(message)
if solution is not None:
if actual == solution:
exit(42)
elif any(token not in TOKENS for token in solution):
print(
"Invalid solution, provide a single string of tokens separated by spaceswith the solution"
)
else:
print("Solution is incorrect")
break
except Exception as e:
print(message)
raise e
solution = get_solution(message)
if solution is not None:
if actual == solution:
# exit code 42 is a special exit code that indicates the solution is correct
exit(42)
elif any(token not in TOKENS for token in solution):
# anything that goes to stdout will be added to the chat history, as feedback to the model
print(
"Invalid solution, provide a single string of tokens separated by spaceswith the solution"
)
else:
print("Solution is incorrect")
break

if solution is None:
print("No solution provided")

0 comments on commit 32d9b0b

Please sign in to comment.