Class: LittleGhost::StructuredOutput::ToolStrategy

Inherits:
Strategy
  • Object
show all
Defined in:
lib/little_ghost/structured_output.rb

Instance Attribute Summary

Attributes inherited from Strategy

#configuration

Instance Method Summary collapse

Methods inherited from Strategy

#initialize, #output_schema, #provider?, #schema_name

Constructor Details

This class inherits a constructor from LittleGhost::StructuredOutput::Strategy

Instance Method Details

#required_capabilitiesObject



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

def required_capabilities = %i[tools tool_choice].freeze

#result_toolObject



42
43
44
45
46
47
48
49
50
# File 'lib/little_ghost/structured_output.rb', line 42

def result_tool
  {
    name: schema_name,
    description: configuration[:description] ||
      "Submit the final structured result. Call this tool only as the final action.",
    input_schema: configuration.fetch(:schema),
    strict: true
  }.freeze
end

#tool?Boolean

Returns:

  • (Boolean)


30
# File 'lib/little_ghost/structured_output.rb', line 30

def tool? = true

#tool_choice(repair:) ⇒ Object



36
37
38
# File 'lib/little_ghost/structured_output.rb', line 36

def tool_choice(repair:)
  repair ? {name: schema_name}.freeze : :required
end

#tools(ordinary_tools) ⇒ Object



32
33
34
# File 'lib/little_ghost/structured_output.rb', line 32

def tools(ordinary_tools)
  [*ordinary_tools, result_tool].freeze
end