Skip to content

JetBrains-Research/planning-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€–πŸ“ Planning Library

Installation

As a package

Currently, only installation from source is supported.

  • For Poetry:

    poetry add git+https://github.com/JetBrains-Research/planning-library.git
  • For pip:

    pip install git+https://github.com/JetBrains-Research/planning-library.git

For development

Step 0: Install prerequisites

In general, the only prerequisite is 🐍 Python. However, note the TextWorld requirements if you run into any issues.

You can use pyenv to set the specific Python version.

Step 2: Clone repository

git clone git@github.com:JetBrains-Research/planning-library.git

Step 3: Install Python dependencies

  • For Poetry: run poetry install.
    • Note. If you do not need to run CI or to run examples, you can exclude the corresponding dependencies groups: poetry install --without dev,examples

Quick Tour

Currently, we have two types of strategies: custom strategies and LangGraph strategies.

Custom strategies

Custom strategies follow the interface provided by BaseCustomStrategy.

Example: Tree of Thoughts + DFS

Initializing strategy

Each custom strategy can be created by invoking a static method create with at least agent and tools.

from planning_library.strategies import TreeOfThoughtsDFSStrategy

agent = ...  # any runnable that follows either RunnableAgent or RunnableMultiActionAgent
tools = [...]  # any sequence of tools
strategy_executor = TreeOfThoughtsDFSStrategy.create(
    agent=agent,
    tools=tools,
)

Some strategies contain other meaningful components (e.g., an evaluator, which is responsible for evaluating intermediate steps). 🚧 We will provide some default implementations for such components, but they can also be redefined with custom runnables tailored for specific tasks.

Using strategy

Each custom strategy is an instance of Chain and mostly can be used the same way as the default AgentExecutor from LangChain.

strategy_executor.invoke({"inputs": "Hello World"})

LangGraph strategies

Strategies powered by LangGraph library follow the interface provided by BaseLangGraphStrategy.

Example: Reflexion

Initializing strategy

Each LangGraph strategy can be created by invoking a static method create with (at least) agent and tools.

from planning_library.strategies import ReflexionStrategy

agent = ...  # any runnable that follows either RunnableAgent or RunnableMultiActionAgent
tools = [...]  # any sequence of tools
strategy_graph = ReflexionStrategy.create(agent=agent, tools=tools)

Some strategies contain other meaningful components (e.g., an evaluator, which is responsible for evaluating intermediate steps). 🚧 We will provide some default implementations for such components, but they can also be redefined with custom runnables tailored for specific tasks.

Using strategy

BaseLangGraphStrategy.create returns a compiled StateGraph that exposes the same interface as any LangChain runnable.

strategy_graph.invoke({"inputs": "Hello World"})

Available Strategies

Name Implementation Type Paper
Tree of Thoughts + DFS / DFSDT TreeOfThoughtsDFSStrategy Custom πŸ“œ ToT, πŸ“œ DFSDT
Reflexion ReflexionStrategy LangGraph πŸ“œ
ADaPT ADaPTStrategy Custom πŸ“œ
Simple/ReAct SimpleStrategy Custom πŸ“œ

Available Environments

2️⃣4️⃣ Game of 24

Game of 24 is a mathematical reasoning task. The goal is to reach the number 24 by applying arithmetical operations to four given numbers. See πŸ“œ Tree of Thoughts paper for more details.

Our implementation of Game of 24 is available under environments/game_of_24 folder. It includes a set of prompts, a set of tools and examples of running available strategies on Game of 24.

❄️ FrozenLake

FrozenLake is a simple environment that requires crossing a frozen lake from start to goal without falling into any holes. See Gymnasium docs for more details.

Our implementation of FrozenLake is available under environments/frozen_lake folder.

🏠 ALFWorld

ALFWorld contains interactive TextWorld environments for household navigation. See πŸ“œ ALFWorld paper or project website for more information.

Our implementation of ALFWorld is available under environments/alfword folder.

About

🌟 library with planning algorithms for AI Agents

Resources

License

Stars

Watchers

Forks