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)
|
summarize_chunks(initial_chunks, user, opts, &on_partial_blk)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
clean_summary =
|
||||||
|
Nokogiri::HTML5.fragment(result[:summary]).css("ai")&.first&.text || result[:summary]
|
||||||
|
|
||||||
if persist_summaries
|
if persist_summaries
|
||||||
AiSummary.store!(
|
AiSummary.store!(
|
||||||
strategy.target,
|
strategy.target,
|
||||||
strategy.type,
|
strategy.type,
|
||||||
llm_model.name,
|
llm_model.name,
|
||||||
result[:summary],
|
clean_summary,
|
||||||
content_to_summarize[:contents].map { |c| c[:id] },
|
content_to_summarize[:contents].map { |c| c[:id] },
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
AiSummary.new(summarized_text: result[:summary])
|
AiSummary.new(summarized_text: clean_summary)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -95,22 +95,34 @@ module DiscourseAi
|
||||||
- Use the original language of the text.
|
- Use the original language of the text.
|
||||||
- Begin directly with the main topic or issue, avoiding introductory phrases.
|
- Begin directly with the main topic or issue, avoiding introductory phrases.
|
||||||
- Limit the summary to a maximum of 20 words.
|
- Limit the summary to a maximum of 20 words.
|
||||||
|
|
||||||
|
Return the 20-word summary inside <ai></ai> tags.
|
||||||
TEXT
|
TEXT
|
||||||
|
|
||||||
prompt.push(type: :user, content: <<~TEXT.strip)
|
context = +<<~TEXT
|
||||||
### Context:
|
### Context:
|
||||||
|
|
||||||
The conversation began with the following statement:
|
|
||||||
|
|
||||||
#{opts[:content_title].present? ? "The discussion title is: " + opts[:content_title] + ".\n" : ""}
|
#{opts[:content_title].present? ? "The discussion title is: " + opts[:content_title] + ".\n" : ""}
|
||||||
|
|
||||||
|
The conversation began with the following statement:
|
||||||
|
|
||||||
#{statements&.pop}
|
#{statements&.pop}\n
|
||||||
|
TEXT
|
||||||
Subsequent discussion includes the following:
|
|
||||||
|
|
||||||
#{statements&.join}
|
if statements.present?
|
||||||
|
context << <<~TEXT
|
||||||
|
Subsequent discussion includes the following:
|
||||||
|
|
||||||
|
#{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
|
TEXT
|
||||||
|
|
||||||
prompt
|
prompt
|
||||||
|
|
Loading…
Reference in New Issue