Skip to content

thedayisntgray/Ruby-ReAct-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages