FEATURE: Better link in Claude summaries (#183)

* FEATURE: Better link in Claude summaries

* lint
This commit is contained in:
Rafael dos Santos Silva 2023-09-04 12:04:47 -03:00 committed by GitHub
parent e3abbd9f46
commit 3c4a53b2cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 12 deletions

View File

@ -66,14 +66,16 @@ module DiscourseAi
base_prompt = <<~TEXT
Human: #{initial_instruction}
Try to keep the summary in the same languague as the forum discussion.
Try to keep the summary in the same language as the forum discussion.
Format the response, including links, using markdown.
Include only the summary inside <ai> tags.
TEXT
if opts[:resource_path]
base_prompt += "Try generating links as well the format is #{opts[:resource_path]}.\n"
end
base_prompt += <<~TEXT if opts[:resource_path]
Try generating links as well the format is #{opts[:resource_path]}/POST_ID
For example, a link to the 3rd post in the topic would be [post 3](#{opts[:resource_path]}/3)
TEXT
base_prompt += "Wrap the whole the summary inside <ai> tags.\n"
base_prompt += "The discussion title is: #{opts[:content_title]}.\n" if opts[
:content_title

View File

@ -10,7 +10,7 @@ RSpec.describe DiscourseAi::Summarization::Models::Anthropic do
let(:content) do
{
resource_path: "/t/1/POST_NUMBER",
resource_path: "/t/-/1",
content_title: "This is a title",
contents: [{ poster: "asd", id: 1, text: "This is a text" }],
}
@ -23,10 +23,11 @@ RSpec.describe DiscourseAi::Summarization::Models::Anthropic do
def expected_messages(contents, opts)
base_prompt = <<~TEXT
Human: Summarize the following forum discussion inside the given <input> tag.
Try to keep the summary in the same languague as the forum discussion.
Try to keep the summary in the same language as the forum discussion.
Format the response, including links, using markdown.
Include only the summary inside <ai> tags.
Try generating links as well the format is #{opts[:resource_path]}.
Try generating links as well the format is #{opts[:resource_path]}/POST_ID
For example, a link to the 3rd post in the topic would be [post 3](#{opts[:resource_path]}/3)
Wrap the whole the summary inside <ai> tags.
The discussion title is: #{opts[:content_title]}.
Don't use more than 400 words.
TEXT
@ -104,10 +105,11 @@ RSpec.describe DiscourseAi::Summarization::Models::Anthropic do
instructions = <<~TEXT
Human: Summarize the following forum discussion inside the given <input> tag.
Try to keep the summary in the same languague as the forum discussion.
Try to keep the summary in the same language as the forum discussion.
Format the response, including links, using markdown.
Include only the summary inside <ai> tags.
Try generating links as well the format is #{opts[:resource_path]}.
Try generating links as well the format is #{opts[:resource_path]}/POST_ID
For example, a link to the 3rd post in the topic would be [post 3](#{opts[:resource_path]}/3)
Wrap the whole the summary inside <ai> tags.
The discussion title is: #{opts[:content_title]}.
Don't use more than 400 words.
<input>(1 asd said: This is a</input>