MCPcopy Create free account
hub / github.com/OpenBMB/ToolBench / start

Method start

toolbench/inference/Algorithms/DFS.py:94–118  ·  view source on GitHub ↗

single_chain_max_step: The maximum depth of the tree tree_beam_size: How many children nodes for one node are generated per layer answer = n means the Algo exits when find n "give_answer" nodes max_query_count: the Algo exits when OpenAI-query exists this value

(self, single_chain_max_step, tree_beam_size, max_query_count, answer=1, with_filter=True)

Source from the content-addressed store, hash-verified

92 return json_obj
93
94 def start(self, single_chain_max_step, tree_beam_size, max_query_count, answer=1, with_filter=True):
95 """ single_chain_max_step: The maximum depth of the tree
96 tree_beam_size: How many children nodes for one node are generated per layer
97 answer = n means the Algo exits when find n "give_answer" nodes
98 max_query_count: the Algo exits when OpenAI-query exists this value
99 with_filter: This is the difference between normal DFS(with_filter=True) and DFSDT(with_filter=False).
100 """
101 self.forward_args = locals()
102 if "self" in self.forward_args.keys():
103 self.forward_args.pop("self")
104 self.tree = my_tree()
105 self.tree.root.node_type = "Action Input"
106 self.tree.root.io_state = deepcopy(self.io_func)
107
108 system = FORMAT_INSTRUCTIONS_SYSTEM_FUNCTION
109 system = system.replace("{task_description}",
110 self.io_func.task_description)
111 self.tree.root.messages.append({"role": "system", "content": system})
112
113 user = FORMAT_INSTRUCTIONS_USER_FUNCTION
114 user = user.replace("{input_description}",
115 self.io_func.input_description)
116 self.tree.root.messages.append({"role": "user", "content": user})
117
118 return self.DFS(self.tree.root, single_chain_max_step, tree_beam_size, max_query_count, answer, with_filter)
119
120 def DFS(self, now_node, single_chain_max_step, tree_beam_size, max_query_count, answer, with_filter=True):
121 """Returns the number of grids to go back. When a child node of a node generates a final answer or give up, it should go back a few more grids

Callers 1

method_converterMethod · 0.95

Calls 2

DFSMethod · 0.95
my_treeClass · 0.90

Tested by

no test coverage detected