Initialize planner#

This code defines a function called initialize_planner which is used to initialize a planner object based on the specified input.

  • initialize_planner : The function first checks if the specified planner type (planner) and LLM type (llm) are valid by comparing them to the predefined dictionaries PLANNER_TO_CLASS and LLM_TO_CLASS respectively. If either of the types is not found in the dictionaries, a ValueError is raised.

    src.openCHA.planners.initialize_planner.initialize_planner(tasks: List[BaseTask] = None, llm: str = LLMType.OPENAI, planner: str = PlannerType.TREE_OF_THOUGHT, **kwargs: Any) BasePlanner[source]

    Initialize a planner with specified tasks, language model type, and planner type.

    Parameters:
    • tasks (List[BaseTask]) – List of tasks to be associated with the planner.

    • llm (str) – Language model type.

    • planner (str) – Planner type.

    • **kwargs (Any) – Additional keyword arguments.

    Returns:

    Initialized planner instance.

    Return type:

    BasePlanner

    Raises:

    ValueError – If the specified planner or language model type is not recognized.

    Example

    from openCHA.planners import PlannerType
    from openCHA.llms import LLMType
    from openCHA.tasks import TaskType
    planner = initialize_planner(tasks=[TaskType.SERPAPI], llm=LLMType.OPENAI, planner=PlannerType.ZERO_SHOT_REACT_PLANNER)