A platform for community discussion. Free, open, simple.
FIX: Default prompts have to be explicit about the expected format. (#34442)
Roman Rizzi5ccd7fa1e44d
diff --git a/plugins/discourse-ai/lib/personas/concept_deduplicator.rb b/plugins/discourse-ai/lib/personas/concept_deduplicator.rbindex 3f2983c3da8..9f93d68178a 100644--- a/plugins/discourse-ai/lib/personas/concept_deduplicator.rb+++ b/plugins/discourse-ai/lib/personas/concept_deduplicator.rb@@ -32,16 +32,17 @@ module DiscourseAiExample Output:AI, AJAX, API, APK, APT Package Manager, ARIA, ARM Architecture, AWS, Abbreviations- Please provide your streamlined list of tags within <streamlined_tags> key.+ Please provide your streamlined list of tags within "streamlined_tags" key.Remember, the goal is to create a more focused and effective set of tags while maintaining the essence of the original list.Your output should be in the following format:- <o>- {- "streamlined_tags": ["tag1", "tag3"]- }- </o>++ {+ "streamlined_tags": ["tag1", "tag3"]+ }++ reply with valid JSON onlyPROMPTenddiff --git a/plugins/discourse-ai/lib/personas/concept_finder.rb b/plugins/discourse-ai/lib/personas/concept_finder.rbindex ab2da8f77e1..283c1e9db1e 100644--- a/plugins/discourse-ai/lib/personas/concept_finder.rb+++ b/plugins/discourse-ai/lib/personas/concept_finder.rb@@ -33,11 +33,11 @@ module DiscourseAi#{existing_concepts_text}Format your response as a JSON object with a single key named "concepts", which has an array of concept strings as the value.Your output should be in the following format:- <o>- {"concepts": ["concept1", "concept2", "concept3"]}- </o>++ {"concepts": ["concept1", "concept2", "concept3"]}Where the concepts are replaced by the actual concepts you've identified.+ reply with valid JSON onlyPROMPTenddiff --git a/plugins/discourse-ai/lib/personas/concept_matcher.rb b/plugins/discourse-ai/lib/personas/concept_matcher.rbindex 58f10c58a0d..46b77817f4a 100644--- a/plugins/discourse-ai/lib/personas/concept_matcher.rb+++ b/plugins/discourse-ai/lib/personas/concept_matcher.rb@@ -27,11 +27,11 @@ module DiscourseAiFormat your response as a JSON object with a single key named "matching_concepts", which has an array of concept strings from the provided list.Your output should be in the following format:- <o>- {"matching_concepts": ["concept1", "concept3", "concept5"]}- </o>++ {"matching_concepts": ["concept1", "concept3", "concept5"]}Only include concepts from the provided list that match the content. If no concepts match, return an empty array.+ reply with valid JSON onlyPROMPTenddiff --git a/plugins/discourse-ai/lib/personas/content_creator.rb b/plugins/discourse-ai/lib/personas/content_creator.rbindex 3bbf3f871ed..f29dc2e7b2d 100644--- a/plugins/discourse-ai/lib/personas/content_creator.rb+++ b/plugins/discourse-ai/lib/personas/content_creator.rb@@ -17,11 +17,11 @@ module DiscourseAiFormat your response as a JSON object with a single key named "output", which has the created content.Your output should be in the following format:- <output>- {"output": "xx"}- </output>++ {"output": "xx"}Where "xx" is replaced by the content.+ reply with valid JSON onlyPROMPTenddiff --git a/plugins/discourse-ai/lib/personas/custom_prompt.rb b/plugins/discourse-ai/lib/personas/custom_prompt.rbindex 166508303cb..1a599aea9c4 100644--- a/plugins/discourse-ai/lib/personas/custom_prompt.rb+++ b/plugins/discourse-ai/lib/personas/custom_prompt.rb@@ -14,11 +14,12 @@ module DiscourseAiFormat your response as a JSON object with a single key named "output", which has the result as the value.Your output should be in the following format:- <output>- {"output": "xx"}- </output>++ {"output": "xx"}+Where "xx" is replaced by the result.+ reply with valid JSON onlyPROMPTenddiff --git a/plugins/discourse-ai/lib/personas/image_captioner.rb b/plugins/discourse-ai/lib/personas/image_captioner.rbindex 7585857a3ad..8eb6aed03e1 100644--- a/plugins/discourse-ai/lib/personas/image_captioner.rb+++ b/plugins/discourse-ai/lib/personas/image_captioner.rb@@ -13,11 +13,11 @@ module DiscourseAiFormat your response as a JSON object with a single key named "output", which has the caption as the value.Your output should be in the following format:- <output>- {"output": "xx"}- </output>++ {"output": "xx"}Where "xx" is replaced by the caption.+ reply with valid JSON onlyPROMPTenddiff --git a/plugins/discourse-ai/lib/personas/markdown_table_generator.rb b/plugins/discourse-ai/lib/personas/markdown_table_generator.rbindex 581f0eb756d..3ec3e375345 100644--- a/plugins/discourse-ai/lib/personas/markdown_table_generator.rb+++ b/plugins/discourse-ai/lib/personas/markdown_table_generator.rb@@ -13,11 +13,11 @@ module DiscourseAiFormat your response as a JSON object with a single key named "output", which has the formatted table as the value.Your output should be in the following format:- <output>- {"output": "xx"}- </output>++ {"output": "xx"}Where "xx" is replaced by the formatted table.+ reply with valid JSON onlyPROMPTenddiff --git a/plugins/discourse-ai/lib/personas/post_illustrator.rb b/plugins/discourse-ai/lib/personas/post_illustrator.rbindex 323fd500d1d..f3e012a542a 100644--- a/plugins/discourse-ai/lib/personas/post_illustrator.rb+++ b/plugins/discourse-ai/lib/personas/post_illustrator.rb@@ -14,11 +14,11 @@ module DiscourseAiFormat your response as a JSON object with a single key named "output", which has the generated prompt as the value.Your output should be in the following format:- <output>- {"output": "xx"}- </output>++ {"output": "xx"}Where "xx" is replaced by the generated prompt.+ reply with valid JSON onlyPROMPTenddiff --git a/plugins/discourse-ai/lib/personas/proofreader.rb b/plugins/discourse-ai/lib/personas/proofreader.rbindex 0067e578d6b..730b831b389 100644--- a/plugins/discourse-ai/lib/personas/proofreader.rb+++ b/plugins/discourse-ai/lib/personas/proofreader.rb@@ -15,11 +15,11 @@ module DiscourseAiFormat your response as a JSON object with a single key named "output", which has the proofreaded version as the value.Your output should be in the following format:- <output>- {"output": "xx"}- </output>++ {"output": "xx"}Where "xx" is replaced by the proofreaded version.+ reply with valid JSON onlyPROMPTenddiff --git a/plugins/discourse-ai/lib/personas/short_summarizer.rb b/plugins/discourse-ai/lib/personas/short_summarizer.rbindex 26af56b9311..723b2677fb8 100644--- a/plugins/discourse-ai/lib/personas/short_summarizer.rb+++ b/plugins/discourse-ai/lib/personas/short_summarizer.rb@@ -24,11 +24,12 @@ module DiscourseAiFormat your response as a JSON object with a single key named "summary", which has the summary as the value.Your output should be in the following format:- <output>- {"summary": "xx"}- </output>++ {"summary": "xx"}+Where "xx" is replaced by the summary.+ reply with valid JSON onlyPROMPTenddiff --git a/plugins/discourse-ai/lib/personas/smart_dates.rb b/plugins/discourse-ai/lib/personas/smart_dates.rbindex fcc656994a7..cbcb4f0acc7 100644--- a/plugins/discourse-ai/lib/personas/smart_dates.rb+++ b/plugins/discourse-ai/lib/personas/smart_dates.rb@@ -24,11 +24,11 @@ module DiscourseAiFormat your response as a JSON object with a single key named "output", which has the formatted result as the value.Your output should be in the following format:- <output>- {"output": "xx"}- </output>++ {"output": "xx"}Where "xx" is replaced by the formatted result.+ reply with valid JSON onlyPROMPTenddiff --git a/plugins/discourse-ai/lib/personas/spam_detector.rb b/plugins/discourse-ai/lib/personas/spam_detector.rbindex 85f782a5fa9..3df11d3ef35 100644--- a/plugins/discourse-ai/lib/personas/spam_detector.rb+++ b/plugins/discourse-ai/lib/personas/spam_detector.rb@@ -46,11 +46,12 @@ module DiscourseAiFormat your response as a JSON object with a one key named "spam", which is a boolean that indicates if a post is spam or legitimate.Your output should be in the following format:- <output>- {"spam": xx}- </output>++ {"spam": xx}Where xx is true if the post is spam, or false if it's legitimate.+ reply with valid JSON only+PROMPTenddiff --git a/plugins/discourse-ai/lib/personas/summarizer.rb b/plugins/discourse-ai/lib/personas/summarizer.rbindex 8cd24902ae4..3c46c473ea5 100644--- a/plugins/discourse-ai/lib/personas/summarizer.rb+++ b/plugins/discourse-ai/lib/personas/summarizer.rb@@ -24,11 +24,11 @@ module DiscourseAiFormat your response as a JSON object with a single key named "summary", which has the summary as the value.Your output should be in the following format:- <output>- {"summary": "xx"}- </output>++ {"summary": "xx"}Where "xx" is replaced by the summary.+ reply with valid JSON onlyPROMPTenddiff --git a/plugins/discourse-ai/lib/personas/tutor.rb b/plugins/discourse-ai/lib/personas/tutor.rbindex 9142346fe4b..ba22b0b658f 100644--- a/plugins/discourse-ai/lib/personas/tutor.rb+++ b/plugins/discourse-ai/lib/personas/tutor.rb@@ -22,11 +22,11 @@ module DiscourseAiFormat your response as a JSON object with a single key named "output", which has the explanation as the value.Your output should be in the following format:- <output>- {"output": "xx"}- </output>++ {"output": "xx"}Where "xx" is replaced by the explanation.+ reply with valid JSON only.PROMPTenddiff --git a/plugins/discourse-ai/spec/lib/personas/concept_deduplicator_spec.rb b/plugins/discourse-ai/spec/lib/personas/concept_deduplicator_spec.rbindex 9a1f36abc18..6ebc355a940 100644--- a/plugins/discourse-ai/spec/lib/personas/concept_deduplicator_spec.rb+++ b/plugins/discourse-ai/spec/lib/personas/concept_deduplicator_spec.rb@@ -15,10 +15,8 @@ RSpec.describe DiscourseAi::Personas::ConceptDeduplicator dolet(:prompt) { persona.system_prompt }it "specifies output format" do- expect(prompt).to include("<streamlined_tags>")- expect(prompt).to include("<o>")+ expect(prompt).to include("streamlined_tags")expect(prompt).to include('"streamlined_tags": ["tag1", "tag3"]')- expect(prompt).to include("</o>")endenddiff --git a/plugins/discourse-ai/spec/lib/personas/concept_finder_spec.rb b/plugins/discourse-ai/spec/lib/personas/concept_finder_spec.rbindex 884fb0d911d..139c478af39 100644--- a/plugins/discourse-ai/spec/lib/personas/concept_finder_spec.rb+++ b/plugins/discourse-ai/spec/lib/personas/concept_finder_spec.rb@@ -43,9 +43,7 @@ RSpec.describe DiscourseAi::Personas::ConceptFinder doit "includes format instructions" doprompt = persona.system_prompt- expect(prompt).to include("<o>")expect(prompt).to include('{"concepts": ["concept1", "concept2", "concept3"]}')- expect(prompt).to include("</o>")endit "includes language preservation instruction" dodiff --git a/plugins/discourse-ai/spec/lib/personas/concept_matcher_spec.rb b/plugins/discourse-ai/spec/lib/personas/concept_matcher_spec.rbindex 955463ca5a8..8a109a75d19 100644--- a/plugins/discourse-ai/spec/lib/personas/concept_matcher_spec.rb+++ b/plugins/discourse-ai/spec/lib/personas/concept_matcher_spec.rb@@ -20,9 +20,7 @@ RSpec.describe DiscourseAi::Personas::ConceptMatcher doit "specifies output format" doexpect(prompt).to include("matching_concepts")- expect(prompt).to include("<o>")expect(prompt).to include('{"matching_concepts": ["concept1", "concept3", "concept5"]}')- expect(prompt).to include("</o>")endend