Skip to content

Latest commit

 

History

History
35 lines (16 loc) · 1.75 KB

README.md

File metadata and controls

35 lines (16 loc) · 1.75 KB

Ruby-ReAct-Agent 🤖

An implementation of the ReAct approach to give LLMs access to external tools in ruby

Image Generated by DALL·E 2 with the prompt: Ruby Robot using tools in the style of basquiat

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.

Example terminal session:

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.

Screenshot 2023-10-30 at 1 29 37 AM

To Run the file on mac make it an executable by running:

chmod +x ruby-re-act.sh

Create a file named .env copy over the contents of .env.example. Then replace with your OpenAI key.

touch .env && cat .env.example > .env

To execute the file type:

./ruby-re-act.sh