mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-07-08 15:22:47 +00:00
FIX: title suggestions should return 5 unique titles
This update fixes a regression from https://github.com/discourse/discourse-ai/pull/1484, which caused AI helper title suggestions to begin suggesting numerous non-unique titles because it was looping through structured responses incorrectly.
This commit is contained in:
parent
7357280e88
commit
422f238f9f
@ -142,14 +142,21 @@ module DiscourseAi
|
|||||||
Proc.new do |partial, _, type|
|
Proc.new do |partial, _, type|
|
||||||
if type == :structured_output && schema_type
|
if type == :structured_output && schema_type
|
||||||
helper_chunk = partial.read_buffered_property(schema_key)
|
helper_chunk = partial.read_buffered_property(schema_key)
|
||||||
if !helper_chunk.nil? && !helper_chunk.empty?
|
next if helper_chunk.nil? || helper_chunk.empty?
|
||||||
if schema_type == "string" || schema_type == "array"
|
|
||||||
helper_response << helper_chunk
|
if schema_type == "array"
|
||||||
else
|
if helper_chunk.is_a?(Array)
|
||||||
helper_response = helper_chunk
|
helper_chunk.each do |item|
|
||||||
|
helper_response << item if helper_response.exclude?(item)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
block.call(helper_chunk) if block && !bad_json
|
elsif schema_type == "string"
|
||||||
|
helper_response << helper_chunk
|
||||||
|
else
|
||||||
|
helper_response = helper_chunk
|
||||||
end
|
end
|
||||||
|
|
||||||
|
block.call(helper_chunk) if block && !bad_json
|
||||||
elsif type.blank?
|
elsif type.blank?
|
||||||
# Assume response is a regular completion.
|
# Assume response is a regular completion.
|
||||||
helper_response << partial
|
helper_response << partial
|
||||||
|
Loading…
x
Reference in New Issue
Block a user