| 86 | child.prune() |
| 87 | |
| 88 | def print(self,process_id = 0): |
| 89 | if process_id != 0: |
| 90 | return |
| 91 | color_converter = {"Thought":"red", "Action": "blue", "Action Input": "cyan","Final Answer": "green","Reflection":"blue"} |
| 92 | print(colored(f"{self.node_type}: {self.description}",color = color_converter[self.node_type])) |
| 93 | if self.observation != "": |
| 94 | if len(self.observation) < 1536: |
| 95 | print(colored(f"Observation: {self.observation}",color="yellow")) |
| 96 | else: |
| 97 | print(colored(f"Observation: {self.observation[:1536]}......(len={len(self.observation)})",color="yellow")) |
| 98 | |
| 99 | |
| 100 | @classmethod |