6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/ruby_llm/schema/json_output.rb', line 6
def to_json_schema
validate!
schema_hash = {
type: "object",
properties: self.class.properties,
required: self.class.required_properties,
additionalProperties: self.class.additional_properties
}
schema_hash[:strict] = self.class.strict unless self.class.strict.nil?
schema_hash["$defs"] = self.class.definitions unless self.class.definitions.empty?
{
name: @name,
description: @description || self.class.description,
schema: schema_hash
}
end
|