| 12 | class DFS_tree_search(base_search_method): |
| 13 | |
| 14 | def __init__(self, llm, io_func, process_id=0, callbacks=None): |
| 15 | super(DFS_tree_search, self).__init__( |
| 16 | llm, io_func, process_id, callbacks) |
| 17 | """Depth-first search. |
| 18 | with_filter=True: Every time a child node is generated, choose the best multiple iterations to go. |
| 19 | with_filter=False: Do as Preorder traversal. |
| 20 | """ |
| 21 | self.io_func = io_func |
| 22 | self.llm = llm |
| 23 | self.process_id = process_id |
| 24 | self.restart() |
| 25 | |
| 26 | self.callbacks = callbacks if callbacks is not None else [] |
| 27 | |
| 28 | def restart(self): |
| 29 | self.status = 0 |