Description
Hello! Thank you for the gem!
I'm exploring this gem by rewriting a small llm agent in a Rails app. And I got to a point where I'm rewriting tools.
In original implementation I'm using an enum parameter. And I do not know how to implement it here.
So far I have squished it into a description:
"The current unit of the temperature value. Must be one of: 'celsius', 'fahrenheit'."
While looking for an solution I found this example: https://rubyllm.com/guides/tools#advanced-tool-parameters
class DataAnalysis < RubyLLM::Tool
description "Analyzes numerical data"
param :data,
type: :array,
desc: "Array of numbers to analyze"
param :operations,
type: :object,
desc: "Analysis operations to perform",
required: false
def execute(data:, operations: {mean: true, median: false})
result = {}
result[:mean] = data.sum.to_f / data.size if operations[:mean]
result[:median] = calculate_median(data) if operations[:median]
result
end
(...)
end
I do not understand how llm would know that operations cloud be mean
and median
, and that it should be a hash at all. I'm discussing it with an LLM (ironic, isn't it?) , and it says the example would not work.
To make it work the description should be much more specific:
"Specifies which analysis to perform. Should be an object with optional boolean keys: 'mean' and 'median'. For example: {'mean': true, 'median': false}. If omitted, both mean and median might be calculated."
.
I saw the issue #11 about Structured output and I think structured input would be nice to have too.
What do you think about including this?
I have no ideas on implementation or API for these yet, but I can try working on it.