⛓️➕ Beyond Chaining: Enabling LLM Agents to Plan

In my last post we talked about OpenAI’s new function calling capability, and our ability to define trees recursively. This opens up an intriguing possibility: could we teach our AI agents to plan by calling a ‘function’ and produces an entire graph? Let's dive deeper.

If you want to just look at the code you can check it out here

Tackling Challenges in AI Planning

As mentioned in my previous post, using recursive schemas in Pydantic and OpenAI enables us to create finite computation Directed Acyclic Graphs (DAGs). However, this approach presented a set of challenges that necessitated some key alterations.

Streamlining AI Planning

1) Saying Goodbye to Recursion

Contrary to expectations, performance was significantly improved by eliminating recursion and adopting a flat structure with dependency lists and IDs.

2) Embracing Chain of Thought (CoT)

As queries became increasingly complex, CoT emerged as a beneficial tool. Notably, combining GPT-4's one-shot capabilities with a cheaper GPT-3.5 function call proved to be an effective strategy. For a more detailed understanding, check the complete script example here.

From Planning to Action: Executing with Pydantic

Pydantic offers more than just data validation. In fact, it can carry out computations tied to data objects. We can now not only represent the plan but also execute it, further extending the capabilities of our AI agents.

Bringing it all Together: Towards More Capable AI Agents

While this computational example may seem simple, the goal is to provide a framework-agnostic approach to exploring agent planning for complex tasks while also considering parallel execution.

The Future of AI Planning

We've just scratched the surface of what's possible when we enable AI agents to plan. Collaboration and innovative thinking will be crucial as we continue to push the boundaries of AI.