more tweaks...

This commit is contained in:
Sam Saffron 2023-05-31 17:15:32 +10:00
parent 2d299900b9
commit d544f2101b
No known key found for this signature in database
GPG Key ID: B9606168D2FFD9F5
3 changed files with 16 additions and 11 deletions

View File

@ -56,8 +56,12 @@ module DiscourseAi
reply = +(bot_reply_post&.raw || "").dup
reply << "\n\n" if reply.length > 0
raw_reply = +""
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)
cancel&.call
@ -97,7 +101,8 @@ module DiscourseAi
bot_reply_post.post_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)
end
end
@ -107,7 +112,7 @@ module DiscourseAi
end
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
def reply_to(post)
@ -263,14 +268,15 @@ module DiscourseAi
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.
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}
The following !commands are available.
#{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

View File

@ -22,12 +22,10 @@ module DiscourseAi::AiBot::Commands
status:open: not closed or archived
status:closed: closed
status:archived: archived
status:noreplies: post count is 1
status:single_user: only a single user posted on the topic
post_count:X: only topics with X amount of posts
min_posts:X: topics containing a minimum of X 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:=CATEGORY: topics in the CATEGORY excluding subcategories
#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
after:YYYY-MM-DD: only topics created after 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
@ -52,13 +51,12 @@ module DiscourseAi::AiBot::Commands
You only have access to public topics.
Strip the query down to the most important terms.
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.
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 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.
TEXT
@ -66,7 +64,7 @@ module DiscourseAi::AiBot::Commands
end
def result_name
"relevant forum search results"
"search results for #{@args}"
end
def description_args

View File

@ -73,6 +73,7 @@ RSpec.describe DiscourseAi::AiBot::Bot do
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).not_to include("details")
end
end