Class: LittleGhost::ModelCapabilities
- Inherits:
-
Data
- Object
- Data
- LittleGhost::ModelCapabilities
- Defined in:
- lib/little_ghost/model_capabilities.rb,
lib/little_ghost/model_capabilities.rb
Overview
Describes the optional features a model can use. Providers expose this value
so structured results and tool selection do not rely on provider guesswork.
A nil supported-parameter list means support is unrestricted.
Instance Attribute Summary collapse
-
#known ⇒ Object
readonly
Returns the value of attribute known.
-
#native_structured_output ⇒ Object
readonly
Returns the value of attribute native_structured_output.
-
#supported_parameters ⇒ Object
readonly
Returns the value of attribute supported_parameters.
-
#tool_choice ⇒ Object
readonly
Returns the value of attribute tool_choice.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
Class Method Summary collapse
-
.legacy ⇒ Object
Supplies the backwards-compatible capability set for legacy providers.
-
.unknown ⇒ Object
Marks capability support as unknown.
Instance Method Summary collapse
-
#initialize(native_structured_output: false, tools: false, tool_choice: false, supported_parameters: nil, known: true) ⇒ ModelCapabilities
constructor
Creates an immutable capability description.
- #known? ⇒ Boolean
- #native_structured_output? ⇒ Boolean
-
#supports_parameter?(*names) ⇒ Boolean
Checks whether any supplied parameter name is supported.
- #tool_choice? ⇒ Boolean
- #tools? ⇒ Boolean
Constructor Details
#initialize(native_structured_output: false, tools: false, tool_choice: false, supported_parameters: nil, known: true) ⇒ ModelCapabilities
Creates an immutable capability description.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/little_ghost/model_capabilities.rb', line 19 def initialize( native_structured_output: false, tools: false, tool_choice: false, supported_parameters: nil, known: true ) parameters = supported_parameters&.map(&:to_s)&.uniq&.freeze super( native_structured_output: !!native_structured_output, tools: !!tools, tool_choice: !!tool_choice, supported_parameters: parameters, known: !!known ) end |
Instance Attribute Details
#known ⇒ Object (readonly)
Returns the value of attribute known
11 12 13 |
# File 'lib/little_ghost/model_capabilities.rb', line 11 def known @known end |
#native_structured_output ⇒ Object (readonly)
Returns the value of attribute native_structured_output
11 12 13 |
# File 'lib/little_ghost/model_capabilities.rb', line 11 def native_structured_output @native_structured_output end |
#supported_parameters ⇒ Object (readonly)
Returns the value of attribute supported_parameters
11 12 13 |
# File 'lib/little_ghost/model_capabilities.rb', line 11 def supported_parameters @supported_parameters end |
#tool_choice ⇒ Object (readonly)
Returns the value of attribute tool_choice
11 12 13 |
# File 'lib/little_ghost/model_capabilities.rb', line 11 def tool_choice @tool_choice end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools
11 12 13 |
# File 'lib/little_ghost/model_capabilities.rb', line 11 def tools @tools end |
Class Method Details
.legacy ⇒ Object
Supplies the backwards-compatible capability set for legacy providers.
49 50 51 |
# File 'lib/little_ghost/model_capabilities.rb', line 49 def self.legacy new(native_structured_output: true, tools: true, tool_choice: true) end |
.unknown ⇒ Object
Marks capability support as unknown.
54 55 56 |
# File 'lib/little_ghost/model_capabilities.rb', line 54 def self.unknown new(known: false) end |
Instance Method Details
#known? ⇒ Boolean
39 |
# File 'lib/little_ghost/model_capabilities.rb', line 39 def known? = known |
#native_structured_output? ⇒ Boolean
36 |
# File 'lib/little_ghost/model_capabilities.rb', line 36 def native_structured_output? = native_structured_output |
#supports_parameter?(*names) ⇒ Boolean
Checks whether any supplied parameter name is supported.
42 43 44 45 46 |
# File 'lib/little_ghost/model_capabilities.rb', line 42 def supports_parameter?(*names) return true unless supported_parameters names.flatten.any? { |name| supported_parameters.include?(name.to_s) } end |
#tool_choice? ⇒ Boolean
38 |
# File 'lib/little_ghost/model_capabilities.rb', line 38 def tool_choice? = tool_choice |
#tools? ⇒ Boolean
37 |
# File 'lib/little_ghost/model_capabilities.rb', line 37 def tools? = tools |