Class: CircuitBreaker::Executors::LLM::CalculatorTool
- Defined in:
- lib/circuit_breaker/executors/llm/tools.rb
Instance Attribute Summary
Attributes inherited from Tool
#description, #name, #parameters
Instance Method Summary collapse
- #execute(expression:) ⇒ Object
-
#initialize ⇒ CalculatorTool
constructor
A new instance of CalculatorTool.
Methods inherited from Tool
Constructor Details
#initialize ⇒ CalculatorTool
Returns a new instance of CalculatorTool.
75 76 77 78 79 80 81 82 83 |
# File 'lib/circuit_breaker/executors/llm/tools.rb', line 75 def initialize super( name: 'calculator', description: 'Perform mathematical calculations', parameters: { expression: { type: 'string', description: 'The mathematical expression to evaluate' } } ) end |
Instance Method Details
#execute(expression:) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/circuit_breaker/executors/llm/tools.rb', line 85 def execute(expression:) # Implement safe evaluation logic here { result: eval(expression).to_s } rescue => e { error: e. } end |