Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 7db2589

Browse files
authored
DEV: prompt engineering to improve citations (#1351)
1 parent 2fb691c commit 7db2589

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lib/personas/forum_researcher.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def system_prompt
2121
The description is: {site_description}
2222
The participants in this conversation are: {participants}
2323
The date now is: {time}, much has changed since you were trained.
24+
Topic URLs are formatted as: /t/-/TOPIC_ID
25+
Post URLs are formatted as: /t/-/TOPIC_ID/POST_NUMBER
2426
2527
As a forum researcher, guide users through a structured research process:
2628
1. UNDERSTAND: First clarify the user's research goal - what insights are they seeking?
@@ -41,10 +43,12 @@ def system_prompt
4143
4244
Research workflow best practices:
4345
1. Start with a dry_run to gauge the scope (set dry_run:true)
44-
2. If results are too numerous (>1000), add more specific filters
45-
3. If results are too few (<5), broaden your filters
46-
4. For temporal analysis, specify explicit date ranges
47-
5. For user behavior analysis, combine @username with categories or tags
46+
2. For temporal analysis, specify explicit date ranges
47+
3. For user behavior analysis, combine @username with categories or tags
48+
49+
- When formatting research results, format backing links clearly:
50+
- When it is a good fit, link to the topic with descriptive text.
51+
- When it is a good fit, link using markdown footnotes.
4852
PROMPT
4953
end
5054
end

lib/personas/tools/researcher.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,15 @@ def run_inference(chunk_text, goals, post, &blk)
166166

167167
def goal_system_prompt(goals)
168168
<<~TEXT
169-
You are a researcher tool designed to analyze and extract information from forum content.
169+
You are a researcher tool designed to analyze and extract information from forum content on #{Discourse.base_url}.
170+
The current date is #{::Time.zone.now.strftime("%a, %d %b %Y %H:%M %Z")}.
170171
Your task is to process the provided content and extract relevant information based on the specified goal.
172+
When extracting content ALWAYS include the following:
173+
- Multiple citations using Markdown
174+
- Topic citations: Interesting fact [ref](/t/-/TOPIC_ID)
175+
- Post citations: Interesting fact [ref](/t/-/TOPIC_ID/POST_NUMBER)
176+
- Relevent quotes from the direct source content
177+
- Relevant dates and times from the content
171178
172179
Your goal is: #{goals}
173180
TEXT

0 commit comments

Comments
 (0)