Skip to content

Commit 3031110

Browse files
committed
Try again
1 parent 905c511 commit 3031110

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/ruby_llm/template/chat_extension.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ def with_template(template_name, context = {})
2626
if loader.available_roles.include?("schema")
2727
schema_result = loader.render_template("schema", context)
2828

29-
if schema_result&.respond_to?(:to_json_schema)
30-
# It's a RubyLLM::Schema instance
31-
schema_data = schema_result.to_json_schema
32-
with_schema(schema_data)
29+
if schema_result
30+
if schema_result.is_a?(Class) && schema_result < RubyLLM::Schema
31+
# It's a schema class, pass it directly to with_schema
32+
with_schema(schema_result)
33+
elsif schema_result.respond_to?(:to_json_schema)
34+
# It's a RubyLLM::Schema instance
35+
schema_data = schema_result.to_json_schema
36+
with_schema(schema_data)
37+
end
3338
end
3439
end
3540

lib/ruby_llm/template/loader.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def load_schema_class(context = {})
112112
end
113113

114114
if schema_class
115-
return schema_class.new
115+
return schema_class
116116
end
117117

118118
# 3. If nothing worked, provide detailed error

0 commit comments

Comments
 (0)