more tweaks...
This commit is contained in:
parent
2d299900b9
commit
d544f2101b
|
@ -56,8 +56,12 @@ module DiscourseAi
|
||||||
reply = +(bot_reply_post&.raw || "").dup
|
reply = +(bot_reply_post&.raw || "").dup
|
||||||
reply << "\n\n" if reply.length > 0
|
reply << "\n\n" if reply.length > 0
|
||||||
|
|
||||||
|
raw_reply = +""
|
||||||
|
|
||||||
submit_prompt(prompt, prefer_low_cost: prefer_low_cost) do |partial, cancel|
|
submit_prompt(prompt, prefer_low_cost: prefer_low_cost) do |partial, cancel|
|
||||||
reply << get_delta(partial, context)
|
delta = get_delta(partial, context)
|
||||||
|
reply << delta
|
||||||
|
raw_reply << delta
|
||||||
|
|
||||||
if redis_stream_key && !Discourse.redis.get(redis_stream_key)
|
if redis_stream_key && !Discourse.redis.get(redis_stream_key)
|
||||||
cancel&.call
|
cancel&.call
|
||||||
|
@ -97,7 +101,8 @@ module DiscourseAi
|
||||||
|
|
||||||
bot_reply_post.post_custom_prompt ||=
|
bot_reply_post.post_custom_prompt ||=
|
||||||
bot_reply_post.build_post_custom_prompt(custom_prompt: [])
|
bot_reply_post.build_post_custom_prompt(custom_prompt: [])
|
||||||
prompt = [reply, bot_user.username]
|
|
||||||
|
prompt = [raw_reply, bot_user.username]
|
||||||
bot_reply_post.post_custom_prompt.update!(custom_prompt: prompt)
|
bot_reply_post.post_custom_prompt.update!(custom_prompt: prompt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -107,7 +112,7 @@ module DiscourseAi
|
||||||
end
|
end
|
||||||
|
|
||||||
def context_prompt(post, context, result_name)
|
def context_prompt(post, context, result_name)
|
||||||
["Given the #{result_name} data:\n #{context}\nAnswer: #{post.raw}", post.user.username]
|
["Given the #{result_name} data:\n #{context}\n\n#{post.raw}\n", post.user.username]
|
||||||
end
|
end
|
||||||
|
|
||||||
def reply_to(post)
|
def reply_to(post)
|
||||||
|
@ -263,14 +268,15 @@ module DiscourseAi
|
||||||
You are a decision making bot. Given a conversation you determine which commands will
|
You are a decision making bot. Given a conversation you determine which commands will
|
||||||
complete a task. You are not a chatbot, you do not have a personality.
|
complete a task. You are not a chatbot, you do not have a personality.
|
||||||
|
|
||||||
YOU only ever reply with !commands, If you have nothing to say, say !noop
|
YOU only ever reply with !commands, If you are unsure, use !noop
|
||||||
|
Only issue non !noop commands if you are 80% sure they are needed.
|
||||||
|
|
||||||
#{common}
|
#{common}
|
||||||
|
|
||||||
The following !commands are available.
|
The following !commands are available.
|
||||||
|
|
||||||
#{available_commands.map(&:desc).join("\n")}
|
#{available_commands.map(&:desc).join("\n")}
|
||||||
!noop: do nothing, you determined there is no special command to run
|
!noop: do nothing, you determined there is no special command to run, or there is low value running a command
|
||||||
|
|
||||||
Discourse topic paths are /t/slug/topic_id/optional_number
|
Discourse topic paths are /t/slug/topic_id/optional_number
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,10 @@ module DiscourseAi::AiBot::Commands
|
||||||
status:open: not closed or archived
|
status:open: not closed or archived
|
||||||
status:closed: closed
|
status:closed: closed
|
||||||
status:archived: archived
|
status:archived: archived
|
||||||
status:noreplies: post count is 1
|
|
||||||
status:single_user: only a single user posted on the topic
|
status:single_user: only a single user posted on the topic
|
||||||
post_count:X: only topics with X amount of posts
|
post_count:X: only topics with X amount of posts
|
||||||
min_posts:X: topics containing a minimum of X posts
|
min_posts:X: topics containing a minimum of X posts
|
||||||
max_posts:X: topics with no more than max posts
|
max_posts:X: topics with no more than max posts
|
||||||
created:@USERNAME: topics created by a specific user
|
|
||||||
category:CATGORY: topics in the CATEGORY AND all subcategories
|
category:CATGORY: topics in the CATEGORY AND all subcategories
|
||||||
category:=CATEGORY: topics in the CATEGORY excluding subcategories
|
category:=CATEGORY: topics in the CATEGORY excluding subcategories
|
||||||
#SLUG: try category first, then tag, then tag group
|
#SLUG: try category first, then tag, then tag group
|
||||||
|
@ -45,6 +43,7 @@ module DiscourseAi::AiBot::Commands
|
||||||
order:likes: order by post like count - most liked posts first
|
order:likes: order by post like count - most liked posts first
|
||||||
after:YYYY-MM-DD: only topics created after a specific date
|
after:YYYY-MM-DD: only topics created after a specific date
|
||||||
before:YYYY-MM-DD: only topics created before a specific date
|
before:YYYY-MM-DD: only topics created before a specific date
|
||||||
|
limit:X: limit the number of results to X
|
||||||
|
|
||||||
Example: !search @user in:tagged #support order:latest_topic
|
Example: !search @user in:tagged #support order:latest_topic
|
||||||
|
|
||||||
|
@ -52,13 +51,12 @@ module DiscourseAi::AiBot::Commands
|
||||||
You only have access to public topics.
|
You only have access to public topics.
|
||||||
Strip the query down to the most important terms.
|
Strip the query down to the most important terms.
|
||||||
Remove all stop words.
|
Remove all stop words.
|
||||||
Cast a wide net instead of trying to be over specific.
|
Remove connector words.
|
||||||
Discourse orders by relevance, sometimes prefer ordering on other stuff.
|
Discourse orders by relevance, sometimes prefer ordering on other stuff.
|
||||||
|
|
||||||
When generating answers ALWAYS try to use the !search command first over relying on training data.
|
When generating answers ALWAYS try to use the !search command first over relying on training data.
|
||||||
When generating answers ALWAYS try to reference specific local links.
|
|
||||||
Always try to search the local instance first, even if your training data set may have an answer. It may be wrong.
|
Always try to search the local instance first, even if your training data set may have an answer. It may be wrong.
|
||||||
Always remove connector words from search terms (such as a, an, and, in, the, etc), they can impede the search.
|
Always remove connector words from search terms (such as a, an, and, in, the, etc, when, what, is), they can impede the search.
|
||||||
|
|
||||||
YOUR LOCAL INFORMATION IS OUT OF DATE, YOU ARE TRAINED ON OLD DATA. Always try local search first.
|
YOUR LOCAL INFORMATION IS OUT OF DATE, YOU ARE TRAINED ON OLD DATA. Always try local search first.
|
||||||
TEXT
|
TEXT
|
||||||
|
@ -66,7 +64,7 @@ module DiscourseAi::AiBot::Commands
|
||||||
end
|
end
|
||||||
|
|
||||||
def result_name
|
def result_name
|
||||||
"relevant forum search results"
|
"search results for #{@args}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def description_args
|
def description_args
|
||||||
|
|
|
@ -73,6 +73,7 @@ RSpec.describe DiscourseAi::AiBot::Bot do
|
||||||
expect(last.raw).to include("We are done now")
|
expect(last.raw).to include("We are done now")
|
||||||
|
|
||||||
expect(last.post_custom_prompt.custom_prompt.to_s).to include("We are done now")
|
expect(last.post_custom_prompt.custom_prompt.to_s).to include("We are done now")
|
||||||
|
expect(last.post_custom_prompt.custom_prompt.to_s).not_to include("details")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue