Skip to content

Commit 16ec048

Browse files
committed
Fix
1 parent 4975a5b commit 16ec048

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

lib/ruby_llm/schema/dsl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ module DSL
1414
include Utilities
1515
end
1616
end
17-
end
17+
end

lib/ruby_llm/schema/dsl/complex_types.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ module RubyLLM
44
class Schema
55
module DSL
66
module ComplexTypes
7-
def object(name, required: true, **options, &block)
8-
add_property(name, object_schema(**options, &block), required: required)
7+
def object(name, description: nil, required: true, **options, &block)
8+
add_property(name, object_schema(description: description, **options, &block), required: required)
99
end
1010

11-
def array(name, required: true, **options, &block)
12-
add_property(name, array_schema(**options, &block), required: required)
11+
def array(name, description: nil, required: true, **options, &block)
12+
add_property(name, array_schema(description: description, **options, &block), required: required)
1313
end
1414

15-
def any_of(name, required: true, **options, &block)
16-
add_property(name, any_of_schema(**options, &block), required: required)
15+
def any_of(name, description: nil, required: true, **options, &block)
16+
add_property(name, any_of_schema(description: description, **options, &block), required: required)
1717
end
1818

19-
def optional(name, **options, &block)
20-
any_of(name, **options) do
19+
def optional(name, description: nil, &block)
20+
any_of(name, description: description) do
2121
instance_eval(&block)
2222
null
2323
end

lib/ruby_llm/schema/dsl/primitive_types.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ module RubyLLM
44
class Schema
55
module DSL
66
module PrimitiveTypes
7-
def string(name, required: true, **options)
8-
add_property(name, string_schema(**options), required: required)
7+
def string(name, description: nil, required: true, **options)
8+
add_property(name, string_schema(description: description, **options), required: required)
99
end
1010

11-
def number(name, required: true, **options)
12-
add_property(name, number_schema(**options), required: required)
11+
def number(name, description: nil, required: true, **options)
12+
add_property(name, number_schema(description: description, **options), required: required)
1313
end
1414

15-
def integer(name, required: true, **options)
16-
add_property(name, integer_schema(**options), required: required)
15+
def integer(name, description: nil, required: true, **options)
16+
add_property(name, integer_schema(description: description, **options), required: required)
1717
end
1818

19-
def boolean(name, required: true, **options)
20-
add_property(name, boolean_schema(**options), required: required)
19+
def boolean(name, description: nil, required: true, **options)
20+
add_property(name, boolean_schema(description: description, **options), required: required)
2121
end
2222

23-
def null(name, required: true, **options)
24-
add_property(name, null_schema(**options), required: required)
23+
def null(name, description: nil, required: true, **options)
24+
add_property(name, null_schema(description: description, **options), required: required)
2525
end
2626
end
2727
end

lib/ruby_llm/schema/dsl/schema_builders.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module RubyLLM
44
class Schema
55
module DSL
66
module SchemaBuilders
7-
def string_schema(enum: nil, description: nil, min_length: nil, max_length: nil, pattern: nil, format: nil)
7+
def string_schema(description: nil, enum: nil, min_length: nil, max_length: nil, pattern: nil, format: nil)
88
{
99
type: "string",
1010
enum: enum,
@@ -44,7 +44,7 @@ def null_schema(description: nil)
4444
{type: "null", description: description}.compact
4545
end
4646

47-
def object_schema(reference: nil, description: nil, &block)
47+
def object_schema(description: nil, reference: nil, &block)
4848
if reference
4949
reference(reference)
5050
else
@@ -66,7 +66,7 @@ def object_schema(reference: nil, description: nil, &block)
6666
end
6767
end
6868

69-
def array_schema(of: nil, description: nil, min_items: nil, max_items: nil, &block)
69+
def array_schema(description: nil, of: nil, min_items: nil, max_items: nil, &block)
7070
items = determine_array_items(of, &block)
7171

7272
{

lib/ruby_llm/schema/dsl/utilities.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ def collect_schemas_from_block(&block)
4545
schema_builder = self
4646

4747
context = Object.new
48-
48+
4949
# Dynamically create methods for all schema builders
5050
schema_builder.methods.grep(/_schema$/).each do |schema_method|
51-
type_name = schema_method.to_s.sub(/_schema$/, '')
52-
51+
type_name = schema_method.to_s.sub(/_schema$/, "")
52+
5353
context.define_singleton_method(type_name) do |name = nil, **options, &blk|
5454
schemas << schema_builder.send(schema_method, **options, &blk)
5555
end

0 commit comments

Comments
 (0)