From 74d47a97c6e87a7bd681f416a3db635eebf91710 Mon Sep 17 00:00:00 2001 From: Rafael Silva Date: Fri, 16 May 2025 15:42:42 -0300 Subject: [PATCH] post rebase fixes --- lib/inferred_concepts/applier.rb | 2 -- lib/personas/bot.rb | 10 ++++++---- lib/personas/bot_context.rb | 10 ++-------- lib/personas/concept_deduplicator.rb | 6 +++++- lib/personas/concept_finder.rb | 6 +++++- lib/personas/concept_matcher.rb | 6 +++++- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/lib/inferred_concepts/applier.rb b/lib/inferred_concepts/applier.rb index 1a2f4c4a..c73bb4c8 100644 --- a/lib/inferred_concepts/applier.rb +++ b/lib/inferred_concepts/applier.rb @@ -125,8 +125,6 @@ module DiscourseAi response = bot.reply(context) - debugger - matching_concepts = JSON.parse(response[0][0]).dig("matching_concepts") matching_concepts || [] diff --git a/lib/personas/bot.rb b/lib/personas/bot.rb index b6e852c5..0dd726df 100644 --- a/lib/personas/bot.rb +++ b/lib/personas/bot.rb @@ -152,10 +152,12 @@ module DiscourseAi raw_context << partial current_thinking << partial end - elsif partial.is_a?(DiscourseAi::Completions::StructuredOutput) - update_blk.call(partial, nil, :structured_output) - else - update_blk.call(partial) + elsif update_blk.present? + if partial.is_a?(DiscourseAi::Completions::StructuredOutput) + update_blk.call(partial, nil, :structured_output) + else + update_blk.call(partial) + end end end end diff --git a/lib/personas/bot_context.rb b/lib/personas/bot_context.rb index 83220a52..8ee81404 100644 --- a/lib/personas/bot_context.rb +++ b/lib/personas/bot_context.rb @@ -17,11 +17,8 @@ module DiscourseAi :context_post_ids, :feature_name, :resource_url, -<<<<<<< HEAD - :cancel_manager -======= + :cancel_manager, :inferred_concepts ->>>>>>> 44391e27 (FEATURE: Extend inferred concepts to include posts) def initialize( post: nil, @@ -39,11 +36,8 @@ module DiscourseAi context_post_ids: nil, feature_name: "bot", resource_url: nil, -<<<<<<< HEAD - cancel_manager: nil -======= + cancel_manager: nil, inferred_concepts: [] ->>>>>>> 44391e27 (FEATURE: Extend inferred concepts to include posts) ) @participants = participants @user = user diff --git a/lib/personas/concept_deduplicator.rb b/lib/personas/concept_deduplicator.rb index d5a5048d..4c6902f1 100644 --- a/lib/personas/concept_deduplicator.rb +++ b/lib/personas/concept_deduplicator.rb @@ -3,6 +3,10 @@ module DiscourseAi module Personas class ConceptDeduplicator < Persona + def self.default_enabled + false + end + def system_prompt <<~PROMPT.strip You will be given a list of machine-generated tags. @@ -42,7 +46,7 @@ module DiscourseAi end def response_format - [{ key: "streamlined_tags", type: "array" }] + [{ "key" => "streamlined_tags", "type" => "array" }] end end end diff --git a/lib/personas/concept_finder.rb b/lib/personas/concept_finder.rb index a713e8b8..912e42fe 100644 --- a/lib/personas/concept_finder.rb +++ b/lib/personas/concept_finder.rb @@ -3,6 +3,10 @@ module DiscourseAi module Personas class ConceptFinder < Persona + def self.default_enabled + false + end + def system_prompt existing_concepts = DiscourseAi::InferredConcepts::Manager.list_concepts(limit: 100) existing_concepts_text = "" @@ -38,7 +42,7 @@ module DiscourseAi end def response_format - [{ key: "concepts", type: "array" }] + [{ "key" => "concepts", "type" => "array" }] end end end diff --git a/lib/personas/concept_matcher.rb b/lib/personas/concept_matcher.rb index 5099196b..8cdcdb0f 100644 --- a/lib/personas/concept_matcher.rb +++ b/lib/personas/concept_matcher.rb @@ -3,6 +3,10 @@ module DiscourseAi module Personas class ConceptMatcher < Persona + def self.default_enabled + false + end + def system_prompt <<~PROMPT.strip You are an advanced concept matching system that determines which concepts from a provided list are relevant to a piece of content. @@ -32,7 +36,7 @@ module DiscourseAi end def response_format - [{ key: "matching_concepts", type: "array" }] + [{ "key" => "matching_concepts", "type" => "array" }] end end end