This repository was archived by the owner on Jul 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +4
-18
lines changed
lib/completions/endpoints Expand file tree Collapse file tree 2 files changed +4
-18
lines changed Original file line number Diff line number Diff line change @@ -114,8 +114,7 @@ def perform_completion!(
114114 model_params [ :response_format ] . dig ( :json_schema , :schema , :properties )
115115
116116 if schema_properties . present?
117- structured_output =
118- DiscourseAi ::Completions ::StructuredOutput . new ( schema_properties )
117+ structured_output = DiscourseAi ::Completions ::StructuredOutput . new ( schema_properties )
119118 end
120119 end
121120
@@ -430,23 +429,9 @@ def non_streaming_response(
430429 response_data . reject! ( &:blank? )
431430
432431 if structured_output . present?
433- has_string_response = false
434-
435- response_data =
436- response_data . reduce ( [ ] ) do |memo , data |
437- if data . is_a? ( String )
438- structured_output << data
439- has_string_response = true
440- next ( memo )
441- else
442- memo << data
443- end
444-
445- memo
446- end
432+ response_data . each { |data | structured_output << data if data . is_a? ( String ) }
447433
448- # We only include the structured output if there was actually a structured response
449- response_data << structured_output if has_string_response
434+ return structured_output
450435 end
451436
452437 # this is to keep stuff backwards compatible
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ def perform_completion!(
6868 end
6969
7070 response = response . first if response . is_a? ( Array ) && response . length == 1
71+
7172 response
7273 end
7374
You can’t perform that action at this time.
0 commit comments