(2023-03-17) Willison A Simple Python Implementation Of The React Pattern For Llms

Simon Willison: A simple Python implementation of the ReAct pattern for LLMs. A popular nightmare scenario for AI is giving it access to tools, so it can make API calls and execute its own code and generally break free of the constraints of its initial environment. Let's do that now!

The ReAct pattern (for Reason+Act) is described in this paper.

Matt Webb wrote a great piece about that here: The surprising ease and effectiveness of AI in a loop. (2023-03-16-WebbTheSurprisingEaseAndEffectivenessOfAiInALoop)

Matt used langchain for his implementation. I decided to try building it from scratch on top of my tiny Python wrapper for the ChatGPT API.

Some examples

Here are some (very cherry-picked) examples of my query() function running, showing the underlying deliberations of the LLM:

What does England share borders with?

Has Simon been to Madagascar?

Fifteen * twenty five

This is not a very robust implementation at all - there's a ton of room for improvement. But I love how simple it is - it really does just take a few dozen lines of Python to make these extra capabilities available to the LLM and have it start to use them.


Edited:    |       |    Search Twitter for discussion