Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thedayisntgray/ruby-react-agent
An implementation of the ReAct approach to give LLMs access to external tools
https://github.com/thedayisntgray/ruby-react-agent
Last synced: about 1 month ago
JSON representation
An implementation of the ReAct approach to give LLMs access to external tools
- Host: GitHub
- URL: https://github.com/thedayisntgray/ruby-react-agent
- Owner: thedayisntgray
- Created: 2023-10-30T03:06:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-30T11:19:59.000Z (about 1 year ago)
- Last Synced: 2024-11-29T03:24:52.052Z (about 1 month ago)
- Language: Ruby
- Size: 9.77 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ruby-ReAct-Agent π€
### An implementation of the ReAct approach to give LLMs access to external tools in rubyThis is an implementation of the ReAct Pattern described in the paper [ReAct: Synergizing Reasoning and Acting in Language Models](https://arxiv.org/abs/2210.03629) 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](https://twitter.com/simonw) in his article [Python ReAct Pattern](https://til.simonwillison.net/llms/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.
#### 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```