Skip to content

Commit 000f318

Browse files
committed
FIX: Default prompts have to be explicit about the expected format.
Wrapping the expected response with `<output>` tags confuses models, especially those from the Claude family, which don't have schema support and rely on prefilling. Relying on prefilling means they only know the response must start with `{`, and how the JSON looks is only hinted at in the system prompt.
1 parent 1fbb439 commit 000f318

17 files changed

+50
-52
lines changed

plugins/discourse-ai/lib/personas/concept_deduplicator.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ def system_prompt
3232
Example Output:
3333
AI, AJAX, API, APK, APT Package Manager, ARIA, ARM Architecture, AWS, Abbreviations
3434
35-
Please provide your streamlined list of tags within <streamlined_tags> key.
35+
Please provide your streamlined list of tags within "streamlined_tags" key.
3636
3737
Remember, the goal is to create a more focused and effective set of tags while maintaining the essence of the original list.
3838
3939
Your output should be in the following format:
40-
<o>
41-
{
42-
"streamlined_tags": ["tag1", "tag3"]
43-
}
44-
</o>
40+
41+
{
42+
"streamlined_tags": ["tag1", "tag3"]
43+
}
44+
45+
reply with valid JSON only
4546
PROMPT
4647
end
4748

plugins/discourse-ai/lib/personas/concept_finder.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ def system_prompt
3333
#{existing_concepts_text}
3434
Format your response as a JSON object with a single key named "concepts", which has an array of concept strings as the value.
3535
Your output should be in the following format:
36-
<o>
37-
{"concepts": ["concept1", "concept2", "concept3"]}
38-
</o>
36+
37+
{"concepts": ["concept1", "concept2", "concept3"]}
3938
4039
Where the concepts are replaced by the actual concepts you've identified.
40+
reply with valid JSON only
4141
PROMPT
4242
end
4343

plugins/discourse-ai/lib/personas/concept_matcher.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ def system_prompt
2727
2828
Format your response as a JSON object with a single key named "matching_concepts", which has an array of concept strings from the provided list.
2929
Your output should be in the following format:
30-
<o>
31-
{"matching_concepts": ["concept1", "concept3", "concept5"]}
32-
</o>
30+
31+
{"matching_concepts": ["concept1", "concept3", "concept5"]}
3332
3433
Only include concepts from the provided list that match the content. If no concepts match, return an empty array.
34+
reply with valid JSON only
3535
PROMPT
3636
end
3737

plugins/discourse-ai/lib/personas/content_creator.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ def system_prompt
1717
1818
Format your response as a JSON object with a single key named "output", which has the created content.
1919
Your output should be in the following format:
20-
<output>
21-
{"output": "xx"}
22-
</output>
20+
21+
{"output": "xx"}
2322
2423
Where "xx" is replaced by the content.
24+
reply with valid JSON only
2525
PROMPT
2626
end
2727

plugins/discourse-ai/lib/personas/custom_prompt.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ def system_prompt
1414
1515
Format your response as a JSON object with a single key named "output", which has the result as the value.
1616
Your output should be in the following format:
17-
<output>
18-
{"output": "xx"}
19-
</output>
17+
18+
{"output": "xx"}
19+
2020
2121
Where "xx" is replaced by the result.
22+
reply with valid JSON only
2223
PROMPT
2324
end
2425

plugins/discourse-ai/lib/personas/image_captioner.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ def system_prompt
1313
1414
Format your response as a JSON object with a single key named "output", which has the caption as the value.
1515
Your output should be in the following format:
16-
<output>
17-
{"output": "xx"}
18-
</output>
16+
17+
{"output": "xx"}
1918
2019
Where "xx" is replaced by the caption.
20+
reply with valid JSON only
2121
PROMPT
2222
end
2323

plugins/discourse-ai/lib/personas/markdown_table_generator.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ def system_prompt
1313
1414
Format your response as a JSON object with a single key named "output", which has the formatted table as the value.
1515
Your output should be in the following format:
16-
<output>
17-
{"output": "xx"}
18-
</output>
16+
17+
{"output": "xx"}
1918
2019
Where "xx" is replaced by the formatted table.
20+
reply with valid JSON only
2121
PROMPT
2222
end
2323

plugins/discourse-ai/lib/personas/post_illustrator.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def system_prompt
1414
1515
Format your response as a JSON object with a single key named "output", which has the generated prompt as the value.
1616
Your output should be in the following format:
17-
<output>
18-
{"output": "xx"}
19-
</output>
17+
18+
{"output": "xx"}
2019
2120
Where "xx" is replaced by the generated prompt.
21+
reply with valid JSON only
2222
PROMPT
2323
end
2424

plugins/discourse-ai/lib/personas/proofreader.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def system_prompt
1515
1616
Format your response as a JSON object with a single key named "output", which has the proofreaded version as the value.
1717
Your output should be in the following format:
18-
<output>
19-
{"output": "xx"}
20-
</output>
18+
19+
{"output": "xx"}
2120
2221
Where "xx" is replaced by the proofreaded version.
22+
reply with valid JSON only
2323
PROMPT
2424
end
2525

plugins/discourse-ai/lib/personas/short_summarizer.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ def system_prompt
2424
2525
Format your response as a JSON object with a single key named "summary", which has the summary as the value.
2626
Your output should be in the following format:
27-
<output>
28-
{"summary": "xx"}
29-
</output>
27+
28+
{"summary": "xx"}
29+
3030
3131
Where "xx" is replaced by the summary.
32+
reply with valid JSON only
3233
PROMPT
3334
end
3435

0 commit comments

Comments
 (0)