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

Commit 7e2ddee

Browse files
committed
improve framing of goals
1 parent 3fdd031 commit 7e2ddee

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

lib/personas/forum_researcher.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ def system_prompt
2525
As a forum researcher, you will help users come up with the correct research criteria to
2626
properly analyze the forum data.
2727
28+
BE MINDFUL: when running the research tool, specify all the goals you want to achieve in one go, avoid running research multiple times in one turn.
29+
30+
When creating reports ALWAYS bias grounding information you provide with links to original posts on the forum.
2831
You will always start with a dry_run of the proposed research criteria.
2932
PROMPT
3033
end

lib/personas/tools/researcher.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ def signature
2020
type: "string",
2121
},
2222
{
23-
name: "goal",
23+
name: "goals",
2424
description:
25-
"The specific information you want to extract or analyze from the filtered content",
25+
"The specific information you want to extract or analyze from the filtered content, you may specify multiple goals",
2626
type: "string",
2727
},
2828
{
@@ -53,24 +53,24 @@ def accepted_options
5353
def invoke(&blk)
5454
@last_filter = parameters[:filter] || ""
5555
post = Post.find_by(id: context.post_id)
56-
goal = parameters[:goal] || ""
56+
goals = parameters[:goals] || ""
5757
dry_run = parameters[:dry_run].nil? ? false : parameters[:dry_run]
5858

5959
filter = DiscourseAi::Utils::Research::Filter.new(@last_filter)
6060

6161
@result_count = filter.search.count
6262

6363
if dry_run
64-
{ dry_run: true, goal: goal, filter: @last_filter, number_of_results: @result_count }
64+
{ dry_run: true, goals: goals, filter: @last_filter, number_of_results: @result_count }
6565
else
66-
process_filter(filter, goal, post, &blk)
66+
process_filter(filter, goals, post, &blk)
6767
end
6868
end
6969

7070
protected
7171

7272
MIN_TOKENS_FOR_RESEARCH = 8000
73-
def process_filter(filter, goal, post, &blk)
73+
def process_filter(filter, goals, post, &blk)
7474
if llm.max_prompt_tokens < MIN_TOKENS_FOR_RESEARCH
7575
raise ArgumentError,
7676
"LLM max tokens too low for research. Minimum is #{MIN_TOKENS_FOR_RESEARCH}."
@@ -84,13 +84,13 @@ def process_filter(filter, goal, post, &blk)
8484

8585
results = []
8686

87-
formatter.each_chunk { |chunk| results << run_inference(chunk[:text], goal, post, &blk) }
88-
{ dry_run: false, goal: goal, filter: @last_filter, results: results }
87+
formatter.each_chunk { |chunk| results << run_inference(chunk[:text], goals, post, &blk) }
88+
{ dry_run: false, goals: goals, filter: @last_filter, results: results }
8989
end
9090

91-
def run_inference(chunk_text, goal, post, &blk)
92-
system_prompt = goal_system_prompt(goal)
93-
user_prompt = goal_user_prompt(goal, chunk_text)
91+
def run_inference(chunk_text, goals, post, &blk)
92+
system_prompt = goal_system_prompt(goals)
93+
user_prompt = goal_user_prompt(goals, chunk_text)
9494

9595
prompt =
9696
DiscourseAi::Completions::Prompt.new(
@@ -112,24 +112,24 @@ def run_inference(chunk_text, goal, post, &blk)
112112
results.join
113113
end
114114

115-
def goal_system_prompt(goal)
115+
def goal_system_prompt(goals)
116116
<<~TEXT
117117
You are a researcher tool designed to analyze and extract information from forum content.
118118
Your task is to process the provided content and extract relevant information based on the specified goal.
119119
120-
Your goal is: #{goal}
120+
Your goal is: #{goals}
121121
TEXT
122122
end
123123

124-
def goal_user_prompt(goal, chunk_text)
124+
def goal_user_prompt(goals, chunk_text)
125125
<<~TEXT
126126
Here is the content to analyze:
127127
128128
{{{
129129
#{chunk_text}
130130
}}}
131131
132-
Your goal is: #{goal}
132+
Your goal is: #{goals}
133133
TEXT
134134
end
135135

@@ -145,7 +145,7 @@ def simulate_count(filter_components)
145145
rand(10..100)
146146
end
147147

148-
def perform_research(filter_components, goal, max_results)
148+
def perform_research(filter_components, goals, max_results)
149149
# This would perform the actual research based on the filter and goal
150150
# For now, return a simplified result structure
151151
format_results([], %w[content url author date])

0 commit comments

Comments
 (0)