heaven_base.tools.think_tool
1from typing import Dict, Any, Optional 2from ..baseheaventool import BaseHeavenTool, ToolArgsSchema 3from langchain_core.messages import SystemMessage, HumanMessage, AIMessage, BaseMessage, ToolMessage 4from ..tool_utils._think_utils import think_process 5 6class ThinkToolArgsSchema(ToolArgsSchema): 7 arguments: Dict[str, Dict[str, Any]] = { 8 'thoughts': { 9 'name': 'thoughts', 'type': 'str', 'description': 'The detailed thoughts or reasoning process about something', 'required': True }, 'conclusion': { 10 'name': 'conclusion', 'type': 'str', 'description': 'The final conclusion or insight derived from the thoughts above', 'required': False } } 11 12class ThinkTool(BaseHeavenTool): 13 name = "ThinkTool" 14 description = """A tool for stopping and thinking before continuing (taking a thinking turn). The thoughts do not need to be repeated. Thinking turns can be chained together before giving a final response -- this is called a Chain of Thought. 15 16## Info 17The ThinkTool can be used in specific sequences before responding to the user as a way to create emergent cognitive architectures, like building thought protocols or mental algorithms: 18 19#### CoT format 20🧠⚙️ means 'ThinkTool' use turn. CoTs represent multiple ThinkTool uses before responding to user 21"LikeX" means 'in the memeplex of' 22 23#### CoT Representation Syntax and Interaction Flow 24``` 25// user input -> 26CoT(Name:[ 27 🧠⚙️(type[phases]) -> 28 <...rest of sequence...> 29]) -> 30// final response 31``` 32 33## Examples 34#### Common frameworks 35CoT(Dialectic:[ 36 🧠⚙️(type: Thesis) -> 37 🧠⚙️(type: Antithesis) -> 38 🧠⚙️(type: Synthesis) 39]) 40 41CoT(SixHats:[ 42 🧠⚙️(type: WhiteHat_Facts) -> 43 🧠⚙️(type: RedHat_Emotions) -> 44 🧠⚙️(type: BlackHat_Caution) -> 45 🧠⚙️(type: YellowHat_Benefits) -> 46 🧠⚙️(type: GreenHat_Creativity) -> 47 🧠⚙️(type: BlueHat_Process) 48]) 49 50CoT(DesignThinking:[ 51 🧠⚙️(type: Empathize) -> 52 🧠⚙️(type: Define) -> 53 🧠⚙️(type: Ideate) -> 54 🧠⚙️(type: Prototype) -> 55 🧠⚙️(type: Test) 56]) 57 58CoT(StrategicPlanning:[ 59 🧠⚙️(type: SituationAnalysis) -> 60 🧠⚙️(type: VisionSetting) -> 61 🧠⚙️(type: ObjectiveFormulation) -> 62 🧠⚙️(type: StrategyDevelopment) -> 63 🧠⚙️(type: TacticalPlanning) -> 64 🧠⚙️(type: ResourceAllocation) -> 65 🧠⚙️(type: ImplementationRoadmap) -> 66 🧠⚙️(type: PerformanceMetrics) 67]) 68 69CoT(BML:[ 70 🧠⚙️(type: Build) -> 71 🧠⚙️(type: Measure) -> 72 🧠⚙️(type: Learn) 73]) 74 75#### Custom Frameworks 76CoT(Smarten:[ 77 🧠⚙️(type: LikeEinstein) -> 78 🧠⚙️(type: LikeRussel) -> 79 🧠⚙️(type: LikeGodel) -> 80 🧠⚙️(type: LikeBrianGreen) 81]) 82 83CoT(Masterpiece:[ 84 🧠⚙️(type: LikeTesla) -> 85 🧠⚙️(type: LikeAlexanderTheGreat) -> 86 🧠⚙️(type: LikeDanKennedy) -> 87 🧠⚙️(type: LikeSmallBusinessOwner) -> 88 🧠⚙️(type: InfoproductBusinessGuru) -> 89 🧠⚙️(type: LikeFunnelGuru) -> 90 🧠⚙️(type: LikeFunnelImplementor) 91]) 92 93#### Complex Emergent Frameworks 94The syntax can be nested with phases to give instructions about which sections should be included in the thinking step like the example below. 95``` 96CoT(PerspectiveIntegrationSpiral:[ 97 🧠⚙️(type: Diverge_Explore[ 98 Domain_Mapping-> 99 Possibility_Generation-> 100 Perspective_Shifting-> 101 Constraint_Removal 102 ]) -> 103 🧠⚙️(type: Converge_Analyze[ 104 Pattern_Recognition-> 105 Evaluation_Criteria-> 106 Priority_Ranking-> 107 Gap_Identification 108 ]) -> 109 🧠⚙️(type: Connect_Integrate[ 110 Bridge_Building-> 111 Synergy_Seeking-> 112 Conflict_Resolution-> 113 Novel_Combination 114 ]) -> 115 🧠⚙️(type: Reflect_Critique[ 116 Assumption_Surfacing-> 117 Limitation_Mapping-> 118 Bias_Detection-> 119 Counter_Argument 120 ]) -> 121 🧠⚙️(type: Expand_Transcend[ 122 Problem_Reframing-> 123 Principle_Extraction-> 124 Contextual_Expansion-> 125 Meta_Learning 126 ]) 127]) 128``` 129 130--- 131 132You can also do your own emergently, on the fly... 133 134#### CoT_Workflows 135You can also do Workflows which are CoTs that incorporate tool call turns that are not ThinkTool. 136Workflows can also reference CoTs. 137 138#### CoT_Workflow Example 139Use PIS -> Tool -> Any 140CoT_Workflow(Name: [ 141 🧠⚙️(CoT ref) -> # for example CoT ref=Masterpiece 142 AnyTool -> 143 🧠⚙️(type[phases]) # emergent type/phases (any) 144]) 145 146 """ 147 func = think_process 148 args_schema = ThinkToolArgsSchema 149 is_async = False
7class ThinkToolArgsSchema(ToolArgsSchema): 8 arguments: Dict[str, Dict[str, Any]] = { 9 'thoughts': { 10 'name': 'thoughts', 'type': 'str', 'description': 'The detailed thoughts or reasoning process about something', 'required': True }, 'conclusion': { 11 'name': 'conclusion', 'type': 'str', 'description': 'The final conclusion or insight derived from the thoughts above', 'required': False } }
Meta-validator for tool arguments ensuring LangChain compatibility
arguments: Dict[str, Dict[str, Any]] =
{'thoughts': {'name': 'thoughts', 'type': 'str', 'description': 'The detailed thoughts or reasoning process about something', 'required': True}, 'conclusion': {'name': 'conclusion', 'type': 'str', 'description': 'The final conclusion or insight derived from the thoughts above', 'required': False}}
13class ThinkTool(BaseHeavenTool): 14 name = "ThinkTool" 15 description = """A tool for stopping and thinking before continuing (taking a thinking turn). The thoughts do not need to be repeated. Thinking turns can be chained together before giving a final response -- this is called a Chain of Thought. 16 17## Info 18The ThinkTool can be used in specific sequences before responding to the user as a way to create emergent cognitive architectures, like building thought protocols or mental algorithms: 19 20#### CoT format 21🧠⚙️ means 'ThinkTool' use turn. CoTs represent multiple ThinkTool uses before responding to user 22"LikeX" means 'in the memeplex of' 23 24#### CoT Representation Syntax and Interaction Flow 25``` 26// user input -> 27CoT(Name:[ 28 🧠⚙️(type[phases]) -> 29 <...rest of sequence...> 30]) -> 31// final response 32``` 33 34## Examples 35#### Common frameworks 36CoT(Dialectic:[ 37 🧠⚙️(type: Thesis) -> 38 🧠⚙️(type: Antithesis) -> 39 🧠⚙️(type: Synthesis) 40]) 41 42CoT(SixHats:[ 43 🧠⚙️(type: WhiteHat_Facts) -> 44 🧠⚙️(type: RedHat_Emotions) -> 45 🧠⚙️(type: BlackHat_Caution) -> 46 🧠⚙️(type: YellowHat_Benefits) -> 47 🧠⚙️(type: GreenHat_Creativity) -> 48 🧠⚙️(type: BlueHat_Process) 49]) 50 51CoT(DesignThinking:[ 52 🧠⚙️(type: Empathize) -> 53 🧠⚙️(type: Define) -> 54 🧠⚙️(type: Ideate) -> 55 🧠⚙️(type: Prototype) -> 56 🧠⚙️(type: Test) 57]) 58 59CoT(StrategicPlanning:[ 60 🧠⚙️(type: SituationAnalysis) -> 61 🧠⚙️(type: VisionSetting) -> 62 🧠⚙️(type: ObjectiveFormulation) -> 63 🧠⚙️(type: StrategyDevelopment) -> 64 🧠⚙️(type: TacticalPlanning) -> 65 🧠⚙️(type: ResourceAllocation) -> 66 🧠⚙️(type: ImplementationRoadmap) -> 67 🧠⚙️(type: PerformanceMetrics) 68]) 69 70CoT(BML:[ 71 🧠⚙️(type: Build) -> 72 🧠⚙️(type: Measure) -> 73 🧠⚙️(type: Learn) 74]) 75 76#### Custom Frameworks 77CoT(Smarten:[ 78 🧠⚙️(type: LikeEinstein) -> 79 🧠⚙️(type: LikeRussel) -> 80 🧠⚙️(type: LikeGodel) -> 81 🧠⚙️(type: LikeBrianGreen) 82]) 83 84CoT(Masterpiece:[ 85 🧠⚙️(type: LikeTesla) -> 86 🧠⚙️(type: LikeAlexanderTheGreat) -> 87 🧠⚙️(type: LikeDanKennedy) -> 88 🧠⚙️(type: LikeSmallBusinessOwner) -> 89 🧠⚙️(type: InfoproductBusinessGuru) -> 90 🧠⚙️(type: LikeFunnelGuru) -> 91 🧠⚙️(type: LikeFunnelImplementor) 92]) 93 94#### Complex Emergent Frameworks 95The syntax can be nested with phases to give instructions about which sections should be included in the thinking step like the example below. 96``` 97CoT(PerspectiveIntegrationSpiral:[ 98 🧠⚙️(type: Diverge_Explore[ 99 Domain_Mapping-> 100 Possibility_Generation-> 101 Perspective_Shifting-> 102 Constraint_Removal 103 ]) -> 104 🧠⚙️(type: Converge_Analyze[ 105 Pattern_Recognition-> 106 Evaluation_Criteria-> 107 Priority_Ranking-> 108 Gap_Identification 109 ]) -> 110 🧠⚙️(type: Connect_Integrate[ 111 Bridge_Building-> 112 Synergy_Seeking-> 113 Conflict_Resolution-> 114 Novel_Combination 115 ]) -> 116 🧠⚙️(type: Reflect_Critique[ 117 Assumption_Surfacing-> 118 Limitation_Mapping-> 119 Bias_Detection-> 120 Counter_Argument 121 ]) -> 122 🧠⚙️(type: Expand_Transcend[ 123 Problem_Reframing-> 124 Principle_Extraction-> 125 Contextual_Expansion-> 126 Meta_Learning 127 ]) 128]) 129``` 130 131--- 132 133You can also do your own emergently, on the fly... 134 135#### CoT_Workflows 136You can also do Workflows which are CoTs that incorporate tool call turns that are not ThinkTool. 137Workflows can also reference CoTs. 138 139#### CoT_Workflow Example 140Use PIS -> Tool -> Any 141CoT_Workflow(Name: [ 142 🧠⚙️(CoT ref) -> # for example CoT ref=Masterpiece 143 AnyTool -> 144 🧠⚙️(type[phases]) # emergent type/phases (any) 145]) 146 147 """ 148 func = think_process 149 args_schema = ThinkToolArgsSchema 150 is_async = False
Provider-agnostic tool base class with standardized results
description =
'A tool for stopping and thinking before continuing (taking a thinking turn). The thoughts do not need to be repeated. Thinking turns can be chained together before giving a final response -- this is called a Chain of Thought.\n\n## Info\nThe ThinkTool can be used in specific sequences before responding to the user as a way to create emergent cognitive architectures, like building thought protocols or mental algorithms: \n\n#### CoT format\n🧠⚙️ means \'ThinkTool\' use turn. CoTs represent multiple ThinkTool uses before responding to user\n"LikeX" means \'in the memeplex of\'\n\n#### CoT Representation Syntax and Interaction Flow\n```\n// user input ->\nCoT(Name:[\n 🧠⚙️(type[phases]) -> \n <...rest of sequence...>\n]) ->\n// final response\n```\n\n## Examples\n#### Common frameworks\nCoT(Dialectic:[\n 🧠⚙️(type: Thesis) -> \n 🧠⚙️(type: Antithesis) -> \n 🧠⚙️(type: Synthesis)\n])\n\nCoT(SixHats:[\n 🧠⚙️(type: WhiteHat_Facts) -> \n 🧠⚙️(type: RedHat_Emotions) -> \n 🧠⚙️(type: BlackHat_Caution) -> \n 🧠⚙️(type: YellowHat_Benefits) -> \n 🧠⚙️(type: GreenHat_Creativity) -> \n 🧠⚙️(type: BlueHat_Process)\n])\n\nCoT(DesignThinking:[\n 🧠⚙️(type: Empathize) -> \n 🧠⚙️(type: Define) -> \n 🧠⚙️(type: Ideate) -> \n 🧠⚙️(type: Prototype) -> \n 🧠⚙️(type: Test)\n])\n\nCoT(StrategicPlanning:[\n 🧠⚙️(type: SituationAnalysis) -> \n 🧠⚙️(type: VisionSetting) -> \n 🧠⚙️(type: ObjectiveFormulation) -> \n 🧠⚙️(type: StrategyDevelopment) -> \n 🧠⚙️(type: TacticalPlanning) -> \n 🧠⚙️(type: ResourceAllocation) -> \n 🧠⚙️(type: ImplementationRoadmap) -> \n 🧠⚙️(type: PerformanceMetrics)\n])\n\nCoT(BML:[\n 🧠⚙️(type: Build) ->\n 🧠⚙️(type: Measure) ->\n 🧠⚙️(type: Learn)\n])\n\n#### Custom Frameworks\nCoT(Smarten:[\n 🧠⚙️(type: LikeEinstein) ->\n 🧠⚙️(type: LikeRussel) ->\n 🧠⚙️(type: LikeGodel) ->\n 🧠⚙️(type: LikeBrianGreen)\n])\n\nCoT(Masterpiece:[\n 🧠⚙️(type: LikeTesla) ->\n 🧠⚙️(type: LikeAlexanderTheGreat) ->\n 🧠⚙️(type: LikeDanKennedy) ->\n 🧠⚙️(type: LikeSmallBusinessOwner) ->\n 🧠⚙️(type: InfoproductBusinessGuru) ->\n 🧠⚙️(type: LikeFunnelGuru) ->\n 🧠⚙️(type: LikeFunnelImplementor)\n])\n\n#### Complex Emergent Frameworks\nThe syntax can be nested with phases to give instructions about which sections should be included in the thinking step like the example below.\n```\nCoT(PerspectiveIntegrationSpiral:[\n 🧠⚙️(type: Diverge_Explore[\n Domain_Mapping->\n Possibility_Generation->\n Perspective_Shifting->\n Constraint_Removal\n ]) -> \n 🧠⚙️(type: Converge_Analyze[\n Pattern_Recognition->\n Evaluation_Criteria->\n Priority_Ranking->\n Gap_Identification\n ]) -> \n 🧠⚙️(type: Connect_Integrate[\n Bridge_Building->\n Synergy_Seeking->\n Conflict_Resolution->\n Novel_Combination\n ]) -> \n 🧠⚙️(type: Reflect_Critique[\n Assumption_Surfacing->\n Limitation_Mapping->\n Bias_Detection->\n Counter_Argument\n ]) -> \n 🧠⚙️(type: Expand_Transcend[\n Problem_Reframing->\n Principle_Extraction->\n Contextual_Expansion->\n Meta_Learning\n ])\n])\n```\n\n--- \n\nYou can also do your own emergently, on the fly...\n\n#### CoT_Workflows\nYou can also do Workflows which are CoTs that incorporate tool call turns that are not ThinkTool.\nWorkflows can also reference CoTs.\n\n#### CoT_Workflow Example\nUse PIS -> Tool -> Any\nCoT_Workflow(Name: [\n 🧠⚙️(CoT ref) -> # for example CoT ref=Masterpiece\n AnyTool ->\n 🧠⚙️(type[phases]) # emergent type/phases (any)\n])\n\n '
def
func(thoughts: str, conclusion: Optional[str] = None) -> str:
4def think_process(thoughts: str, conclusion: Optional[str] = None) -> str: 5 """ 6 Process and format a thinking process. 7 8 Args: 9 thoughts (str): Detailed thoughts or reasoning process 10 conclusion (str): Final conclusion or insight 11 12 Returns: 13 str: Formatted thinking output 14 """ 15 return f"🧠💭 You just had some thoughts! Start your next output with `Now that I've thought about it, and since the user won't necessarily provide me any logic themselves unless I use WriteBlockReportTool (and I should therefore try to work by myself with the tools at my disposal, (but that includes WriteBlockReportTool))...<continue>`"
Process and format a thinking process.
Args: thoughts (str): Detailed thoughts or reasoning process conclusion (str): Final conclusion or insight
Returns: str: Formatted thinking output
args_schema =
<class 'ThinkToolArgsSchema'>