Class: LittleGhost::ModelCapabilities

Inherits:
Data
  • Object
show all
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 the list itself is unrestricted. Check known? before treating that as known provider support.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(native_structured_output: false, tools: false, tool_choice: false, supported_parameters: nil, known: true) ⇒ ModelCapabilities

Creates an immutable capability description.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/little_ghost/model_capabilities.rb', line 20

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

#knownObject (readonly)

Returns the value of attribute known

Returns:

  • (Object)

    the current value of known



12
13
14
# File 'lib/little_ghost/model_capabilities.rb', line 12

def known
  @known
end

#native_structured_outputObject (readonly)

Returns the value of attribute native_structured_output

Returns:

  • (Object)

    the current value of native_structured_output



12
13
14
# File 'lib/little_ghost/model_capabilities.rb', line 12

def native_structured_output
  @native_structured_output
end

#supported_parametersObject (readonly)

Returns the value of attribute supported_parameters

Returns:

  • (Object)

    the current value of supported_parameters



12
13
14
# File 'lib/little_ghost/model_capabilities.rb', line 12

def supported_parameters
  @supported_parameters
end

#tool_choiceObject (readonly)

Returns the value of attribute tool_choice

Returns:

  • (Object)

    the current value of tool_choice



12
13
14
# File 'lib/little_ghost/model_capabilities.rb', line 12

def tool_choice
  @tool_choice
end

#toolsObject (readonly)

Returns the value of attribute tools

Returns:

  • (Object)

    the current value of tools



12
13
14
# File 'lib/little_ghost/model_capabilities.rb', line 12

def tools
  @tools
end

Class Method Details

.permissiveObject

Supplies a permissive capability set when a provider accepts every optional model feature.



51
52
53
# File 'lib/little_ghost/model_capabilities.rb', line 51

def self.permissive
  new(native_structured_output: true, tools: true, tool_choice: true)
end

.unknownObject

Marks capability support as unknown.



56
57
58
# File 'lib/little_ghost/model_capabilities.rb', line 56

def self.unknown
  new(known: false)
end

Instance Method Details

#known?Boolean

Returns:

  • (Boolean)


40
# File 'lib/little_ghost/model_capabilities.rb', line 40

def known? = known

#native_structured_output?Boolean

Returns:

  • (Boolean)


37
# File 'lib/little_ghost/model_capabilities.rb', line 37

def native_structured_output? = native_structured_output

#supports_parameter?(*names) ⇒ Boolean

Checks whether any supplied parameter name is supported.

Returns:

  • (Boolean)


43
44
45
46
47
# File 'lib/little_ghost/model_capabilities.rb', line 43

def supports_parameter?(*names)
  return true unless supported_parameters

  names.flatten.any? { |name| supported_parameters.include?(name.to_s) }
end

#tool_choice?Boolean

Returns:

  • (Boolean)


39
# File 'lib/little_ghost/model_capabilities.rb', line 39

def tool_choice? = tool_choice

#tools?Boolean

Returns:

  • (Boolean)


38
# File 'lib/little_ghost/model_capabilities.rb', line 38

def tools? = tools