-
Notifications
You must be signed in to change notification settings - Fork 39
BoxCar Calculator
Tabrez Syed edited this page Feb 22, 2023
·
1 revision
- LLMs are not great at doing math. Using this BoxCar asks the LLM to use Ruby code to evaluate the math.
- Use this BoxCar when you need to perform mathematical calculations.
# run the calculator
engine = Boxcars::Openai.new(max_tokens: 256)
calc = Boxcars::Calculator.new(engine: engine)
puts calc.run "what is pi to the fourth power divided by 22.1?"
Produces:
> Entering Calculator#run
what is pi to the forth power divided by 22.1?
RubyREPL: puts(Math::PI**4 / 22.1)
Answer: 4.407651178009159
4.407651178009159
< Exiting Calculator#run
4.407651178009159
Note that since Openai is currently the most used Engine, if you do not pass in an engine, it will default as expected. So, this is the equialent shorter version of the above script:
# run the calculator
calc = Boxcars::Calculator.new # just use the default Engine
puts calc.run "what is pi to the forth power divided by 22.1?"