Planner Tree of Though Implementation#
In this tutorial, we elaborate on the implementation of the Tree of Thought prompting technique. We will describe how available tasks are introduced to the Tree of Thought, the process of curating and generating the planning prompt, and ultimately, how the final planning results are transformed into executable tasks by the Task Executor.
Task Planner and Planning Techniques#
The core component of the Task Planner is the selection of an appropriate planning technique. Among various techniques using large language models (LLMs) that have proven practical, we opted for the Tree of Thought approach.
Implementation Phases#
To effectively implement the Tree of Thought, we structured the planning process into two main sections:
Preparation of the Planning Prompt: Initially, we prepare a comprehensive prompt that includes a list of available tasks, relevant metadata, records of previously performed tasks, conversation history, and user input. This setup ensures the planner is thoroughly informed about the tasks it can call upon, the metadata that should be used or passed along, and the context of past interactions to prevent redundant planning and maintain the continuity of conversations.
Execution of the Chosen Strategy: In the second stage of the planning process, our objective is to translate the chosen decision into sequences of task functions that the Orchestrator can understand and execute. Within the Orchestrator, we have implemented a function named execute_task, which serves as an interface to retrieve and execute tasks with the appropriate inputs accurately.
Each strategy is designed to collect the necessary information to address the query efficiently. It is then asked to provide the pros and cons of each strategy, ultimately selecting the most suitable one as the final decision.