(self, use_messages=False)
| 208 | return now_str |
| 209 | |
| 210 | def to_json(self, use_messages=False): |
| 211 | |
| 212 | json_obj = {} |
| 213 | json_obj["is_terminal"] = False |
| 214 | json_obj["pruned"] = self.pruned |
| 215 | json_obj["finished"] = self.finished |
| 216 | |
| 217 | json_obj["depth"] = self.get_depth() |
| 218 | json_obj["node_type"] = self.node_type |
| 219 | json_obj["description"] = self.description |
| 220 | json_obj["Elo"] = self.Elo |
| 221 | if self.observation != "": |
| 222 | json_obj["observation"] = self.observation |
| 223 | if self.observation_code != None: |
| 224 | json_obj["observation_code"] = self.observation_code |
| 225 | json_obj["child_count"] = len(self.children) |
| 226 | json_obj["expand_num"] = self.expand_num |
| 227 | |
| 228 | if self.io_state != None and self.node_type == "Action Input": |
| 229 | json_obj["io_state"] = self.io_state.to_json() |
| 230 | |
| 231 | |
| 232 | if use_messages: |
| 233 | json_obj["messages"] = [] |
| 234 | for message in self.messages: |
| 235 | if not ("valid" in message.keys() and message["valid"] == False): |
| 236 | json_obj["messages"].append(message["role"]) |
| 237 | else: |
| 238 | json_obj["messages"].append(message["role"] + "_invalid") |
| 239 | |
| 240 | return json_obj |
no test coverage detected