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 support is unrestricted.

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.



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

#knownObject (readonly)

Returns the value of attribute known

Returns:

  • (Object)

    the current value of known



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

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



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

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



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

def supported_parameters
  @supported_parameters
end

#tool_choiceObject (readonly)

Returns the value of attribute tool_choice

Returns:

  • (Object)

    the current value of tool_choice



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

def tool_choice
  @tool_choice
end

#toolsObject (readonly)

Returns the value of attribute tools

Returns:

  • (Object)

    the current value of tools



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

def tools
  @tools
end

Class Method Details

.permissiveObject

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



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

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

.unknownObject

Marks capability support as unknown.



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

def self.unknown
  new(known: false)
end

Instance Method Details

#known?Boolean

Returns:

  • (Boolean)


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

def known? = known

#native_structured_output?Boolean

Returns:

  • (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.

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

def tool_choice? = tool_choice

#tools?Boolean

Returns:

  • (Boolean)


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

def tools? = tools