Skip to main content

LangChain-based library with planning algorithms for AI Agents.

Project description

🤖✨ Planning Library

Library with planning algorithms for AI Agents built with LangChain and LangGraph.

Installation

As a package

  • For Poetry:

    poetry add planning-library
    
  • For pip:

    pip install planning-library
    

For development

Step 0: Install prerequisites

In general, the only prerequisite is :snake: 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 code quality checks 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). :construction: 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). :construction: 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 :scroll: ToT, :scroll: DFSDT
Reflexion ReflexionStrategy LangGraph :scroll:
ADaPT ADaPTStrategy Custom :scroll:
Simple/ReAct SimpleStrategy Custom :scroll:

Available Environments

:two::four: 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 :scroll: 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.

:snowflake: 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.

:house: ALFWorld

ALFWorld contains interactive TextWorld environments for household navigation. See :scroll: ALFWorld paper or project website for more information.

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

Strategies usage examples

Examples are available under examples folder.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

planning_library-0.1.4.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

planning_library-0.1.4-py3-none-any.whl (50.8 kB view details)

Uploaded Python 3

File details

Details for the file planning_library-0.1.4.tar.gz.

File metadata

  • Download URL: planning_library-0.1.4.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.19 Linux/6.5.0-1023-azure

File hashes

Hashes for planning_library-0.1.4.tar.gz
Algorithm Hash digest
SHA256 de82ab0d8c33928f0d2011f17c84feebfa5f0ba3befa5a9932c95132e79f6dd7
MD5 b087b98c58b97c7913813070009b68a9
BLAKE2b-256 829e253b1de5f8c66216ebe87fc5ff7cadc464996f6b737a9b6092971109e87d

See more details on using hashes here.

File details

Details for the file planning_library-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: planning_library-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 50.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.19 Linux/6.5.0-1023-azure

File hashes

Hashes for planning_library-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d821d7721b285e49c392db992e1e55a90b8943d9ca6e415b78c2969597af7bd5
MD5 0bb532459318e5c4584b7b34b03dbb27
BLAKE2b-256 82d2a37c30d2b16819da1cf555ab91d12f6ec8d4a7a9cff5180bb1bdf0fe79d1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page