This is an implementation of the ReAct Pattern described in the paper ReAct: Synergizing Reasoning and Acting in Language Models in Ruby as a learning exercise.
To aide me in this project I closely followed and essentially ported over some python code written by Simon Willison in his article Python ReAct Pattern
Hope this sample code benefits someone in their own exploration of AI Agents in Ruby.
Currently the only tool implemented is a calculator.
The noteworthy aspect here is that the LLM isn't dependent on the data it was trained on. Instead, it calls a method in the code. This method serves as a versatile tool. You have the flexibility to define other tools, such as the capability to search websites like Wikipedia or make API calls, rather than having the LLM rely solely on its training data.
chmod +x ruby-re-act.sh
touch .env && cat .env.example > .env
./ruby-re-act.sh