UX: Avoid introductory phrases and summarize topics without replies (#848)
This commit is contained in:
parent
6d504ab80d
commit
3533814870
|
@ -45,16 +45,19 @@ module DiscourseAi
|
|||
summarize_chunks(initial_chunks, user, opts, &on_partial_blk)
|
||||
end
|
||||
|
||||
clean_summary =
|
||||
Nokogiri::HTML5.fragment(result[:summary]).css("ai")&.first&.text || result[:summary]
|
||||
|
||||
if persist_summaries
|
||||
AiSummary.store!(
|
||||
strategy.target,
|
||||
strategy.type,
|
||||
llm_model.name,
|
||||
result[:summary],
|
||||
clean_summary,
|
||||
content_to_summarize[:contents].map { |c| c[:id] },
|
||||
)
|
||||
else
|
||||
AiSummary.new(summarized_text: result[:summary])
|
||||
AiSummary.new(summarized_text: clean_summary)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -95,22 +95,34 @@ module DiscourseAi
|
|||
- Use the original language of the text.
|
||||
- Begin directly with the main topic or issue, avoiding introductory phrases.
|
||||
- Limit the summary to a maximum of 20 words.
|
||||
|
||||
Return the 20-word summary inside <ai></ai> tags.
|
||||
TEXT
|
||||
|
||||
prompt.push(type: :user, content: <<~TEXT.strip)
|
||||
context = +<<~TEXT
|
||||
### Context:
|
||||
|
||||
The conversation began with the following statement:
|
||||
|
||||
#{opts[:content_title].present? ? "The discussion title is: " + opts[:content_title] + ".\n" : ""}
|
||||
|
||||
#{statements&.pop}
|
||||
The conversation began with the following statement:
|
||||
|
||||
#{statements&.pop}\n
|
||||
TEXT
|
||||
|
||||
if statements.present?
|
||||
context << <<~TEXT
|
||||
Subsequent discussion includes the following:
|
||||
|
||||
#{statements&.join}
|
||||
#{statements&.join("\n")}
|
||||
|
||||
Your task is to focus on these latest messages, capturing their meaning in the context of the initial post.
|
||||
Your task is to focus on these latest messages, capturing their meaning in the context of the initial statement.
|
||||
TEXT
|
||||
else
|
||||
context << "Your task is to capture the meaning of the initial statement."
|
||||
end
|
||||
|
||||
prompt.push(type: :user, content: <<~TEXT.strip)
|
||||
#{context} Return the 20-word summary inside <ai></ai> tags.
|
||||
TEXT
|
||||
|
||||
prompt
|
||||
|
|
Loading…
Reference in New Issue