Class: LLM::Tool
- Inherits:
-
Struct
- Object
- Struct
- LLM::Tool
- Defined in:
- lib/llm/tool.rb
Overview
The LLM::Tool class represents a platform-native tool that can be activated by an LLM provider. Unlike LLM::Function, these tools are pre-defined by the provider and their capabilities are already known to the underlying LLM.
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#provider ⇒ Object
Returns the value of attribute provider.
Instance Method Summary collapse
-
#to_json ⇒ String
-
#to_h ⇒ Hash
(also: #to_hash)
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
15 16 17 |
# File 'lib/llm/tool.rb', line 15 def name @name end |
#options ⇒ Object
Returns the value of attribute options
15 16 17 |
# File 'lib/llm/tool.rb', line 15 def @options end |
#provider ⇒ Object
Returns the value of attribute provider
15 16 17 |
# File 'lib/llm/tool.rb', line 15 def provider @provider end |
Instance Method Details
#to_json ⇒ String
18 19 20 |
# File 'lib/llm/tool.rb', line 18 def to_json(...) to_h.to_json(...) end |
#to_h ⇒ Hash Also known as: to_hash
24 25 26 27 28 29 30 |
# File 'lib/llm/tool.rb', line 24 def to_h case provider.class.to_s when "LLM::Anthropic" then .merge("name" => name.to_s) when "LLM::Gemini" then {name => } else .merge("type" => name.to_s) end end |