Module: Legion::Extensions::Llm::Canonical::ToolSchema
- Defined in:
- lib/legion/extensions/llm/canonical/tool_schema.rb
Overview
Extracts and normalizes tool schemas from ToolDefinition ONLY (04 §6). A schema extractor that tolerates raw hashes is a hidden path over the canonical type — wrong-class input raises (L3).
Constant Summary collapse
- EMPTY_OBJECT =
{ type: 'object', properties: {} }.freeze
Class Method Summary collapse
- .extract(tool_definition) ⇒ Object
- .require_tool_definition!(tool_definition, site) ⇒ Object
- .tool_description(tool_definition) ⇒ Object
- .tool_name(tool_definition) ⇒ Object
Class Method Details
.extract(tool_definition) ⇒ Object
15 16 17 18 |
# File 'lib/legion/extensions/llm/canonical/tool_schema.rb', line 15 def extract(tool_definition) require_tool_definition!(tool_definition, 'ToolSchema.extract') ToolDefinition.normalize_parameters(tool_definition.parameters) end |
.require_tool_definition!(tool_definition, site) ⇒ Object
30 31 32 33 34 |
# File 'lib/legion/extensions/llm/canonical/tool_schema.rb', line 30 def require_tool_definition!(tool_definition, site) return tool_definition if tool_definition.is_a?(ToolDefinition) raise ArgumentError, "#{site}: expected Canonical::ToolDefinition, got #{tool_definition.class}" end |
.tool_description(tool_definition) ⇒ Object
25 26 27 28 |
# File 'lib/legion/extensions/llm/canonical/tool_schema.rb', line 25 def tool_description(tool_definition) require_tool_definition!(tool_definition, 'ToolSchema.tool_description') tool_definition.description end |
.tool_name(tool_definition) ⇒ Object
20 21 22 23 |
# File 'lib/legion/extensions/llm/canonical/tool_schema.rb', line 20 def tool_name(tool_definition) require_tool_definition!(tool_definition, 'ToolSchema.tool_name') tool_definition.name end |