mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-25 17:12:16 +00:00
FIX: Make summaries more cohesive by tweaking prompt. (#310)
Other changes: - Don't use Bedrock for non claude models if credentials are set. - Remove extra sentence from HyDE prompt.
This commit is contained in:
parent
df8804afcd
commit
419c43592a
@ -5,7 +5,8 @@ module DiscourseAi
|
|||||||
module Endpoints
|
module Endpoints
|
||||||
class AwsBedrock < Base
|
class AwsBedrock < Base
|
||||||
def self.can_contact?(model_name)
|
def self.can_contact?(model_name)
|
||||||
SiteSetting.ai_bedrock_access_key_id.present? &&
|
%w[claude-instant-1 claude-2].include?(model_name) &&
|
||||||
|
SiteSetting.ai_bedrock_access_key_id.present? &&
|
||||||
SiteSetting.ai_bedrock_secret_access_key.present? &&
|
SiteSetting.ai_bedrock_secret_access_key.present? &&
|
||||||
SiteSetting.ai_bedrock_region.present?
|
SiteSetting.ai_bedrock_region.present?
|
||||||
end
|
end
|
||||||
|
@ -100,7 +100,6 @@ module DiscourseAi
|
|||||||
You are a content creator for a forum. The forum description is as follows:
|
You are a content creator for a forum. The forum description is as follows:
|
||||||
#{SiteSetting.title}
|
#{SiteSetting.title}
|
||||||
#{SiteSetting.site_description}
|
#{SiteSetting.site_description}
|
||||||
Given the forum description write a forum post about the following subject:
|
|
||||||
TEXT
|
TEXT
|
||||||
input: <<~TEXT,
|
input: <<~TEXT,
|
||||||
Using this description, write a forum post about the subject inside the <input></input> XML tags:
|
Using this description, write a forum post about the subject inside the <input></input> XML tags:
|
||||||
|
@ -105,21 +105,24 @@ module DiscourseAi
|
|||||||
|
|
||||||
def summarization_prompt(input, opts)
|
def summarization_prompt(input, opts)
|
||||||
insts = <<~TEXT
|
insts = <<~TEXT
|
||||||
You are a summarization bot that effectively summarize any text, creating a cohesive narrative.
|
You are a summarization bot that effectively summarize any text
|
||||||
Your replies contain ONLY a summarized version of the text I provided and you, using the same language.
|
Your replies contain ONLY a summarized version of the text I provided and you, using the same language.
|
||||||
You understand and generate Discourse forum Markdown.
|
You understand and generate Discourse forum Markdown.
|
||||||
You format the response, including links, using Markdown.
|
You format the response, including links, using Markdown.
|
||||||
|
Your summaries are always a cohesive narrative in the form of one or multiple paragraphs.
|
||||||
|
|
||||||
TEXT
|
TEXT
|
||||||
|
|
||||||
insts += <<~TEXT if opts[:resource_path]
|
insts += <<~TEXT if opts[:resource_path]
|
||||||
Each message is formatted as "<POST_NUMBER>) <USERNAME> <MESSAGE> "
|
Each post is formatted as "<POST_NUMBER>) <USERNAME> <MESSAGE> "
|
||||||
Append <POST_NUMBER> to #{opts[:resource_path]} when linking posts.
|
Try generating links as well the format is #{opts[:resource_path]}/<POST_NUMBER>
|
||||||
|
For example, a link to the 3rd post in the topic would be [post 3](#{opts[:resource_path]}/3)
|
||||||
TEXT
|
TEXT
|
||||||
|
|
||||||
insts += "The discussion title is: #{opts[:content_title]}.\n" if opts[:content_title]
|
insts += "The discussion title is: #{opts[:content_title]}.\n" if opts[:content_title]
|
||||||
|
|
||||||
prompt = { insts: insts, input: <<~TEXT }
|
prompt = { insts: insts, input: <<~TEXT }
|
||||||
Here is the text, inside <input></input> XML tags:
|
Here is the a list of posts, inside <input></input> XML tags:
|
||||||
|
|
||||||
<input>
|
<input>
|
||||||
#{input}
|
#{input}
|
||||||
@ -129,7 +132,7 @@ module DiscourseAi
|
|||||||
if opts[:resource_path]
|
if opts[:resource_path]
|
||||||
prompt[:examples] = [
|
prompt[:examples] = [
|
||||||
[
|
[
|
||||||
"<input>(1 user1 said: I love Mondays 2) user2 said: I hate Mondays</input>",
|
"<input>1) user1 said: I love Mondays 2) user2 said: I hate Mondays</input>",
|
||||||
"Two users are sharing their feelings toward Mondays. [user1](#{opts[:resource_path]}/1) hates them, while [user2](#{opts[:resource_path]}/2) loves them.",
|
"Two users are sharing their feelings toward Mondays. [user1](#{opts[:resource_path]}/1) hates them, while [user2](#{opts[:resource_path]}/2) loves them.",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user